summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/views/flag.py34
-rw-r--r--templates/packages/flaghelp.html20
2 files changed, 33 insertions, 21 deletions
diff --git a/packages/views/flag.py b/packages/views/flag.py
index 0d2f9009..7fa2d508 100644
--- a/packages/views/flag.py
+++ b/packages/views/flag.py
@@ -6,16 +6,13 @@ from django.db import transaction
from django.shortcuts import get_object_or_404, redirect
from django.template import loader, Context
from django.views.generic.simple import direct_to_template
-from django.views.decorators.cache import never_cache
+from django.views.decorators.cache import cache_page, never_cache
from ..models import FlagRequest
from main.models import Package
from main.utils import utc_now
-def flaghelp(request):
- return direct_to_template(request, 'packages/flaghelp.html')
-
class FlagForm(forms.Form):
email = forms.EmailField(label='E-mail Address')
message = forms.CharField(label='Message To Developer',
@@ -26,6 +23,20 @@ class FlagForm(forms.Form):
widget=forms.TextInput(attrs={'style': 'display:none;'}),
required=False)
+ def __init__(self, *args, **kwargs):
+ # we remove the 'email' field if this form is being shown to a
+ # logged-in user, e.g., a developer.
+ auth = kwargs.pop('authenticated', False)
+ super(FlagForm, self).__init__(*args, **kwargs)
+ if auth:
+ del self.fields['email']
+
+
+@cache_page(3600)
+def flaghelp(request):
+ return direct_to_template(request, 'packages/flaghelp.html')
+
+
@never_cache
def flag(request, name, repo, arch):
pkg = get_object_or_404(Package,
@@ -41,8 +52,10 @@ def flag(request, name, repo, arch):
repo__staging=pkg.repo.staging).order_by(
'pkgname', 'repo__name', 'arch__name')
+ authenticated = request.user.is_authenticated()
+
if request.POST:
- form = FlagForm(request.POST)
+ form = FlagForm(request.POST, authenticated=authenticated)
if form.is_valid() and form.cleaned_data['website'] == '':
# save the package list for later use
flagged_pkgs = list(pkgs)
@@ -54,9 +67,12 @@ def flag(request, name, repo, arch):
else:
version = ''
- email = form.cleaned_data['email']
message = form.cleaned_data['message']
ip_addr = request.META.get('REMOTE_ADDR')
+ if authenticated:
+ email = request.user.email
+ else:
+ email = form.cleaned_data['email']
@transaction.commit_on_success
def perform_updates():
@@ -68,7 +84,7 @@ def flag(request, name, repo, arch):
ip_address=ip_addr, pkgbase=pkg.pkgbase,
version=version, repo=pkg.repo,
num_packages=len(flagged_pkgs))
- if request.user.is_authenticated():
+ if authenticated:
flag_request.user = request.user
flag_request.save()
@@ -106,9 +122,7 @@ def flag(request, name, repo, arch):
arch=arch)
else:
initial = {}
- if request.user.is_authenticated():
- initial['email'] = request.user.email
- form = FlagForm(initial=initial)
+ form = FlagForm(authenticated=authenticated)
context = {
'package': pkg,
diff --git a/templates/packages/flaghelp.html b/templates/packages/flaghelp.html
index 819a2f01..399b7e01 100644
--- a/templates/packages/flaghelp.html
+++ b/templates/packages/flaghelp.html
@@ -1,20 +1,19 @@
-<!DOCTYPE html>
+{% load static from staticfiles %}<!DOCTYPE html>
<html lang="en">
<head>
<title>Flagging Packages</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <style type="text/css" media="screen, projection">
- <!--
- body { background: #eef; color: #444; font-family: sans-serif; }
- a { color: #07b; text-decoration: none; }
- a:hover { text-decoration: underline; }
- -->
+ <link rel="icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
+ <link rel="shortcut icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
+ <style type="text/css" media="screen, projection">
+ body { background: #f6f9fc; color: #222; font-family: sans-serif; }
+ a:link { text-decoration: none; color: #07b; }
+ a:visited { color: #666; }
+ a:hover { text-decoration: underline; color: #666; }
</style>
</head>
<body>
-
<h3>Flagging Packages</h3>
-
<p>If you notice that a package is out-of-date (i.e., there is a newer
<strong>stable</strong> release available), then please notify us by
using the <strong>Flag</strong> button in the <em>Package Details</em>
@@ -29,8 +28,7 @@
with your additional text.</p>
<p><strong>Note:</strong> Please do <em>not</em> use this facility if the
- package is broken! Use the <a target="_blank" href="https://bugs.archlinux.org"
+ package is broken! Use the <a target="_blank" href="https://bugs.archlinux.org/"
title="Arch Linux Bugtracker">bugtracker</a> instead.</p>
-
</body>
</html>