added popup forms and widgets for production, group
This commit is contained in:
parent
ab23f16047
commit
2b0d8f8df0
|
@ -9,22 +9,7 @@ from padmavideos.models import PadmaVideo, PadmaClip
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Submit
|
from crispy_forms.layout import Submit
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from app.forms import *
|
||||||
|
|
||||||
class ItfForm(forms.ModelForm):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.helper = FormHelper()
|
|
||||||
self.helper.form_tag = False
|
|
||||||
super(ItfForm, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class PopupForm(ItfForm):
|
|
||||||
'''
|
|
||||||
All popup forms inherit from this
|
|
||||||
'''
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PopupPersonForm(PopupForm):
|
class PopupPersonForm(PopupForm):
|
||||||
|
|
||||||
|
@ -32,38 +17,17 @@ class PopupPersonForm(PopupForm):
|
||||||
model = Person
|
model = Person
|
||||||
|
|
||||||
|
|
||||||
class AutocompleteAddWidget(forms.Select):
|
class PopupGroupForm(PopupForm):
|
||||||
template_name = 'formwidgets/select2.html'
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
class Meta:
|
||||||
ctype = kwargs.pop('ctype')
|
model = TheatreGroup
|
||||||
self.ctype = ctype
|
|
||||||
super(AutocompleteAddWidget, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def get_context(self, name, value, attrs, *args, **kwargs):
|
|
||||||
ctx = super(AutocompleteAddWidget, self).get_context(name, value, attrs)
|
|
||||||
ctx['ctype'] = self.ctype
|
|
||||||
return ctx
|
|
||||||
|
|
||||||
|
|
||||||
#class ConnectionsWidget(forms.SelectMultiple):
|
class PopupProductionForm(PopupForm):
|
||||||
# template_name = 'formwidgets/select2_multiple.html'
|
|
||||||
|
|
||||||
# '''
|
|
||||||
# def get_context_data(self):
|
|
||||||
# ctx = super(ConnectionsWidget, self).get_context_data()
|
|
||||||
#
|
|
||||||
# #ctx['data_json'] = [{'id': obj[0], 'text': obj[1]} for obj in self.choices]
|
|
||||||
# return ctx
|
|
||||||
# '''
|
|
||||||
#
|
|
||||||
# def get_context(self, name, value, attrs, *args, **kwargs):
|
|
||||||
# ctx = super(ConnectionsWidget, self).get_context(name, value, attrs)
|
|
||||||
# ctx['popup_url'] = '/m/person/popup' #FIXME: url scheme, also, a better way to pass this context to the widget template.
|
|
||||||
# #selected_values = [{'id': obj[0], 'text': obj[1]} for obj in self.choices if obj[0] in value]
|
|
||||||
# #ctx['data_json'] = json.dumps(selected_values) # json.dumps(choices)
|
|
||||||
# return ctx
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Production
|
||||||
|
|
||||||
class ItfAllAuthRegForm(forms.Form):
|
class ItfAllAuthRegForm(forms.Form):
|
||||||
firstname=forms.CharField()
|
firstname=forms.CharField()
|
||||||
lastname=forms.CharField()
|
lastname=forms.CharField()
|
||||||
|
@ -86,21 +50,21 @@ class ItfRegistrationForm(RegistrationForm):
|
||||||
|
|
||||||
|
|
||||||
class ConnectionsForm(ItfForm):
|
class ConnectionsForm(ItfForm):
|
||||||
ctype = ContentType.objects.get_for_model(Person)
|
#ctype = ContentType.objects.get_for_model(Person)
|
||||||
person2 = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(ctype=ctype))
|
person2 = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PersonPerson
|
model = PersonPerson
|
||||||
exclude = ('disapproved',)
|
exclude = ('disapproved',)
|
||||||
|
|
||||||
class PersonProductionForm(ItfForm):
|
class PersonProductionForm(ItfForm):
|
||||||
pass
|
production = forms.ModelChoiceField(Production.objects.all(), widget=AutocompleteAddWidget(model_class=Production))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PersonProduction
|
model = PersonProduction
|
||||||
|
|
||||||
class PersonGroupForm(ItfForm):
|
class PersonGroupForm(ItfForm):
|
||||||
pass
|
group = forms.ModelChoiceField(TheatreGroup.objects.all(), widget=AutocompleteAddWidget(model_class=TheatreGroup))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PersonGroup
|
model = PersonGroup
|
||||||
|
|
|
@ -126,6 +126,8 @@ class Play(ItfModel):
|
||||||
|
|
||||||
class Production(ItfModel):
|
class Production(ItfModel):
|
||||||
# user = models.ForeignKey(User)
|
# user = models.ForeignKey(User)
|
||||||
|
fts_fields = ['name', 'group__name']
|
||||||
|
form_names = ['PopupProductionForm']
|
||||||
play = models.ForeignKey("Play", null=True, blank=True)
|
play = models.ForeignKey("Play", null=True, blank=True)
|
||||||
name = models.CharField(max_length=255, db_index=True)
|
name = models.CharField(max_length=255, db_index=True)
|
||||||
language = models.ForeignKey("Language", blank=True, null=True)
|
language = models.ForeignKey("Language", blank=True, null=True)
|
||||||
|
@ -151,6 +153,8 @@ class PersonProduction(models.Model):
|
||||||
original_cast = models.BooleanField(default=False)
|
original_cast = models.BooleanField(default=False)
|
||||||
|
|
||||||
class TheatreGroup(ItfModel):
|
class TheatreGroup(ItfModel):
|
||||||
|
fts_fields = ['name', 'about']
|
||||||
|
form_names = ['PopupGroupForm']
|
||||||
name = models.CharField(max_length=255, db_index=True) # name + location is unique
|
name = models.CharField(max_length=255, db_index=True) # name + location is unique
|
||||||
city = models.CharField(max_length=255)
|
city = models.CharField(max_length=255)
|
||||||
location = models.ForeignKey(Location, blank=True, null=True)
|
location = models.ForeignKey(Location, blank=True, null=True)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user