Skip to content

Commit 83c224b

Browse files
committed
라이트닝 토크 신청 기능 추가
1 parent db8ebe7 commit 83c224b

File tree

8 files changed

+150
-21
lines changed

8 files changed

+150
-21
lines changed

program/admin.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from import_export.admin import ImportExportModelAdmin, ImportMixin
1212
from .models import (Room, Program, ProgramTime, ProgramDate, ProgramCategory,
1313
Speaker, Preference, Proposal, TutorialProposal, SprintProposal,
14-
TutorialCheckin, SprintCheckin, OpenReview)
14+
TutorialCheckin, SprintCheckin, OpenReview, LightningTalk)
1515

1616

1717
class RoomAdmin(SummernoteModelAdmin, TranslationAdmin):
@@ -145,3 +145,17 @@ def user(self, o):
145145

146146

147147
admin.site.register(OpenReview, OpenReviewAdmin)
148+
149+
150+
class LightningTalkAdminForm(forms.ModelForm):
151+
class Meta:
152+
model = LightningTalk
153+
fields = '__all__'
154+
155+
156+
class LightningTalkAdmin(admin.ModelAdmin):
157+
form = LightningTalkAdminForm
158+
list_display = ('owner', 'title', 'day', 'accepted', 'created_at')
159+
160+
161+
admin.site.register(LightningTalk, LightningTalkAdmin)

program/forms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def __init__(self, *args, **kwargs):
204204

205205
class Meta:
206206
model = LightningTalk
207-
fields = ('name', 'slide_url', 'day', 'comment',)
207+
fields = ('title', 'slide_url', 'day', 'comment',)
208208
labels = {
209-
'name': _('발표자 이름'),
209+
'title': _('발표 제목'),
210210
'slide_url': _('발표 슬라이드 URL'),
211211
'day': _('발표 요일'),
212212
'comment': _('준비위원회에게 남기고 싶은 말'),

program/urls.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SpeakerList, SpeakerUpdate, SpeakerDetail,
55
SprintProposalCreate, SprintProposalList, SprintProposalDetail, SprintProposalUpdate,
66
TutorialProposalCreate, TutorialProposalList, TutorialProposalDetail, TutorialProposalUpdate,
7-
RoomDetail, LightningTalkCreate)
7+
RoomDetail)
88
from .views import ProposalCreate, ProposalUpdate, ProposalDetail, ProposalList
99
from .views import schedule, youngcoder, child_care, tutorial_join, sprint_join
1010

@@ -57,10 +57,6 @@
5757
login_required(ProposalList.as_view()), name='proposal-list'),
5858
re_path(r'^cfp/sprint-propose/$',
5959
login_required(SprintProposalCreate.as_view()), name='sprint-propose'),
60-
re_path(r'^lightning-talk/propose/$',
61-
login_required(LightningTalkCreate.as_view()), name='lightning-talk-propose'),
62-
re_path(r'^lightning-talk/detail/$',
63-
login_required(), name='lightning-talk-detail'),
6460

6561
re_path(r'^profile/proposal/(?P<pk>\d+)/edit$',
6662
login_required(ProposalUpdate.as_view()), name='proposal-update'),

program/views.py

+71-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.views.generic.edit import ModelFormMixin
99

1010
from .models import Program, ProgramCategory, Preference, Speaker, Room, Proposal, OpenReview, \
11-
TutorialProposal, SprintProposal
11+
TutorialProposal, SprintProposal, LightningTalk
1212
from .forms import SpeakerForm, SprintProposalForm, TutorialProposalForm, ProposalForm, \
1313
OpenReviewCategoryForm, OpenReviewCommentForm, ProgramForm, LightningTalkForm
1414

@@ -594,12 +594,37 @@ def is_proposal_opened(request):
594594
return flag
595595

596596

