diff --git a/events/admin.py b/events/admin.py index 0d615a5..01da08d 100644 --- a/events/admin.py +++ b/events/admin.py @@ -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) + diff --git a/events/models/events.py b/events/models/events.py index ea27091..335ff77 100644 --- a/events/models/events.py +++ b/events/models/events.py @@ -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) + diff --git a/events/models/profiles.py b/events/models/profiles.py index 8dc018f..e595701 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -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 diff --git a/get_together/views/events.py b/get_together/views/events.py index 3a1ec5d..26c5da5 100644 --- a/get_together/views/events.py +++ b/get_together/views/events.py @@ -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: