Add admin for Speaker, Presenter and Talk

This commit is contained in:
Michael Hall 2018-04-21 22:14:15 -04:00
parent 437134991d
commit e45c0370a1
4 changed files with 47 additions and 22 deletions

View file

@ -3,9 +3,27 @@ from django.utils.safestring import mark_safe
# Register your models here.
from .models.locale import Language, Continent, Country, SPR, City
from .models.profiles import UserProfile, Organization, Team, Member, Category, Topic
from .models.profiles import (
UserProfile,
Organization,
Team,
Member,
Category,
Topic,
Speaker,
Talk,
)
from .models.search import Searchable
from .models.events import Place, Event, EventComment, EventSeries, EventPhoto, CommonEvent, Attendee
from .models.events import (
Place,
Event,
EventComment,
EventSeries,
EventPhoto,
CommonEvent,
Attendee,
Presentation,
)
admin.site.register(Language)
admin.site.register(Continent)
@ -115,3 +133,7 @@ class TopicAdmin(admin.ModelAdmin):
exclude = ('slug', )
admin.site.register(Topic, TopicAdmin)
admin.site.register(Speaker)
admin.site.register(Talk)
admin.site.register(Presentation)

View file

@ -381,7 +381,10 @@ class SpeakerRequest(models.Model):
topics = models.ManyToManyField('Topic', blank=True)
class Presentation(models.Model):
event = models.ForeignKey(Event, on_delete=models.CASCADE)
talk = models.ForeignKey(Talk, on_delete=models.SET_NULL, blank=False, null=True)
event = models.ForeignKey(Event, related_name='presentations', on_delete=models.CASCADE)
talk = models.ForeignKey(Talk, related_name='presentations', on_delete=models.SET_NULL, blank=False, null=True)
start_time = models.DateTimeField(verbose_name=_('Start Time'), db_index=True)
def __str__(self):
return '%s at %s' % (self.talk.title, self.event.name)

View file

@ -309,6 +309,9 @@ class Speaker(models.Model):
categories = models.ManyToManyField('Category', blank=True)
topics = models.ManyToManyField('Topic', blank=True)
def __str__(self):
return self.user.__str__()
class Talk(models.Model):
PRESENTATION=0
WORKSHOP=1
@ -333,4 +336,6 @@ class Talk(models.Model):
category = models.ForeignKey('Category', on_delete=models.SET_NULL, blank=False, null=True)
topics = models.ManyToManyField('Topic', blank=True)
def __str__(self):
return self.title

View file

@ -7,8 +7,17 @@ from django.shortcuts import render, redirect, reverse, get_object_or_404
from django.http import HttpResponse, JsonResponse
from django.utils import timezone
from events.models.events import Event, CommonEvent, EventSeries, EventPhoto, Place, Attendee, update_event_searchable, \
delete_event_searchable
from events.models.events import (
Event,
CommonEvent,
EventSeries,
EventPhoto,
Place,
Attendee,
Presentation,
update_event_searchable,
delete_event_searchable,
)
from events.models.profiles import Team, Organization, UserProfile, Member
from events.forms import (
TeamEventForm,
@ -20,7 +29,7 @@ from events.forms import (
NewPlaceForm,
UploadEventPhotoForm,
NewCommonEventForm
)
)
from events import location
import datetime
@ -56,6 +65,7 @@ def show_event(request, event_id, event_slug):
'comment_form': comment_form,
'is_attending': request.user.profile in event.attendees.all(),
'attendee_list': Attendee.objects.filter(event=event),
'presentation_list': event.presentations.all().order_by('start_time'),
'can_edit_event': request.user.profile.can_edit_event(event),
}
return render(request, 'get_together/events/show_event.html', context)
@ -220,13 +230,6 @@ def add_place_to_series(request, series_id):
else:
return redirect('home')
def share_event(request, event_id):
event = get_object_or_404(Event, id=event_id)
context = {
'event': event,
}
return render(request, 'get_together/events/share_event.html', context)
def edit_event(request, event_id):
event = get_object_or_404(Event, id=event_id)
@ -391,14 +394,6 @@ def create_common_event(request, org_slug):
else:
return redirect('home')
def share_common_event(request, event_id):
event = get_object_or_404(CommonEvent, id=event_id)
context = {
'event': event,
}
return render(request, 'get_together/orgs/share_common_event.html', context)
@login_required
def create_common_event_team_select(request, event_id):
teams = request.user.profile.moderating
if len(teams) == 1: