Browse Source

verbose_name, help_text for forms, use HTML 5 widgets; change models - Training and Resource are now generic

Sanj 12 years ago
parent
commit
e7590216e3
  1. 25
      itf/itfprofiles/forms.py
  2. 37
      itf/itfprofiles/models.py
  3. 22
      itf/scriptbank/forms.py
  4. 133
      itf/scriptbank/models.py
  5. 28
      migrations/sqldiff020812.sql

25
itf/itfprofiles/forms.py

@ -45,6 +45,21 @@ class AwardsForm(ItfForm):
AwardsInline = itf_inlineformset_factory(Award, form=AwardsForm, title="Awards", is_generic=True)
class ResourcesForm(ItfForm):
class Meta:
model = Resource
ResourcesInline = itf_inlineformset_factory(Resource, form=ResourcesForm, title="Resources", is_generic=True)
class TrainingsForm(ItfForm):
class Meta:
model = Training
TrainingsInline = itf_inlineformset_factory(Training, form=TrainingsForm, title='Training', is_generic=True)
class PadmaClipForm(ItfForm):
pass
@ -117,9 +132,9 @@ class PersonForm(ItfForm):
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
# connections = forms.ModelMultipleChoiceField(Person.objects.all(), widget=ConnectionsWidget())
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'}))
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'example@email.com'}))
# inlines = [ConnectionsInline]
inlines = [ConnectionsInline, ProductionsInline, GroupsInline, BuzzItemsInline, AwardsInline, PersonOccupationsInline, PadmaClipsInline]
inlines = [PersonOccupationsInline, ConnectionsInline, ProductionsInline, GroupsInline, TrainingsInline, BuzzItemsInline, AwardsInline, ResourcesInline, PadmaClipsInline]
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
@ -134,6 +149,8 @@ class PersonForm(ItfForm):
widgets = {
'first_name': forms.TextInput,
'last_name': forms.TextInput,
'languages': forms.CheckboxSelectMultiple,
'dob': forms.DateInput
# 'occupations': forms.CheckboxSelectMultiple
}
#exclude = ('connections', 'productions', 'occupations', 'groups',)
@ -159,7 +176,7 @@ GroupOccupationInline = itf_inlineformset_factory(TheatreGroup, GroupGroupOccupa
class TheatreGroupForm(ItfForm):
languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple())
inlines = [GroupOccupationInline, PersonGroupInline, BuzzItemsInline, AwardsInline, LocationsInline]
inlines = [GroupOccupationInline, PersonGroupInline, ResourcesInline, BuzzItemsInline, AwardsInline, TrainingsInline, LocationsInline]
class Meta:
model = TheatreGroup
@ -177,7 +194,7 @@ class PersonProductionForm(ItfForm):
PersonProductionInline = itf_inlineformset_factory(Production, PersonProduction, form=PersonProductionForm, title="People associated with the production")
class ProductionForm(ItfForm):
inlines = [PersonProductionInline]
inlines = [PersonProductionInline, AwardsInline]
script = forms.ModelChoiceField(Script.objects.all(), widget=AutocompleteAddWidget(model_class=Script))
director = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person))
playwright = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person))

37
itf/itfprofiles/models.py

