11# -*- coding: utf-8 -*-
22from __future__ import absolute_import , unicode_literals
33
4+ # Third Party Stuff
45from django .contrib .auth .models import User
56from django .core .exceptions import ValidationError
67from django .core .urlresolvers import reverse
1314from slugify import slugify
1415from uuid_upload_path import upload_to
1516
17+ # Junction Stuff
18+ from junction .base .utils import get_date_diff_display
1619from junction .base .constants import ConferenceSettingConstants , ConferenceStatus
1720from junction .base .models import AuditModel
18- from junction .base .utils import get_date_diff_display
1921
2022
2123@python_2_unicode_compatible
2224class Conference (AuditModel ):
2325
2426 """ Conference/Event master """
25-
2627 name = models .CharField (max_length = 255 , verbose_name = "Conference Name" )
27- slug = AutoSlugField (
28- max_length = 255 , unique = True , populate_from = ("name" ,), editable = True
29- )
28+ slug = AutoSlugField (max_length = 255 , unique = True , populate_from = ('name' ,),
29+ editable = True )
3030 description = models .TextField (default = "" )
3131 start_date = models .DateField (verbose_name = "Start Date" )
3232 end_date = models .DateField (verbose_name = "End Date" )
3333 logo = models .ImageField (blank = True , null = True , upload_to = upload_to )
3434 status = models .PositiveSmallIntegerField (
35- choices = ConferenceStatus .CHOICES , verbose_name = "Current Status"
36- )
37- venue = models .ForeignKey ("ConferenceVenue" , null = True , blank = True )
38-
39- twitter_id = models .CharField (
40- max_length = 100 ,
41- blank = True ,
42- null = True ,
43- default = "" ,
44- help_text = _ ("Used in social share widgets." ),
45- )
46- hashtags = models .CharField (
47- max_length = 100 ,
48- blank = True ,
49- null = True ,
50- default = "" ,
51- help_text = _ (
52- "Used in social sharing, use commas to separate to tags, no '#' required."
53- ),
35+ choices = ConferenceStatus .CHOICES , verbose_name = "Current Status" )
36+ venue = models .ForeignKey (
37+ 'ConferenceVenue' , null = True , blank = True ,
38+ on_delete = models .SET_NULL
5439 )
5540
41+ twitter_id = models .CharField (max_length = 100 , blank = True , null = True , default = '' ,
42+ help_text = _ ('Used in social share widgets.' ))
43+ hashtags = models .CharField (max_length = 100 , blank = True , null = True , default = '' ,
44+ help_text = _ ("Used in social sharing, use commas to separate to tags, no '#' required." ))
45+
5646 deleted = models .BooleanField (default = False , verbose_name = "Is Deleted?" )
5747
5848 class Meta :
59- verbose_name = _ ("Conference" )
60- verbose_name_plural = _ ("Conferences" )
61- ordering = (
62- "-start_date" ,
63- "name" ,
64- )
65- get_latest_by = "start_date"
49+ verbose_name = _ ('Conference' )
50+ verbose_name_plural = _ ('Conferences' )
51+ ordering = ('-start_date' , 'name' ,)
52+ get_latest_by = 'start_date'
6653
6754 def __str__ (self ):
6855 return self .name
6956
7057 def get_absolute_url (self ):
71- return reverse ("conference-detail" , kwargs = {"conference_slug" : self .slug })
58+ return reverse ("conference-detail" , kwargs = {'conference_slug' :
59+ self .slug })
7260
7361 def duration_display (self ):
7462 return get_date_diff_display (self .start_date , self .end_date )
7563
7664 def clean (self ):
7765 if self .end_date < self .start_date :
7866 msg = _ ("End date should be greater than start date." )
79- raise ValidationError ({" end_date" : msg })
67+ raise ValidationError ({' end_date' : msg })
8068
8169 def save (self , * args , ** kwargs ):
8270 if not self .slug :
8371 self .slug = slugify (self .name )
8472 if not self .pk :
8573 super (Conference , self ).save (* args , ** kwargs )
8674 public_voting = ConferenceSettingConstants .ALLOW_PUBLIC_VOTING_ON_PROPOSALS
87- ConferenceSetting .objects .create (
88- name = public_voting ["name" ],
89- value = public_voting ["value" ],
90- description = public_voting ["description" ],
91- conference = self ,
92- )
75+ ConferenceSetting .objects .create (name = public_voting ['name' ],
76+ value = public_voting ['value' ],
77+ description = public_voting ['description' ],
78+ conference = self )
9379 display_propsals = ConferenceSettingConstants .DISPLAY_PROPOSALS_IN_PUBLIC
80+ ConferenceSetting .objects .create (name = display_propsals ['name' ],
81+ value = display_propsals ['value' ],
82+ description = display_propsals ['description' ],
83+ conference = self )
84+ allow_plus_zero_vote = ConferenceSettingConstants .ALLOW_PLUS_ZERO_REVIEWER_VOTE
9485 ConferenceSetting .objects .create (
95- name = display_propsals ["name" ],
96- value = display_propsals ["value" ],
97- description = display_propsals ["description" ],
98- conference = self ,
99- )
100- allow_plus_zero_vote = (
101- ConferenceSettingConstants .ALLOW_PLUS_ZERO_REVIEWER_VOTE
102- )
103- ConferenceSetting .objects .create (
104- name = allow_plus_zero_vote ["name" ],
105- value = allow_plus_zero_vote ["value" ],
106- description = allow_plus_zero_vote ["description" ],
107- conference = self ,
108- )
86+ name = allow_plus_zero_vote ['name' ],
87+ value = allow_plus_zero_vote ['value' ],
88+ description = allow_plus_zero_vote ['description' ],
89+ conference = self )
10990 return
11091 super (Conference , self ).save (* args , ** kwargs )
11192
11293 def is_accepting_proposals (self ):
11394 """Check if any one of the proposal section is accepting proposal.
11495 """
115- if (
116- self .status == ConferenceStatus .CLOSED_CFP
117- or self .status == ConferenceStatus .SCHEDULE_PUBLISHED
118- ):
96+ if (self .status == ConferenceStatus .CLOSED_CFP or
97+ self .status == ConferenceStatus .SCHEDULE_PUBLISHED ):
11998 return False
12099 return self .proposal_types .filter (end_date__gt = now ()).exists ()
121100
@@ -124,15 +103,17 @@ def is_accepting_proposals(self):
124103class ConferenceModerator (AuditModel ):
125104
126105 """ List of Conference Moderators/Administrators """
127-
128- conference = models .ForeignKey (Conference , related_name = "moderators" )
129- moderator = models .ForeignKey (User )
106+ conference = models .ForeignKey (
107+ Conference , related_name = 'moderators' ,
108+ on_delete = models .CASCADE
109+ )
110+ moderator = models .ForeignKey (User , on_delete = models .CASCADE )
130111 active = models .BooleanField (default = True , verbose_name = "Is Active?" )
131112
132113 class Meta :
133114 unique_together = ("conference" , "moderator" )
134- verbose_name = " moderator"
135- verbose_name_plural = " moderators"
115+ verbose_name = ' moderator'
116+ verbose_name_plural = ' moderators'
136117
137118 def __str__ (self ):
138119 return "{}[{}]" .format (self .moderator .get_full_name (), self .conference )
@@ -142,18 +123,20 @@ def __str__(self):
142123class ConferenceProposalReviewer (AuditModel ):
143124
144125 """ List of global proposal reviewers """
145-
146- conference = models .ForeignKey (Conference , related_name = "proposal_reviewers" )
147- reviewer = models .ForeignKey (User )
148- active = models .BooleanField (default = True , verbose_name = "Is Active?" )
149- nick = models .CharField (
150- max_length = 255 , verbose_name = "Nick Name" , default = "Reviewer"
126+ conference = models .ForeignKey (
127+ Conference ,
128+ related_name = 'proposal_reviewers' ,
129+ on_delete = models .CASCADE
151130 )
131+ reviewer = models .ForeignKey (User , on_delete = models .CASCADE )
132+ active = models .BooleanField (default = True , verbose_name = "Is Active?" )
133+ nick = models .CharField (max_length = 255 , verbose_name = "Nick Name" ,
134+ default = "Reviewer" )
152135 history = HistoricalRecords ()
153136
154137 class Meta :
155- verbose_name = " proposals reviewer"
156- verbose_name_plural = " proposals reviewers"
138+ verbose_name = ' proposals reviewer'
139+ verbose_name_plural = ' proposals reviewers'
157140 unique_together = ("conference" , "reviewer" )
158141
159142 def __str__ (self ):
@@ -175,7 +158,7 @@ def __str__(self):
175158
176159class Room (AuditModel ):
177160 name = models .CharField (max_length = 100 )
178- venue = models .ForeignKey (ConferenceVenue )
161+ venue = models .ForeignKey (ConferenceVenue , on_delete = models . CASCADE )
179162
180163 note = models .CharField (max_length = 255 )
181164
@@ -185,7 +168,7 @@ def __str__(self):
185168
186169@python_2_unicode_compatible
187170class ConferenceSetting (AuditModel ):
188- conference = models .ForeignKey (Conference )
171+ conference = models .ForeignKey (Conference , on_delete = models . CASCADE )
189172 name = models .CharField (max_length = 100 , db_index = True )
190173 value = models .BooleanField (default = False )
191174 description = models .CharField (max_length = 255 )
0 commit comments