New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rama mapeveri #68
Rama mapeveri #68
Changes from 4 commits
7409af3
d7238d7
aa34ec3
acc6eaa
d39bf0a
359b1c1
4ecfc8d
5ad5ead
ce099d0
d646565
9752d0b
72f0ece
466e9cf
40e0532
95d75f9
f540aac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
from django.views.generic import TemplateView | ||
|
||
from events.forms import RegistrationForm | ||
from events.models import Event, Registration | ||
from events.models import Event, Registration, Category, CategoryEvent | ||
from events.utils import newMail, pendingMail | ||
|
||
|
||
|
@@ -25,21 +25,27 @@ def index(request): | |
oldEvents = Event.objects.filter( | ||
active=True, eventDate__lt=now).order_by('-eventDate') | ||
|
||
categories = Category.objects.all() | ||
|
||
data = { | ||
'nextEvents': nextEvents, | ||
'oldEvents': oldEvents, | ||
'categories': categories, | ||
} | ||
|
||
return render_to_response( | ||
'index.html', data, context_instance=RequestContext(request)) | ||
|
||
|
||
def detail(request, id, slug): | ||
"""Event details page.""" | ||
event = get_object_or_404(Event, id=id, active=True) | ||
|
||
"""Get all the categories related to the event""" | ||
categories = CategoryEvent.objects.filter(event_id=id) | ||
|
||
data = { | ||
'event': event, | ||
'categories': categories, | ||
} | ||
|
||
return render_to_response( | ||
|
@@ -219,3 +225,20 @@ def stats(request): | |
|
||
return render_to_response( | ||
'stats/index.html', data, context_instance=RequestContext(request)) | ||
|
||
def events_category(request, id, slug): | ||
""" | ||
Filter evets for category | ||
""" | ||
events = CategoryEvent.objects.filter(category_id=id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use get_object_or_404 since we expect just one valid result There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here used try and catch why i need use filter model. Used get_object_or_404 for model category. |
||
|
||
ct = Category.objects.get(id=id) | ||
category = ct.name | ||
|
||
data = { | ||
'events': events, | ||
'category': category, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you pass just the category name? If you pass the category object then in the template you can access all values easily category.name category.slug... |
||
} | ||
|
||
return render_to_response( | ||
'events/events_categories.html', data, context_instance=RequestContext(request)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a slug here would be useful for urls. See comments below.