cleanup in program/
This commit is contained in:
parent
5bffb9c53a
commit
f9ba48ddfb
|
@ -1,7 +1,14 @@
|
|||
from channels.generic.websockets import JsonWebsocketConsumer
|
||||
|
||||
from camps.models import Camp
|
||||
from .models import Event, EventInstance, Favorite, EventLocation, EventType, Speaker
|
||||
from .models import (
|
||||
Event,
|
||||
EventInstance,
|
||||
Favorite,
|
||||
EventLocation,
|
||||
EventType,
|
||||
Speaker
|
||||
)
|
||||
|
||||
|
||||
class ScheduleConsumer(JsonWebsocketConsumer):
|
||||
|
|
|
@ -3,8 +3,9 @@ from django.shortcuts import redirect
|
|||
from django.urls import reverse
|
||||
from . import models
|
||||
from django.contrib import messages
|
||||
import sys, mimetypes
|
||||
from django.http import Http404, HttpResponse
|
||||
import sys
|
||||
import mimetypes
|
||||
|
||||
|
||||
class EnsureCFSOpenMixin(SingleObjectMixin):
|
||||
|
@ -12,7 +13,9 @@ class EnsureCFSOpenMixin(SingleObjectMixin):
|
|||
# do not permit editing if call for speakers is not open
|
||||
if not self.camp.call_for_speakers_open:
|
||||
messages.error(request, "The Call for Speakers is not open.")
|
||||
return redirect(reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}))
|
||||
return redirect(
|
||||
reverse('proposal_list', kwargs={'camp_slug': self.camp.slug})
|
||||
)
|
||||
|
||||
# alright, continue with the request
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
@ -23,8 +26,10 @@ class CreateProposalMixin(SingleObjectMixin):
|
|||
# set camp and user before saving
|
||||
form.instance.camp = self.camp
|
||||
form.instance.user = self.request.user
|
||||
speaker = form.save()
|
||||
return redirect(reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}))
|
||||
form.save()
|
||||
return redirect(
|
||||
reverse('proposal_list', kwargs={'camp_slug': self.camp.slug})
|
||||
)
|
||||
|
||||
|
||||
class EnsureUnapprovedProposalMixin(SingleObjectMixin):
|
||||
|
@ -54,7 +59,9 @@ class EnsureUserOwnsProposalMixin(SingleObjectMixin):
|
|||
# make sure that this proposal belongs to the logged in user
|
||||
if self.get_object().user.username != request.user.username:
|
||||
messages.error(request, "No thanks")
|
||||
return redirect(reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}))
|
||||
return redirect(
|
||||
reverse('proposal_list', kwargs={'camp_slug': self.camp.slug})
|
||||
)
|
||||
|
||||
# alright, continue with the request
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
@ -83,7 +90,10 @@ class PictureViewMixin(SingleObjectMixin):
|
|||
def get_picture_response(self, path):
|
||||
if 'runserver' in sys.argv or 'runserver_plus' in sys.argv:
|
||||
# this is a local devserver situation, guess mimetype from extension and return picture directly
|
||||
response = HttpResponse(self.picture, content_type=mimetypes.types_map[".%s" % self.picture.name.split(".")[-1]])
|
||||
response = HttpResponse(
|
||||
self.picture,
|
||||
content_type=mimetypes.types_map[".%s" % self.picture.name.split(".")[-1]]
|
||||
)
|
||||
else:
|
||||
# make nginx serve the picture using X-Accel-Redirect
|
||||
# (this works for nginx only, other webservers use x-sendfile)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import uuid
|
||||
import os
|
||||
import icalendar
|
||||
import CommonMark
|
||||
import logging
|
||||
|
||||
from datetime import timedelta
|
||||
|
@ -10,12 +9,9 @@ from django.contrib.postgres.fields import DateTimeRangeField
|
|||
from django.contrib import messages
|
||||
from django.db import models
|
||||
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
||||
from django.dispatch import receiver
|
||||
from django.utils.text import slugify
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.urls import reverse
|
||||
from django.apps import apps
|
||||
|
@ -644,7 +640,6 @@ class Speaker(CampRelatedModel):
|
|||
def get_large_picture_url(self):
|
||||
return self.get_picture_url('large')
|
||||
|
||||
|
||||
def serialize(self):
|
||||
data = {
|
||||
'name': self.name,
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,4 +1,3 @@
|
|||
import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
@ -12,7 +11,6 @@ from django.contrib.admin.views.decorators import staff_member_required
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib import messages
|
||||
from django.urls import reverse
|
||||
from django.db.models import Q
|
||||
from django.template import Engine, Context
|
||||
|
||||
import icalendar
|
||||
|
@ -34,7 +32,7 @@ from . import models
|
|||
logger = logging.getLogger("bornhack.%s" % __name__)
|
||||
|
||||
|
||||
############## ical calendar ########################################################
|
||||
# ical calendar
|
||||
|
||||
|
||||
class ICSView(CampViewMixin, View):
|
||||
|
@ -90,7 +88,7 @@ class ICSView(CampViewMixin, View):
|
|||
return response
|
||||
|
||||
|
||||
############## proposals ########################################################
|
||||
# proposals
|
||||
|
||||
|
||||
class ProposalListView(LoginRequiredMixin, CampViewMixin, ListView):
|
||||
|
@ -241,7 +239,7 @@ class EventProposalDetailView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsP
|
|||
template_name = 'eventproposal_detail.html'
|
||||
|
||||
|
||||
################## speakers ###############################################
|
||||
# speakers
|
||||
|
||||
|
||||
@method_decorator(require_safe, name='dispatch')
|
||||
|
@ -268,7 +266,7 @@ class SpeakerListView(CampViewMixin, ListView):
|
|||
template_name = 'speaker_list.html'
|
||||
|
||||
|
||||
################## events ##############################################
|
||||
# events
|
||||
|
||||
|
||||
class EventListView(CampViewMixin, ListView):
|
||||
|
@ -281,7 +279,7 @@ class EventDetailView(CampViewMixin, DetailView):
|
|||
template_name = 'schedule_event_detail.html'
|
||||
|
||||
|
||||
################## schedule #############################################
|
||||
# schedule
|
||||
|
||||
|
||||
class NoScriptScheduleView(CampViewMixin, TemplateView):
|
||||
|
@ -293,13 +291,12 @@ class NoScriptScheduleView(CampViewMixin, TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
|
||||
class ScheduleView(CampViewMixin, TemplateView):
|
||||
template_name = 'schedule_overview.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(ScheduleView, self).get_context_data(**kwargs)
|
||||
context['schedule_midnight_offset_hours'] = settings.SCHEDULE_MIDNIGHT_OFFSET_HOURS;
|
||||
context['schedule_midnight_offset_hours'] = settings.SCHEDULE_MIDNIGHT_OFFSET_HOURS
|
||||
return context
|
||||
|
||||
|
||||
|
@ -308,8 +305,8 @@ class CallForSpeakersView(CampViewMixin, TemplateView):
|
|||
return '%s_call_for_speakers.html' % self.camp.slug
|
||||
|
||||
|
||||
# control center
|
||||
|
||||
################## control center #############################################
|
||||
|
||||
class ProgramControlCenter(CampViewMixin, TemplateView):
|
||||
template_name = "control/index.html"
|
||||
|
|
Loading…
Reference in a new issue