# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from patchwork.models import Patch, Project, Person
-from patchwork.filters import Filters
-from patchwork.forms import LoginForm, PatchForm
+from patchwork.models import Patch, Project, Person, EmailConfirmation
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect, Http404
-from django.db import transaction
-from django.contrib.auth.models import User
-from django.contrib.auth.decorators import login_required
-import django.core.urlresolvers
from patchwork.requestcontext import PatchworkRequestContext
-from django.core import serializers
+from django.core import serializers, urlresolvers
from django.template.loader import render_to_string
from django.conf import settings
if projects.count() == 1:
return HttpResponseRedirect(
- django.core.urlresolvers.reverse('patchwork.views.patch.list',
+ urlresolvers.reverse('patchwork.views.patch.list',
kwargs = {'project_id': projects[0].linkname}))
context['projects'] = projects
return render_to_response('patchwork/projects.html', context)
-def project(request, project_id):
- context = PatchworkRequestContext(request)
- project = get_object_or_404(Project, linkname = project_id)
- context.project = project
-
- context['maintainers'] = User.objects.filter( \
- userprofile__maintainer_projects = project)
- context['n_patches'] = Patch.objects.filter(project = project,
- archived = False).count()
- context['n_archived_patches'] = Patch.objects.filter(project = project,
- archived = True).count()
-
- return render_to_response('patchwork/project.html', context)
-
def pwclientrc(request, project_id):
project = get_object_or_404(Project, linkname = project_id)
context = PatchworkRequestContext(request)
context.project = project
+ if request.is_secure():
+ context['scheme'] = 'https'
+ else:
+ context['scheme'] = 'http'
response = HttpResponse(mimetype = "text/plain")
response['Content-Disposition'] = 'attachment; filename=.pwclientrc'
response.write(render_to_string('patchwork/pwclientrc', context))
def pwclient(request):
context = PatchworkRequestContext(request)
response = HttpResponse(mimetype = "text/x-python")
- response['Content-Disposition'] = 'attachment; filename=pwclient.py'
- response.write(render_to_string('patchwork/pwclient.py', context))
+ response['Content-Disposition'] = 'attachment; filename=pwclient'
+ response.write(render_to_string('patchwork/pwclient', context))
return response
+def confirm(request, key):
+ import patchwork.views.user, patchwork.views.mail
+ views = {
+ 'userperson': patchwork.views.user.link_confirm,
+ 'registration': patchwork.views.user.register_confirm,
+ 'optout': patchwork.views.mail.optout_confirm,
+ 'optin': patchwork.views.mail.optin_confirm,
+ }
+
+ conf = get_object_or_404(EmailConfirmation, key = key)
+ if conf.type not in views:
+ raise Http404
+
+ if conf.active and conf.is_valid():
+ return views[conf.type](request, conf)
+
+ context = PatchworkRequestContext(request)
+ context['conf'] = conf
+ if not conf.active:
+ context['error'] = 'inactive'
+ elif not conf.is_valid():
+ context['error'] = 'expired'
+
+ return render_to_response('patchwork/confirm-error.html', context)
+
def submitter_complete(request):
search = request.GET.get('q', '')
response = HttpResponse(mimetype = "text/plain")
def help(request, path):
context = PatchworkRequestContext(request)
- if help_pages.has_key(path):
+ if path in help_pages:
return render_to_response('patchwork/help/' + help_pages[path], context)
raise Http404