events model / form

This commit is contained in:
Sanjay B 2013-02-03 02:58:28 +05:30
parent 44c871f15b
commit 627968b777
4 changed files with 36 additions and 17 deletions

View File

@ -24,7 +24,9 @@ GroupEventInline = itf_inlineformset_factory(Event, GroupEvent, form=GroupEventF
class EventForm(ItfForm): class EventForm(ItfForm):
inlines = [PersonEventInline, GroupEventInline] inlines = [PersonEventInline, GroupEventInline]
parent_event = forms.ModelChoiceField(Event.objects.all(), widget=AutocompleteAddWidget(model_class=Event))
production = forms.ModelChoiceField(Production.objects.all(), widget=AutocompleteAddWidget(model_class=Production))
class Meta: class Meta:
model = Event model = Event
exclude = ('people', 'groups',) exclude = ('people', 'groups',)

View File

@ -6,23 +6,38 @@ from django.contrib.localflavor.in_.forms import INZipCodeField
#from ox.django.fields import DictField #from ox.django.fields import DictField
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic from django.contrib.contenttypes import generic
from itfprofiles.models import Location, Production, TheatreGroup, Person from itfprofiles.models import City, Location, Production, TheatreGroup, Person
EVENT_TYPE_CHOICES = (
('workshop', 'Workshop'),
('talk', 'Talk'),
('performance', 'Performance'),
('festival', 'Festival'),
('other', 'Other'),
)
class Event(ItfModel): class Event(ItfModel):
#ItfModel stuff: #ItfModel stuff:
form_names = ['EventForm'] form_names = ['EventForm']
main_form = 'EventForm' main_form = 'EventForm'
fts_fields = ['title', 'oneliner', 'description'] fts_fields = ['title', 'oneliner', 'description']
added_by = models.ForeignKey(User, editable=False, null=True, blank=True)
title = models.CharField(max_length=1024) title = models.CharField(max_length=1024)
oneliner = models.CharField(max_length=1024,help_text="Event slogan/one liner") event_type = models.CharField(choices=EVENT_TYPE_CHOICES, max_length=64)
oneliner = models.CharField(max_length=1024,help_text="Event slogan/one liner", blank=True)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
locations = generic.GenericRelation(Location) parent_event = models.ForeignKey("Event", related_name='child_events', help_text='If this event is part of another event', blank=True, null=True)
start_date = models.DateTimeField() city = models.ForeignKey(City)
end_date = models.DateTimeField() address = models.TextField(blank=True)
booking_link = models.URLField(blank=True, null=True, help_text="Ticket booking") # location = models.ForeignKey(Location)
# locations = generic.GenericRelation(Location)
start_date = models.DateField()
end_date = models.DateField(null=True, blank=True, help_text='If event is on a single day, leave blank')
start_time = models.TimeField(null=True, blank=True)
end_time = models.TimeField(null=True, blank=True)
booking_link = models.URLField(blank=True, null=True, help_text="Ticket booking link, if applicable")
tel_no = models.CharField(max_length=100, blank=True) tel_no = models.CharField(max_length=100, blank=True)
production = models.ForeignKey(Production, blank=True, null=True, help_text="If this is a showing of a production...") production = models.ForeignKey(Production, blank=True, null=True, help_text="If this is a showing of a production...")
people = models.ManyToManyField(Person, blank=True, null=True, through="PersonEvent") people = models.ManyToManyField(Person, blank=True, null=True, through="PersonEvent")
@ -77,13 +92,13 @@ class GroupEvent(models.Model):
typ = models.CharField(choices=GROUP_EVENT_CHOICES, max_length=128) typ = models.CharField(choices=GROUP_EVENT_CHOICES, max_length=128)
class Connection(models.Model): #class Connection(models.Model):
link_type = models.CharField(max_length=255) # link_type = models.CharField(max_length=255)
extra_text = models.CharField(max_length=1024) # extra_text = models.CharField(max_length=1024)
content_type = models.ForeignKey(ContentType) # content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField() # object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id') # content_object = generic.GenericForeignKey('content_type', 'object_id')
def __unicode__(self): # def __unicode__(self):
return self.link_type # return self.link_type

View File

@ -236,6 +236,7 @@ STATE_CHOICES= (
class City(models.Model): class City(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
state = models.CharField(choices = STATE_CHOICES, max_length=255) state = models.CharField(choices = STATE_CHOICES, max_length=255)
def __unicode__(self): def __unicode__(self):
return self.name return self.name

View File

@ -20,7 +20,8 @@ django-crispy-forms
django-floppyforms django-floppyforms
django-markitup django-markitup
twitter twitter
-e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth #-e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth
-e git://github.com/pennersr/django-allauth.git@92f3ebe231267bffba53c6c0c1d4eb6e13755bb5#egg=django_allauth-0.6.0-py2.7-dev
-e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk -e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk
django-comments-xtd django-comments-xtd
django-avatar django-avatar