@ -24,12 +24,13 @@ class Person(ItfModel):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField(blank=True, null=True, unique=True, db_index=True)
tel_no = models.CharField(max_length=100, blank=True)
about = models.TextField(blank=True, null=True)
tel_no = models.CharField(max_length=100, blank=True, verbose_name='Telephone number')
is_practitioner = models.BooleanField(default=False, verbose_name='Are you a theatre practitioner?')
is_freelancer = models.BooleanField(default=False, verbose_name='Are you a theatre associate?') #Change to is_associate
is_enthusiast = models.BooleanField(default=True, verbose_name='Are you a theatre enthusiast?')
about = models.TextField(blank=True, null=True, verbose_name='About yourself')
dob = models.DateField(null=True, verbose_name="Date of Birth", blank=True)
is_practitioner = models.BooleanField(default=False)
is_enthusiast = models.BooleanField(default=True)
is_freelancer = models.BooleanField(default=False) #Change to is_associate
#Occupation info
occupations = models.ManyToManyField("Occupation", through='PersonOccupation', blank=True, null=True)
@ -43,7 +44,7 @@ class Person(ItfModel):
groups = models.ManyToManyField("TheatreGroup", blank=True, null=True, through='PersonGroup')
connections = models.ManyToManyField('Person', blank=True, null=True, through='PersonPerson')
productions = models.ManyToManyField("Production", blank=True, null=True, through='PersonProduction')
trainings = models.ManyToManyField("Training", blank=True, null=True, related_name="trainee")
trainings = generic.GenericRelation("Training", related_name='Trainee')
# awards = models.ManyToManyField("Award", blank=True, null=True)
languages = models.ManyToManyField("Language", blank=True, null=True) #s added
awards = generic.GenericRelation("Award")
@ -220,6 +221,9 @@ class Training(models.Model):
from_when = models.DateField(blank=True, null=True)
until_when = models.DateField(blank=True, null=True)
locations = generic.GenericRelation("Location")
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
def __unicode__(self):
return self.area
@ -240,10 +244,10 @@ class TheatreGroup(ItfModel):
form_names = ['TheatreGroupForm', 'PopupGroupForm']
main_form = 'TheatreGroupForm'
added_by = models.ForeignKey(User)
name = models.CharField(max_length=255, db_index=True) # name + location is unique
name = models.CharField(max_length=255, db_index=True, help_text='Name of theatre group') # name + location is unique
email = models.EmailField(blank=True, null=True)
# location = models.ForeignKey(Location, blank=True, null=True, related_name="theatregroup_location")
tel = models.IntegerField(blank=True, null=True)
tel = models.IntegerField(blank=True, null=True, verbose_name='Telephone number')
# -- FIXME tel = models.CharField(blank=True, null=True)
languages = models.ManyToManyField("Language", blank=True, null=True)
@ -252,7 +256,7 @@ class TheatreGroup(ItfModel):
awards = generic.GenericRelation("Award")
buzzitems = generic.GenericRelation("BuzzItem")
website = models.URLField(blank=True, verify_exists=False)
resources = models.ManyToManyField("Resource", blank=True, null=True)
resources = generic.GenericRelation("Resource")
locations = generic.GenericRelation("Location")
# albums = generic.GenericRelation(Album)
nature_of_work = models.ManyToManyField("GroupOccupation", blank=True, null=True, through="GroupGroupOccupation")
@ -260,8 +264,8 @@ class TheatreGroup(ItfModel):
about = models.TextField(blank=True, null=True)
#nature_of_work = models.CharField(max_length=255)
founded = models.CharField(max_length=10)
trainings = models.ManyToManyField("Training", blank=True, null=True)
# founded = models.CharField(max_length=10)
trainings = generic.GenericRelation("Training")
def __unicode__(self):
return self.name
@ -293,10 +297,12 @@ class TheatreGroup(ItfModel):
class Resource(models.Model):
title = models.CharField(max_length=255, blank=True)
desc = models.TextField(max_length=10000, blank=True, null =True, help_text="Optional Description, 500 words or less")
fil = models.FileField(upload_to='upload/docs', blank=True, null=True)
fil = models.FileField(upload_to='upload/docs', blank=True, null=True, verbose_name='File')
url = models.URLField(blank=True, null=True, verify_exists=True)
thumbnail= models.ImageField(upload_to='uploads/docs', blank=True, null=True)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
from scriptbank.models import Script
@ -314,6 +320,7 @@ class Production(ItfModel):
director = models.ForeignKey(Person, related_name='productions_directed', blank=True, null=True)
playwright = models.ForeignKey(Person, related_name='productions_authored', blank=True, null=True)
anecdotes = models.TextField(blank=True)
awards = generic.GenericRelation("Award")
def __unicode__(self):
return self.name
@ -380,8 +387,8 @@ class GroupOccupation(models.Model):
class GroupGroupOccupation(models.Model):
theatregroup = models.ForeignKey("TheatreGroup")
groupoccupation = models.ForeignKey("GroupOccupation")
is_main = models.BooleanField(default=False)
groupoccupation = models.ForeignKey("GroupOccupation", verbose_name="Occupation")
is_main = models.BooleanField(default=False, verbose_name="Is this the group's main occupation?")

