1
1
# -*- coding: utf-8 -*-
2
2
from __future__ import absolute_import , unicode_literals
3
3
4
+ # Third Party Stuff
4
5
from django .contrib .auth .models import User
5
6
from django .core .exceptions import ValidationError
6
7
from django .core .urlresolvers import reverse
13
14
from slugify import slugify
14
15
from uuid_upload_path import upload_to
15
16
17
+ # Junction Stuff
18
+ from junction .base .utils import get_date_diff_display
16
19
from junction .base .constants import ConferenceSettingConstants , ConferenceStatus
17
20
from junction .base .models import AuditModel
18
- from junction .base .utils import get_date_diff_display
19
21
20
22
21
23
@python_2_unicode_compatible
22
24
class Conference (AuditModel ):
23
25
24
26
""" Conference/Event master """
25
-
26
27
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 )
30
30
description = models .TextField (default = "" )
31
31
start_date = models .DateField (verbose_name = "Start Date" )
32
32
end_date = models .DateField (verbose_name = "End Date" )
33
33
logo = models .ImageField (blank = True , null = True , upload_to = upload_to )
34
34
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
54
39
)
55
40
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
+
56
46
deleted = models .BooleanField (default = False , verbose_name = "Is Deleted?" )
57
47
58
48
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'
66
53
67
54
def __str__ (self ):
68
55
return self .name
69
56
70
57
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 })
72
60
73
61
def duration_display (self ):
74
62
return get_date_diff_display (self .start_date , self .end_date )
75
63
76
64
def clean (self ):
77
65
if self .end_date < self .start_date :
78
66
msg = _ ("End date should be greater than start date." )
79
- raise ValidationError ({" end_date" : msg })
67
+ raise ValidationError ({' end_date' : msg })
80
68
81
69
def save (self , * args , ** kwargs ):
82
70
if not self .slug :
83
71
self .slug = slugify (self .name )
84
72
if not self .pk :
85
73
super (Conference , self ).save (* args , ** kwargs )
86
74
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 )
93
79
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
94
85
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 )
109
90
return
110
91
super (Conference , self ).save (* args , ** kwargs )
111
92
112
93
def is_accepting_proposals (self ):
113
94
"""Check if any one of the proposal section is accepting proposal.
114
95
"""
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 ):
119
98
return False
120
99
return self .proposal_types .filter (end_date__gt = now ()).exists ()
121
100
@@ -124,15 +103,17 @@ def is_accepting_proposals(self):
124
103
class ConferenceModerator (AuditModel ):
125
104
126
105
""" 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 )
130
111
active = models .BooleanField (default = True , verbose_name = "Is Active?" )
131
112
132
113
class Meta :
133
114
unique_together = ("conference" , "moderator" )
134
- verbose_name = " moderator"
135
- verbose_name_plural = " moderators"
115
+ verbose_name = ' moderator'
116
+ verbose_name_plural = ' moderators'
136
117
137
118
def __str__ (self ):
138
119
return "{}[{}]" .format (self .moderator .get_full_name (), self .conference )
@@ -142,18 +123,20 @@ def __str__(self):
142
123
class ConferenceProposalReviewer (AuditModel ):
143
124
144
125
""" 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
151
130
)
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" )
152
135
history = HistoricalRecords ()
153
136
154
137
class Meta :
155
- verbose_name = " proposals reviewer"
156
- verbose_name_plural = " proposals reviewers"
138
+ verbose_name = ' proposals reviewer'
139
+ verbose_name_plural = ' proposals reviewers'
157
140
unique_together = ("conference" , "reviewer" )
158
141
159
142
def __str__ (self ):
@@ -175,7 +158,7 @@ def __str__(self):
175
158
176
159
class Room (AuditModel ):
177
160
name = models .CharField (max_length = 100 )
178
- venue = models .ForeignKey (ConferenceVenue )
161
+ venue = models .ForeignKey (ConferenceVenue , on_delete = models . CASCADE )
179
162
180
163
note = models .CharField (max_length = 255 )
181
164
@@ -185,7 +168,7 @@ def __str__(self):
185
168
186
169
@python_2_unicode_compatible
187
170
class ConferenceSetting (AuditModel ):
188
- conference = models .ForeignKey (Conference )
171
+ conference = models .ForeignKey (Conference , on_delete = models . CASCADE )
189
172
name = models .CharField (max_length = 100 , db_index = True )
190
173
value = models .BooleanField (default = False )
191
174
description = models .CharField (max_length = 255 )
0 commit comments