597+
def is_lightning_talk_proposable(request):
598+
KST = datetime.timezone(datetime.timedelta(hours=9))
599+
now = datetime.datetime.now(tz=KST)
600+
LT_open_at = constance.config.LIGHTNING_TALK_OPEN.replace(tzinfo=KST)
601+
LT_close_at = constance.config.LIGHTNING_TALK_CLOSE.replace(tzinfo=KST)
602+
if LT_open_at < now < LT_close_at:
603+
return True
604+
else:
605+
return False
606+
607+
608+
class LightningTalkHome(TemplateView):
609+
template_name = "pyconkr/lightning_talk_home.html"
610+
611+
def get_context_data(self, **kwargs):
612+
context = super().get_context_data(**kwargs)
613+
614+
KST = datetime.timezone(datetime.timedelta(hours=9))
615+
context['LT_open_at'] = constance.config.LIGHTNING_TALK_OPEN.replace(tzinfo=KST)
616+
context['LT_close_at'] = constance.config.LIGHTNING_TALK_CLOSE.replace(tzinfo=KST)
617+
context['is_proposable'] = is_lightning_talk_proposable(self.request)
618+
619+
return context
620+
621+
597622
class LightningTalkCreate(CreateView):
598623
form_class = LightningTalkForm
599624
template_name = "pyconkr/lightning_talk_form.html"
600625

601626
def form_valid(self, form):
602-
form.instance.user = self.request.user
627+
form.instance.owner = self.request.user
603628
form.save()
604629
return super(LightningTalkCreate, self).form_valid(form)
605630

@@ -610,14 +635,51 @@ def dispatch(self, request, *args, **kwargs):
610635
if request.user.profile.name == '':
611636
return redirect('profile_edit')
612637

613-
# 라톡이 열리지 않았을 때 redirect
614-
# if CFP_OPENED == -1:
615-
# return redirect("/2020/error/unopened")
616-
# elif CFP_OPENED == 1 and EDIT_AVAILABLE is False:
617-
# return redirect("/2020/error/closed/")
638+
if not is_lightning_talk_proposable(self.request):
639+
return redirect('lightning-talk')
640+
641+
if LightningTalk.objects.filter(owner=self.request.user).exists():
642+
return redirect('lightning-talk-detail')
618643

619644
return super(LightningTalkCreate, self).dispatch(request, *args, **kwargs)
620645

621646
def get_success_url(self):
622-
new_cfp_registered(self.request.META['HTTP_ORIGIN'], self.object.id, self.object.title)
623-
return reverse('proposal-list')
647+
return reverse('lightning-talk-detail')
648+
649+
650+
class LightningTalkDetail(TemplateView):
651+
template_name = "pyconkr/lightning_talk_detail.html"
652+
653+
def dispatch(self, request, *args, **kwargs):
654+
if not LightningTalk.objects.filter(owner=self.request.user).exists():
655+
return redirect('lightning-talk')
656+
return super(LightningTalkDetail, self).dispatch(request, *args, **kwargs)
657+
658+
def get_context_data(self, **kwargs):
659+
context = super(LightningTalkDetail, self).get_context_data(**kwargs)
660+
context['title'] = _("Lightning Talk Proposal")
661+
context['talk'] = LightningTalk.objects.get(owner=self.request.user)
662+
context['is_editable'] = is_lightning_talk_proposable(self.request)
663+
return context
664+
665+
666+
class LightningTalkUpdate(UpdateView):
667+
model = LightningTalk
668+
form_class = LightningTalkForm
669+
template_name = "pyconkr/lightning_talk_form.html"
670+
671+
def dispatch(self, request, *args, **kwargs):
672+
if not LightningTalk.objects.filter(owner=self.request.user).exists() or not is_lightning_talk_proposable(
673+
self.request):
674+
return redirect('lightning-talk')
675+
if LightningTalk.objects.get(id=self.kwargs['pk']).owner != self.request.user:
676+
return redirect('lightning-talk')
677+
678+
return super(LightningTalkUpdate, self).dispatch(request, *args, **kwargs)
679+
680+
def get_context_data(self, **kwargs):
681+
context = super(LightningTalkUpdate, self).get_context_data(**kwargs)
682+
return context
683+
684+
def get_success_url(self):
685+
return reverse('lightning-talk-detail')

pyconkr/context_processors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def default(request):
8585
('cfp', {'title': _('Proposing a Talk')}),
8686
('review-talk-proposal',
8787
{'title': _('Review Talk Proposal')}),
88-
('proposing-tutorial',
89-
{'title': _('Proposing a Tutorial'), 'disable': True}),
88+
('lightning-talk/home',
89+
{'title': _('Proposing a Lightning Talk')}),
9090
('recommending-keynote',
9191
{'title': _('Recommending Keynote')}),
9292
('volunteer', {'title': _('Volunteer'), 'disable': True}),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% extends "base.html" %}
2+
{% load i18n %}
3+
4+
{% block content %}
5+
<div class="row proposal-detail">
6+
<h3>
7+
{{ talk.title }}
8+
</h3>
9+
<br>
10+
<div>
11+
<h4>{% trans "Slide URL" %}</h4>
12+
{{ talk.slide_url }}
13+
</div>
14+
{% if is_editable %}
15+
<div class="a_btn_container">
16+
<a class="a_btn" href="{% url 'lightning-talk-edit' talk.id %}">{% trans "수정하기" %}</a>
17+
</div>
18+
{% endif %}
19+
</div>
20+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends "base.html" %}
2+
{% load i18n %}
3+
4+
{% block title %}
5+
{% trans "Proposing a Lightning Talk" %}
6+
{% endblock %}
7+
8+
{% block content %}
9+
<p>
10+
{% trans "누구나 파이콘 한국 2020에 제출된 발표 제안 내용들을 검토하고 의견을 남겨주실 수 있습니다." %}
11+
</p>
12+
<p>
13+
{% trans "여러분의 손으로 풍성한 파이콘 한국을 만들어주세요 :)" %}
14+
</p>
15+
16+
<h2>{% trans "일정" %}</h2>
17+
<p>
18+
{{ LT_open_at|date:_("Y년 F j일 (D) H:i") }} - {{ LT_close_at|date:_("Y년 F j일 (D) H:i") }}
19+
</p>
20+
21+
<h2>{% trans "문의" %}</h2>
22+
<p><a href="mailto:[email protected]" target="_blank">[email protected]</a></p>
23+
24+
{% if is_proposable %}
25+
<div class="a_btn_container">
26+
<a class="a_btn large" href="{% url 'lightning-talk-propose' %}">{% trans "신청하기" %}</a>
27+
</div>
28+
{% endif %}
29+
{% endblock %}

pyconkr/urls.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from .views import login, logout
1313
from .views import PatronList
1414

15-
from program.views import ProposalCreate, OpenReviewUpdate
16-
from program.views import OpenReviewList, OpenReviewHome, ContributionHome
15+
from program.views import ProposalCreate, OpenReviewUpdate, OpenReviewList, OpenReviewHome, ContributionHome, \
16+
LightningTalkCreate, LightningTalkHome, LightningTalkDetail, LightningTalkUpdate
1717

1818
from django.contrib import admin
1919

@@ -53,6 +53,14 @@
5353
login_required(OpenReviewList.as_view()), name='openreview-list'),
5454
re_path(r'^2020/contribution/review-talk-proposal/review/(?P<pk>\d+)$',
5555
login_required(OpenReviewUpdate.as_view()), name='openreview-update'),
56+
re_path(r'^2020/contribution/lightning-talk/home/$',
57+
login_required(LightningTalkHome.as_view()), name='lightning-talk'),
58+
re_path(r'^2020/contribution/lightning-talk/propose/$',
59+
login_required(LightningTalkCreate.as_view()), name='lightning-talk-propose'),
60+
re_path(r'^2020/contribution/lightning-talk/detail/$',
61+
login_required(LightningTalkDetail.as_view()), name='lightning-talk-detail'),
62+
re_path(r'^2020/contribution/lightning-talk/edit/(?P<pk>\d+)$',
63+
login_required(LightningTalkUpdate.as_view()), name='lightning-talk-edit'),
5664

5765
# for flatpages
5866
re_path(r'^(?P<url>.*/)$', views.flatpage, name='flatpage'),

0 commit comments

Comments
 (0)