forked from AFPy/PonyConf
staff: edit talks
This commit is contained in:
parent
c8a242bb04
commit
324634c27d
19
cfp/forms.py
19
cfp/forms.py
|
@ -38,6 +38,25 @@ class TalkForm(forms.ModelForm):
|
|||
fields = ('category', 'title', 'description','notes')
|
||||
|
||||
|
||||
class TalkStaffForm(TalkForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
tracks = kwargs.pop('tracks')
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['track'].queryset = tracks
|
||||
|
||||
class Meta(TalkForm.Meta):
|
||||
fields = ('category', 'track', 'title', 'description','notes')
|
||||
labels = {
|
||||
'category': _('Category'),
|
||||
'title': _('Title'),
|
||||
'description': _('Description'),
|
||||
'notes': _('Notes'),
|
||||
}
|
||||
help_texts = {
|
||||
'notes': _('Visible by speakers'),
|
||||
}
|
||||
|
||||
|
||||
class TalkFilterForm(forms.Form):
|
||||
category = forms.MultipleChoiceField(
|
||||
label=_('Category'),
|
||||
|
|
|
@ -7,11 +7,7 @@
|
|||
|
||||
<h1>{{ talk.title }}</h1>
|
||||
|
||||
{% comment %}
|
||||
{% if edit_perm %}
|
||||
<a class="btn btn-success" href="{% url 'edit-talk' talk.slug %}">{% trans "Edit" %}</a><br />
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
<p><a class="btn btn-success" href="{% url 'talk-edit' talk.token %}">{% trans "Edit" %}</a></p>
|
||||
|
||||
<p>{% if talk.abstract %}{{ talk.abstract }}{% else %}<i>{% trans "No abstract provided." %}</i>{% endif %}</p>
|
||||
|
||||
|
@ -138,7 +134,7 @@
|
|||
|
||||
{% include 'mailing/_message_list.html' with messages=talk.conversation.message_set.all %}
|
||||
|
||||
{% trans "Send a message – <em>this message will be received by the staff team only</em>" as message_form_title %}
|
||||
{% trans "Comment this talk – <em>this message will be received by the staff team only</em>" as message_form_title %}
|
||||
{% include 'mailing/_message_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
13
cfp/templates/cfp/staff/talk_form.html
Normal file
13
cfp/templates/cfp/staff/talk_form.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends 'cfp/staff/base.html' %}
|
||||
{% load i18n crispy_forms_tags %}
|
||||
|
||||
{% block talkstab %} class="active"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>{% trans "Edit a talk" %}</h1>
|
||||
|
||||
{% url 'talk-details' talk.token as cancel_url %}
|
||||
{% include '_form.html' %}
|
||||
|
||||
{% endblock %}
|
|
@ -15,6 +15,7 @@ urlpatterns = [
|
|||
url(r'^staff/talks/(?P<talk_id>[\w\-]+)/vote/(?P<score>[-+0-2]+)/$', views.talk_vote, name='talk-vote'),
|
||||
url(r'^staff/talks/(?P<talk_id>[\w\-]+)/accept/$', views.talk_decide, {'accept': True}, name='talk-accept'),
|
||||
url(r'^staff/talks/(?P<talk_id>[\w\-]+)/decline/$', views.talk_decide, {'accept': False}, name='talk-decline'),
|
||||
url(r'^staff/talks/(?P<talk_id>[\w\-]+)/edit/$', views.TalkEdit.as_view(), name='talk-edit'),
|
||||
url(r'^staff/speakers/$', views.participant_list, name='participant-list'),
|
||||
url(r'^staff/speakers/(?P<participant_id>[\w\-]+)/$', views.participant_details, name='participant-details'),
|
||||
url(r'^staff/add-user/$', views.create_user, name='create-user'),
|
||||
|
|
26
cfp/views.py
26
cfp/views.py
|
@ -6,6 +6,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from django.views.generic import FormView, TemplateView
|
||||
from django.contrib import messages
|
||||
from django.db.models import Q
|
||||
from django.views.generic import CreateView, DetailView, ListView, UpdateView
|
||||
|
||||
from django_select2.views import AutoResponseView
|
||||
|
||||
|
@ -16,8 +17,8 @@ from mailing.forms import MessageForm
|
|||
from .decorators import staff_required
|
||||
from .mixins import StaffRequiredMixin
|
||||
from .utils import is_staff
|
||||
from .models import Participant, Talk, TalkCategory, Vote
|
||||
from .forms import TalkForm, TalkFilterForm, ParticipantForm, ConferenceForm, CreateUserForm, STATUS_VALUES
|
||||
from .models import Participant, Talk, TalkCategory, Vote, Track
|
||||
from .forms import TalkForm, TalkStaffForm, TalkFilterForm, ParticipantForm, ConferenceForm, CreateUserForm, STATUS_VALUES
|
||||
|
||||
|
||||
def home(request, conference):
|
||||
|
@ -324,6 +325,27 @@ You can now:
|
|||
})
|
||||
|
||||
|
||||
class OnSiteMixin:
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(site=self.kwargs['conference'].site)
|
||||
|
||||
|
||||
class TalkEdit(StaffRequiredMixin, OnSiteMixin, UpdateView):
|
||||
model = Talk
|
||||
slug_field = 'token'
|
||||
slug_url_kwarg = 'talk_id'
|
||||
form_class = TalkStaffForm
|
||||
template_name = 'cfp/staff/talk_form.html'
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs.update({
|
||||
'categories': TalkCategory.objects.filter(site=self.kwargs['conference'].site),
|
||||
'tracks': Track.objects.filter(site=self.kwargs['conference'].site),
|
||||
})
|
||||
return kwargs
|
||||
|
||||
|
||||
@staff_required
|
||||
def create_user(request, conference):
|
||||
form = CreateUserForm(request.POST or None)
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
{% for url, class, text in buttons %}
|
||||
<a href="{% url url %}" class="btn btn-{{ class }}">{{ text }}</a>
|
||||
{% endfor %}
|
||||
<a href="{% if request.META.HTTP_REFERER %}{{ request.META.HTTP_REFERER }}{% else %}{% url 'home' %}{% endif %}" class="btn btn-default">{% trans "Cancel" %}</a>
|
||||
<a href="{% if cancel_url %}{{ cancel_url }}{% elif request.META.HTTP_REFERER %}{{ request.META.HTTP_REFERER }}{% else %}{% url 'home' %}{% endif %}" class="btn btn-default">{% trans "Cancel" %}</a>
|
||||
{% endbuttons %}
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue
Block a user