-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathconference.py
More file actions
174 lines (147 loc) · 5.33 KB
/
conference.py
File metadata and controls
174 lines (147 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from model_utils.models import TimeFramedModel, TimeStampedModel
from timezone_field import TimeZoneField
from helpers.models import GeoLocalizedModel
from i18n.fields import I18nCharField, I18nTextField
from .deadline import Deadline, DeadlineStatus
def get_upload_to(instance, filename):
return f"conferences/{instance.code}/{filename}"
class Conference(GeoLocalizedModel, TimeFramedModel, TimeStampedModel):
organizer = models.ForeignKey(
"organizers.Organizer",
verbose_name=_("organizer"),
on_delete=models.PROTECT,
related_name="conferences",
null=True,
)
name = I18nCharField(_("name"), max_length=100)
code = models.CharField(_("code"), max_length=100, unique=True)
timezone = TimeZoneField()
logo = models.ImageField(_("logo"), upload_to=get_upload_to, blank=True)
location = models.TextField(_("location"), max_length=1024, blank=True)
topics = models.ManyToManyField(
"conferences.Topic", verbose_name=_("topics"), blank=True
)
languages = models.ManyToManyField(
"languages.Language", verbose_name=_("languages"), blank=True
)
audience_levels = models.ManyToManyField(
"conferences.AudienceLevel", verbose_name=_("audience levels"), blank=True
)
submission_types = models.ManyToManyField(
"submissions.SubmissionType", verbose_name=_("submission types"), blank=True
)
proposal_tags = models.ManyToManyField(
"submissions.SubmissionTag", verbose_name=_("proposal tags"), blank=True
)
pretix_organizer_id = models.CharField(
_("pretix organizer id"), max_length=200, blank=True, default=""
)
pretix_event_id = models.CharField(
_("pretix event id"), max_length=200, blank=True, default=""
)
pretix_event_url = models.URLField(_("pretix event url"), blank=True, default="")
pretix_conference_voucher_quota_id = models.IntegerField(
_("Pretix speaker voucher quota id"),
blank=True,
null=True,
)
introduction = I18nTextField(_("introduction"), blank=False)
slack_new_proposal_channel_id = models.CharField(
_("New proposal Slack channel ID for notification"),
max_length=255,
blank=True,
default="",
)
slack_new_grant_reply_channel_id = models.CharField(
_("New grant reply Slack channel ID for notification"),
max_length=255,
blank=True,
default="",
)
slack_speaker_invitation_answer_channel_id = models.CharField(
_("New speaker invitation answer Slack channel ID for notification"),
max_length=255,
blank=True,
default="",
)
slack_new_sponsor_lead_channel_id = models.CharField(
_("New sponsor lead Slack channel ID for notification"),
max_length=255,
blank=True,
default="",
)
slack_new_invitation_letter_request_channel_id = models.CharField(
_("New invitation letter request Slack channel ID for notification"),
max_length=255,
blank=True,
default="",
)
video_title_template = models.TextField(
default="",
blank=True,
)
video_description_template = models.TextField(
default="",
blank=True,
)
youtube_video_bottom_text = models.TextField(
default="",
blank=True,
)
frontend_revalidate_url = models.URLField(
default="",
blank=True,
)
frontend_revalidate_secret = models.CharField(
default="",
blank=True,
max_length=32224,
)
def get_slack_oauth_token(self):
return self.organizer.slack_oauth_bot_token
@property
def is_cfp_open(self):
try:
cfp_deadline = self.deadlines.get(type=Deadline.TYPES.cfp)
now = timezone.now()
return cfp_deadline.start <= now <= cfp_deadline.end
except Deadline.DoesNotExist:
return False
@property
def is_voting_open(self):
try:
voting_deadline = self.deadlines.get(type=Deadline.TYPES.voting)
now = timezone.now()
return voting_deadline.start <= now <= voting_deadline.end
except Deadline.DoesNotExist:
return False
@cached_property
def is_voting_closed(self):
try:
voting_deadline = self.deadlines.get(type=Deadline.TYPES.voting)
now = timezone.now()
return voting_deadline.end <= now
except Deadline.DoesNotExist:
return False
@cached_property
def is_grants_open(self):
try:
grants_deadline = self.deadlines.get(type=Deadline.TYPES.grants)
return grants_deadline.status == DeadlineStatus.HAPPENING_NOW
except Deadline.DoesNotExist:
return False
def is_deadline_active(self, deadline_type: str):
try:
deadline = self.deadlines.get(type=deadline_type)
return deadline.status == DeadlineStatus.HAPPENING_NOW
except Deadline.DoesNotExist:
return False
def __str__(self):
return f"{self.name} <{self.code}>"
class Meta:
verbose_name = _("Conference")
verbose_name_plural = _("Conferences")