Add "redirect homepage" for base event urls
authorMagnus Hagander <magnus@hagander.net>
Wed, 27 Dec 2017 14:01:25 +0000 (15:01 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 27 Dec 2017 14:01:25 +0000 (15:01 +0100)
With the new rename, there is now the concept of a root url for a
conference, being /events/<conferenename>/. If the user goes there, is
logged in and has a registration, then redirect to the registration
dashboard which has all the info for the user. In all other cases,
redirect to the conference homepage URL.

postgresqleu/confreg/views.py
postgresqleu/urls.py

index 75ccd028e8f5af7202f0d39f21ac04036db94e84..1dc82f4ca9742aace3d086b358737f54b0689b81 100644 (file)
@@ -189,6 +189,17 @@ def _registration_dashboard(request, conference, reg):
                'invoices': invoices,
        })
 
+def confhome(request, confname):
+       conference = get_object_or_404(Conference, urlname=confname)
+
+       # If there is a registration, redirect to the registration dashboard.
+       # If not, or if the user is not logged in, redirect to the conference homepage.
+       if request.user.is_authenticated():
+               if ConferenceRegistration.objects.filter(conference=conference, attendee=request.user).exists():
+                       return HttpResponseRedirect('register/')
+
+       return HttpResponseRedirect(conference.confurl)
+
 @login_required
 @transaction.atomic
 def home(request, confname):
index cfde316e68bb614131ec6a2085bede573302d007..0b39d7a082845e16c2fea084b2a09c13da40dc14 100644 (file)
@@ -122,6 +122,9 @@ urlpatterns = patterns('',
 
     (r'^events/sponsor/', include('postgresqleu.confsponsor.urls')),
 
+    # "Homepage" for events
+    (r'^events/([^/]+)/$', postgresqleu.confreg.views.confhome),
+
     # Mobile conference stuff
     (r'^m/(\w+)/$', postgresqleu.confreg.mobileviews.index),
     (r'^m/(\w+)/cache.manifest/$', postgresqleu.confreg.mobileviews.cachemanifest),