Skip to content

Commit ee03791

Browse files
author
Kishore kumar J
committed
Added Event participation link to site
1 parent f65544a commit ee03791

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

participantsprofile/views.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.shortcuts import render_to_response
2-
from django.http import HttpResponseRedirect
2+
from django.http import HttpResponseRedirect, HttpResponse
33
from django.template import RequestContext
44
from django.contrib.auth.decorators import login_required
55

@@ -8,15 +8,21 @@
88
@login_required
99
def participant_events(request):
1010
if request.method == 'POST':
11-
participant = request.user.get_profile().participant_set.all()[0]
11+
try:
12+
participant = request.user.get_profile().participant_set.all()[0]
13+
except Exception:
14+
return HttpResponse('This page is not for you!<br><a href="/">Take me back Home</a>')
1215
form = ParticipantEventsForm(request.POST)
1316
participant.events = form.data.getlist('events')
1417
for e in form.data.getlist('events'):
1518
if e not in [e.id for e in participant.events.all()]:
1619
participant.events.add(e)
1720
return HttpResponseRedirect('/')
1821
else:
19-
participant = request.user.get_profile().participant_set.all()[0]
22+
try:
23+
participant = request.user.get_profile().participant_set.all()[0]
24+
except Exception:
25+
return HttpResponse('This page is not for you!<br><a href="/">Take me back Home</a>')
2026
events = [ e.id for e in participant.events.all()]
2127
form = ParticipantEventsForm(data = {'events':events})
2228
return render_to_response('participantsprofile/participant_events.html', {'form':form}, context_instance=RequestContext(request), mimetype='text/html')

static/css/base.css

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ a:visited:hover {
2828
}
2929
.user_info {
3030
float: right;
31+
text-align: right;
3132
}
3233
.menu {
3334
margin-top: 0px;

templates/richbase.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
<body>
3434
<div class="user_info">
3535
{% if request.user.is_authenticated %}
36-
Hello {{ request.user }}, <a href="{% url user_signout %}?next=/">Sign out</a>
36+
Hello {{ request.user }}, <a href="{% url user_signout %}?next=/">Sign out</a><br/>
37+
<a href="{% url participant_events %}">Update Event Participation</a>
3738
{% else %}
3839
<a href="{% url user_signin %}?next={{request.get_full_path}}">Log In</a> | <a href="{% url registration_register %}?next={{request.get_full_path}}">Register</a>
3940
{% endif %}

0 commit comments

Comments
 (0)