Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translation hooks #45

Merged
merged 3 commits into from
Oct 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions scuole/campuses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from scuole.counties.models import County
from scuole.districts.models import District
from scuole.stats.models import SchoolYear, StatsBase

from django.utils.translation import ugettext_lazy as _

@python_2_unicode_compatible
class Campus(models.Model):
Expand All @@ -33,21 +33,21 @@ class Campus(models.Model):
TWELFTH_GRADE = '12'

GRADE_CHOICES = (
(EARLY_EDUCATION, 'Early education'),
(PRE_KINDERGARTEN, 'Pre-kindergarten'),
(KINDERGARTEN, 'Kindergarten'),
(FIRST_GRADE, '1st Grade'),
(SECOND_GRADE, '2nd Grade'),
(THIRD_GRADE, '3rd Grade'),
(FOURTH_GRADE, '4th Grade'),
(FIFTH_GRADE, '5th Grade'),
(SIXTH_GRADE, '6th Grade'),
(SEVENTH_GRADE, '7th Grade'),
(EIGHTH_GRADE, '8th Grade'),
(NINTH_GRADE, '9th Grade'),
(TENTH_GRADE, '10th Grade'),
(ELEVENTH_GRADE, '11th Grade'),
(TWELFTH_GRADE, '12th Grade'),
(EARLY_EDUCATION, _('Early education')),
(PRE_KINDERGARTEN, _('Pre-kindergarten')),
(KINDERGARTEN, _('Kindergarten')),
(FIRST_GRADE, _('1st Grade')),
(SECOND_GRADE, _('2nd Grade')),
(THIRD_GRADE, _('3rd Grade')),
(FOURTH_GRADE, _('4th Grade')),
(FIFTH_GRADE, _('5th Grade')),
(SIXTH_GRADE, _('6th Grade')),
(SEVENTH_GRADE, _('7th Grade')),
(EIGHTH_GRADE, _('8th Grade')),
(NINTH_GRADE, _('9th Grade')),
(TENTH_GRADE, _('10th Grade')),
(ELEVENTH_GRADE, _('11th Grade')),
(TWELFTH_GRADE, _('12th Grade')),
)

ELEMENTARY_SCHOOL = 'E'
Expand All @@ -56,47 +56,47 @@ class Campus(models.Model):
ELEMENTARY_SECONDARY_SCHOOL = 'B'

SCHOOL_TYPE_CHOICES = (
(ELEMENTARY_SCHOOL, 'Elementary school'),
(MIDDLE_SCHOOL, 'Middle school or junior high school'),
(HIGH_SCHOOL, 'High school'),
(ELEMENTARY_SECONDARY_SCHOOL, 'Elementary/secondary school'),
(ELEMENTARY_SCHOOL, _('Elementary school')),
(MIDDLE_SCHOOL, _('Middle school or junior high school')),
(HIGH_SCHOOL, _('High school')),
(ELEMENTARY_SECONDARY_SCHOOL, _('Elementary/secondary school')),
)

# CCD - SCHNAM
name = models.CharField('Campus name', max_length=200)
name = models.CharField(_('Campus name'), max_length=200)
slug = models.SlugField(max_length=150)
# TEA - CAMPUS
tea_id = models.CharField('TEA campus identifier', max_length=10)
tea_id = models.CharField(_('TEA campus identifier'), max_length=10)
# CCD - PHONE
phone = models.CharField('Campus phone number', max_length=10)
phone = models.CharField(_('Campus phone number'), max_length=10)
# CCD - LSTREE
street = models.CharField('Campus street', max_length=100)
street = models.CharField(_('Campus street'), max_length=100)
# CCD - LCITY
city = models.CharField('Campus city', max_length=200)
city = models.CharField(_('Campus city'), max_length=200)
# CCD - LSTATE
state = USStateField('Campus state', max_length=2)
state = USStateField(_('Campus state'), max_length=2)
# CCD - LZIP-LZIP4
zip_code = USZipCodeField('Campus ZIP Code')
zip_code = USZipCodeField(_('Campus ZIP Code'))
# CCD - ULOCAL
locale = models.CharField(
'Campus NCES urban-centric locale identifier', max_length=15)
_('Campus NCES urban-centric locale identifier'), max_length=15)
# CCD - LATCOD
coordinates = models.PointField(null=True)
# TEA - GRDSPAN
low_grade = models.CharField(
'Lowest grade offered', max_length=2, choices=GRADE_CHOICES)
_('Lowest grade offered'), max_length=2, choices=GRADE_CHOICES)
high_grade = models.CharField(
'Highest grade offered', max_length=2, choices=GRADE_CHOICES)
_('Highest grade offered'), max_length=2, choices=GRADE_CHOICES)
school_type = models.CharField(
'School type', max_length=1, choices=SCHOOL_TYPE_CHOICES)
_('School type'), max_length=1, choices=SCHOOL_TYPE_CHOICES)

district = models.ForeignKey(District, related_name='campuses')
county = models.ForeignKey(County, related_name='campuses')
objects = models.GeoManager()

class Meta:
ordering = ['name']
verbose_name_plural = 'campuses'
verbose_name_plural = _('campuses')

def __str__(self):
return self.name
Expand All @@ -123,7 +123,7 @@ class CampusStats(StatsBase):

class Meta:
unique_together = ('campus', 'year',)
verbose_name_plural = 'Campus stats'
verbose_name_plural = _('Campus stats')

def __str__(self):
return '{0} {1}'.format(self.year.name, self.campus.name)
Expand Down
15 changes: 8 additions & 7 deletions scuole/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from localflavor.us.models import PhoneNumberField

from django.db import models
from django.utils.translation import ugettext_lazy as _


class PersonnelBase(models.Model):
Expand All @@ -16,16 +17,16 @@ class Superintendent(PersonnelBase):
...

"""
name = models.CharField('Name of personnel', max_length=254)
role = models.CharField('Role of personnel', max_length=100)
name = models.CharField(_('Name of personnel'), max_length=254)
role = models.CharField(_('Role of personnel'), max_length=100)

email = models.EmailField('Email of personnel')
phone_number = PhoneNumberField('Phone number of personnel')
email = models.EmailField(_('Email of personnel'))
phone_number = PhoneNumberField(_('Phone number of personnel'))
phone_number_extension = models.CharField(
'Phone number extension', max_length=4, blank=True, default='')
fax_number = PhoneNumberField('Fax number of personnel')
_('Phone number extension'), max_length=4, blank=True, default='')
fax_number = PhoneNumberField(_('Fax number of personnel'))
fax_number_extension = models.CharField(
'Fax number extension', max_length=4, blank=True, default='')
_('Fax number extension'), max_length=4, blank=True, default='')

class Meta:
abstract = True
9 changes: 5 additions & 4 deletions scuole/counties/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
from django.utils.encoding import python_2_unicode_compatible

from scuole.states.models import State
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class County(models.Model):
name = models.CharField('County name', max_length=100)
name = models.CharField(_('County name'), max_length=100)
slug = models.SlugField()
fips = models.CharField('County FIPS place code', max_length=3)
state = models.ForeignKey(State, related_name='counties')
fips = models.CharField(_('County FIPS place code'), max_length=3)
state = models.ForeignKey(State, related_name=_('counties'))

class Meta:
verbose_name_plural = 'counties'
verbose_name_plural = _('counties')

def __str__(self):
return self.name
19 changes: 10 additions & 9 deletions scuole/districts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,32 @@
from scuole.counties.models import County
from scuole.regions.models import Region
from scuole.stats.models import SchoolYear, StatsBase
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class District(models.Model):
# CCD - NAME
name = models.CharField('District name', max_length=200)
name = models.CharField(_('District name'), max_length=200)
slug = models.SlugField(max_length=75)
# TEA - STID
tea_id = models.CharField('TEA district identifier', max_length=6)
tea_id = models.CharField(_('TEA district identifier'), max_length=6)
# CCD - LSTREE
street = models.CharField('District street', max_length=200)
street = models.CharField(_('District street'), max_length=200)
# CCD - LCITY
city = models.CharField('District office city', max_length=100)
city = models.CharField(_('District office city'), max_length=100)
# CCD - LSTATE
state = USStateField(
'District office abbreviated state location', max_length=2)
_('District office abbreviated state location'), max_length=2)
# CCD - LZIP-LZIP4
zip_code = USZipCodeField('District ZIP Code')
zip_code = USZipCodeField(_('District ZIP Code'))
region = models.ForeignKey(
Region, related_name='districts', null=True, blank=True)
county = models.ForeignKey(
County, related_name='districts', null=True, blank=True)
# CCD - LONCOD, LATCOD
coordinates = models.PointField('District office coordinates', null=True)
shape = models.MultiPolygonField('District shape', srid=4326, null=True)
coordinates = models.PointField(_('District office coordinates'), null=True)
shape = models.MultiPolygonField(_('District shape'), srid=4326, null=True)

objects = models.GeoManager()

Expand Down Expand Up @@ -80,7 +81,7 @@ class DistrictStats(StatsBase):

class Meta:
unique_together = ('district', 'year',)
verbose_name_plural = 'District stats'
verbose_name_plural = _('District stats')

def __str__(self):
return '{0} {1}'.format(self.year.name, self.district.name)
Expand Down
7 changes: 4 additions & 3 deletions scuole/regions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

from scuole.states.models import State
from scuole.stats.models import SchoolYear, StatsBase
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class Region(models.Model):
name = models.CharField('Geographic name for region', max_length=20)
region_id = models.CharField('Region identifier', max_length=2)
name = models.CharField(_('Geographic name for region'), max_length=20)
region_id = models.CharField(_('Region identifier'), max_length=2)
slug = models.SlugField()
state = models.ForeignKey(State, related_name='regions')

Expand All @@ -26,7 +27,7 @@ class RegionStats(StatsBase):

class Meta:
unique_together = ('region', 'year',)
verbose_name_plural = 'Region stats'
verbose_name_plural = _('Region stats')

def __str__(self):
return '{0} {1}'.format(self.year.name, self.region.name)
5 changes: 3 additions & 2 deletions scuole/states/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from django.utils.encoding import python_2_unicode_compatible

from scuole.stats.models import SchoolYear, StatsBase
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class State(models.Model):
name = USStateField('State name')
name = USStateField(_('State name'))
slug = models.SlugField()

def __str__(self):
Expand All @@ -25,7 +26,7 @@ class StateStats(StatsBase):

class Meta:
unique_together = ('state', 'year',)
verbose_name_plural = 'State stats'
verbose_name_plural = _('State stats')

def __str__(self):
return '{0} {1}'.format(self.year.name, self.state.name)
Loading