22
itf/scriptbank/forms.py

@ -1,18 +1,30 @@
import floppyforms as forms
from models import Script
from app.forms import *
from itfprofiles.models import TheatreGroup
class ScriptForm(ItfForm):
class Meta:
model = Script
exclude = ('added_by',)
class ScriptForm(ItfForm):
# no_characters = forms.IntegerField(widget=forms.NumberInput())
# no_of_women = forms.IntegerField(widget=forms.NumberInput())
# approx_duration = forms.IntegerField(widget=forms.NumberInput())
# contact = forms.EmailField(widget=forms.EmailInput())
theatre_group = forms.ModelChoiceField(TheatreGroup.objects.all(), widget=AutocompleteAddWidget(model_class=TheatreGroup))
class Meta:
model = Script
exclude = ('added_by',)
widgets = {
'no_characters': forms.NumberInput,
'no_of_women': forms.NumberInput,
'approx_duration': forms.NumberInput,
'contact': forms.EmailInput
}
class PopupScriptForm(PopupForm):
class Meta:
model = Script
fields = ('title', 'synopsis',)
#fields = ('name', 'email',)

133
itf/scriptbank/models.py

@ -6,8 +6,8 @@ from app.models import ItfModel
from itfprofiles.models import TheatreGroup
GENRES = (
('Fiction', 'Fiction'),
('Comedy', 'Comedy'),
('Fiction', 'Fiction'),
('Comedy', 'Comedy'),
)
LICENSE_TYPE_CHOICES = (
@ -16,90 +16,65 @@ LICENSE_TYPE_CHOICES = (
)
LANGUAGE_CHOICES = (
('en', 'English'),
('hi', 'Hindi'),
('ma', 'Marathi'),
('be', 'Bengali'),
('en', 'English'),
('hi', 'Hindi'),
('ma', 'Marathi'),
('be', 'Bengali'),
)
class Script(ItfModel):
added_by = models.ForeignKey(User)
form_names = ['ScriptForm', 'PopupScriptForm']
main_form = 'ScriptForm'
title = models.CharField(max_length=255)
synopsis = models.TextField(blank=True)
no_characters = models.IntegerField(blank=True, null=True, help_text="Approximate number of characters")
no_of_women = models.IntegerField(blank=True, null=True, help_text="How many characters are women?")
tags = TagField(blank=True)
production_notes = models.TextField(blank=True, help_text="Additional production notes")
language = models.CharField(max_length=32, choices=LANGUAGE_CHOICES)
approx_duration = models.IntegerField(blank=True, null=True, help_text="Approximate time, in minutes")
is_partial = models.BooleanField(default=False, help_text="Check this if you are uploading only a partial script")
author = models.CharField(max_length=255)
contact = models.EmailField()
script = models.FileField(null=True, upload_to='upload/scripts/')
license_adapt = models.ForeignKey("License", related_name="adaptation_license", help_text="License for adaptation rights")
license_perform = models.ForeignKey("License", related_name="performance_license", help_text="License for performance rights")
fts_fields = ['title', 'synopsis', 'author']
fk_fields = ['license_adapt', 'license_perform']
theatre_group = models.ForeignKey(TheatreGroup, help_text="Theatre Group, if any")
added_by = models.ForeignKey(User)
form_names = ['ScriptForm', 'PopupScriptForm']
main_form = 'ScriptForm'
title = models.CharField(max_length=255, help_text="Title of the play")
synopsis = models.TextField(blank=True)
no_characters = models.IntegerField(blank=True, null=True, verbose_name="No of characters", help_text="Approximate number of characters")
no_of_women = models.IntegerField(blank=True, null=True, help_text="How many characters are women?")
tags = TagField(blank=True, help_text="Enter as many tags as you like, separated by commas")
production_notes = models.TextField(blank=True, help_text="Additional production notes")
language = models.CharField(max_length=32, choices=LANGUAGE_CHOICES)
approx_duration = models.IntegerField(blank=True, null=True, verbose_name="Approximate duration", help_text="Approximate time, in minutes")
author = models.CharField(max_length=255, help_text="Name of the author of the play")
contact = models.EmailField()
script = models.FileField(null=True, upload_to='upload/scripts/')
is_partial = models.BooleanField(default=False, verbose_name="Is this a partial script upload?", help_text="Check this if you are uploading only a partial script")
license_adapt = models.ForeignKey("License", related_name="adaptation_license", verbose_name="Adaptation License", help_text="License for adaptation rights")
license_perform = models.ForeignKey("License", related_name="performance_license", verbose_name="Performance License", help_text="License for performance rights")
fts_fields = ['title', 'synopsis', 'author']
fk_fields = ['license_adapt', 'license_perform']
theatre_group = models.ForeignKey(TheatreGroup, help_text="Theatre Group, if any")
# add_form = 'ScriptForm'
#Meta
added = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
added = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.title
def list_dict(self):
return {
'id': self.id,
'title': self.title,
}
def get_dict(self):
return {
'title': self.title,
'synopsis': self.synopsis,
'no_characters': self.no_characters,
'no_of_women': self.no_of_women,
'production_notes': self.production_notes,
'language': self.language,
'approx_duration': self.approx_duration,
'is_partial': self.is_partial,
'author': self.author,
'contact': self.contact,
'script_file': self.script.url,
'license_adapt': self.license_adapt,
'license_perform': self.license_perform
}
def __unicode__(self):
return self.title
def list_dict(self):
return {
'id': self.id,
'title': self.title,
}
def get_dict(self):
return {
'title': self.title,
'synopsis': self.synopsis,
'no_characters': self.no_characters,
'no_of_women': self.no_of_women,
'production_notes': self.production_notes,
'language': self.language,
'approx_duration': self.approx_duration,
'is_partial': self.is_partial,
'author': self.author,
'contact': self.contact,
'script_file': self.script.url,
'license_adapt': self.license_adapt,
'license_perform': self.license_perform
}
'''
@classmethod
def get_list(kls, data):
options = {
'page_no': 1,
'list_size': 8
}
options.update(data)
l = []
page_no = options['page_no']
list_size = options['list_size']
qset = kls.objects.all()
paginator = Paginator(qset, list_size)
try:
results = paginator.page(page_no)
except (EmptyPage, InvalidPage):
results = paginator.page(paginator.num_pages)
for r in results.object_list:
l.append({
'id': r.id,
'title': r.title
})
return l
'''

28
migrations/sqldiff020812.sql

@ -0,0 +1,28 @@
drop table itfprofiles_resource;
drop table itfprofiles_training;
CREATE TABLE `itfprofiles_resource` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`title` varchar(255) NOT NULL,
`desc` longtext,
`fil` varchar(100),
`url` varchar(200),
`thumbnail` varchar(100),
`content_type_id` integer NOT NULL,
`object_id` integer UNSIGNED NOT NULL
)
;
CREATE TABLE `itfprofiles_training` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`person_id` integer NOT NULL,
`area` varchar(255) NOT NULL,
`with_whom` varchar(255) NOT NULL,
`where_id` integer NOT NULL,
`from_when` date,
`until_when` date,
`content_type_id` integer NOT NULL,
`object_id` integer UNSIGNED NOT NULL
)
;
Loading…
Cancel
Save