This repository was archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathtalks.py
More file actions
119 lines (102 loc) · 3.46 KB
/
talks.py
File metadata and controls
119 lines (102 loc) · 3.46 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
from django.conf.urls import url
from django.conf import settings
from django.db.models import Q
from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
from conference.models import Talk, TALK_STATUS, TALK_TYPE_CHOICES
def talk(request, talk_slug):
"""
Display Talk
"""
talk = get_object_or_404(Talk, slug=talk_slug)
talk_as_dict = dump_relevant_talk_information_to_dict(talk)
return TemplateResponse(
request,
"ep19/bs/talks/talk.html",
{"title": talk.title, "talk": talk, "talk_as_dict": talk_as_dict},
)
def list_accepted_talks_for_current_conference(request):
"""
"""
# Copy from conference/talk_vorting.py;
# Possibly could be refactored to use some function to come up with filters
talk_type = request.GET.get("talk_type", "all")
extra_filters = []
if talk_type == "talk":
extra_filters += [
Q(
type__in=[
TALK_TYPE_CHOICES.t_30,
TALK_TYPE_CHOICES.t_45,
TALK_TYPE_CHOICES.t_60,
]
)
]
if talk_type == "training":
extra_filters += [Q(type__in=[TALK_TYPE_CHOICES.r_180])]
if talk_type == "poster":
extra_filters += [
Q(
type__in=[
TALK_TYPE_CHOICES.i_60,
TALK_TYPE_CHOICES.p_180,
TALK_TYPE_CHOICES.n_60,
TALK_TYPE_CHOICES.n_90,
]
)
]
if talk_type == "helpdesk":
extra_filters += [Q(type__in=[TALK_TYPE_CHOICES.h_180])]
talks = get_accepted_talks_for_current_conference(extra_filters)
return TemplateResponse(
request,
"ep19/bs/talks/list_accepted_talks.html",
{"talks": talks, "talk_type": talk_type}
)
def get_accepted_talks_for_current_conference(extra_filters):
return (
Talk.objects
.filter(
conference=settings.CONFERENCE_CONFERENCE,
status=TALK_STATUS.accepted
)
.filter(*extra_filters)
)
def dump_relevant_talk_information_to_dict(talk: Talk):
output = {
"title": talk.title,
"uuid": talk.uuid,
"slug": talk.slug,
"type": talk.type,
"type_display": talk.get_type_display(),
"subtitle": talk.sub_title,
"abstract_short": talk.abstract_short,
"abstract": talk.getAbstract().body,
"abstract_extra": talk.abstract_extra,
"python_level": talk.get_level_display(),
"domain_level": talk.get_domain_level_display(),
"created": talk.created,
"modified": talk.modified,
"admin_type": talk.admin_type,
"status": talk.status,
"tags": [t.name for t in talk.tags.all()],
"speakers": [],
}
for speaker in talk.get_all_speakers():
ap = speaker.user.attendeeprofile
output["speakers"].append(
{
"id": speaker.user.id,
"name": speaker.user.assopy_user.name(),
"email": speaker.user.email,
"company": ap.company,
"company_homepage": ap.company_homepage,
"bio": getattr(ap.getBio(), "body", ""),
"phone": ap.phone,
}
)
return output
urlpatterns = [
url(r"^$", list_accepted_talks_for_current_conference, name="list"),
url(r"^(?P<talk_slug>[\w-]+)/$", talk, name="talk"),
]