2011-09-04 04:21:51 +00:00
|
|
|
from django.template import RequestContext
|
2011-09-12 05:53:54 +00:00
|
|
|
from django.contrib.auth.models import User
|
2011-09-27 09:27:15 +00:00
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
from django.http import HttpResponseRedirect
|
2011-09-29 01:36:47 +00:00
|
|
|
from django.shortcuts import render, render_to_response, get_object_or_404
|
2011-09-27 09:27:15 +00:00
|
|
|
|
2011-09-29 01:54:50 +00:00
|
|
|
from regluit.core import models, search
|
2011-09-12 03:44:21 +00:00
|
|
|
|
2011-08-31 03:46:55 +00:00
|
|
|
def home(request):
|
2011-09-27 09:27:15 +00:00
|
|
|
if request.user.is_authenticated():
|
|
|
|
return HttpResponseRedirect(reverse('supporter',
|
|
|
|
args=[request.user.username]))
|
2011-09-29 01:54:50 +00:00
|
|
|
return render(request, 'home.html')
|
2011-09-12 03:44:21 +00:00
|
|
|
|
2011-09-12 18:20:36 +00:00
|
|
|
def supporter(request, supporter_username):
|
|
|
|
supporter = get_object_or_404(User, username=supporter_username)
|
2011-09-21 15:11:36 +00:00
|
|
|
campaigns = models.Campaign.objects.all()
|
2011-09-29 01:54:50 +00:00
|
|
|
context = {
|
|
|
|
"supporter": supporter,
|
|
|
|
"campaigns": campaigns,
|
|
|
|
}
|
|
|
|
return render(request, 'supporter.html', context)
|
2011-09-29 01:36:47 +00:00
|
|
|
|
|
|
|
def search(request):
|
2011-09-29 01:54:50 +00:00
|
|
|
q = request.GET.get('q', None)
|
|
|
|
results = search.gluejar_search(q)
|
|
|
|
context = {
|
|
|
|
"q": q,
|
|
|
|
"results": results,
|
|
|
|
}
|
|
|
|
return render(request, 'search.html', context)
|