summaryrefslogtreecommitdiff
path: root/packages/views
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-08 15:02:28 -0600
committerDan McGee <dan@archlinux.org>2011-12-08 15:02:28 -0600
commit5006da56476ebd3614cab68c574ab893e82d5aaf (patch)
treef240bb83230741579f8cf46f2e2bfd02c7b410d0 /packages/views
parent3e094a548f409e4a87454764f6baf814464d9619 (diff)
Store flag requests in the database
This makes them persistent rather than the transient beings they currently are. We attempt to capture all the metadata we need to be able to do things with this later- aka IP address (for spam checking later), fields that allow us to mark the request as spam or not an actual out-of-date report, etc. As a bonus, logged-in developers now get the email address field filled in for free. Yay. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views')
-rw-r--r--packages/views/flag.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/packages/views/flag.py b/packages/views/flag.py
index 7e9d87c7..4132f9a7 100644
--- a/packages/views/flag.py
+++ b/packages/views/flag.py
@@ -9,6 +9,7 @@ from django.template import loader, Context
from django.views.generic.simple import direct_to_template
from django.views.decorators.cache import never_cache
+from ..models import FlagRequest
from main.models import Package
@@ -17,7 +18,7 @@ def flaghelp(request):
class FlagForm(forms.Form):
email = forms.EmailField(label='* E-mail Address')
- usermessage = forms.CharField(label='Message To Dev',
+ message = forms.CharField(label='Message To Dev',
widget=forms.Textarea, required=False)
# The field below is used to filter out bots that blindly fill out all
# input elements
@@ -47,6 +48,16 @@ def flag(request, name, repo, arch):
flagged_pkgs = list(pkgs)
pkgs.update(flag_date=datetime.utcnow())
+ # store our flag request
+ flag_request = FlagRequest(user_email=form.cleaned_data['email'],
+ ip_address=request.META.get('REMOTE_ADDR', '127.0.0.1'),
+ pkgbase=pkg.pkgbase, repo=pkg.repo,
+ num_packages=len(flagged_pkgs),
+ message=form.cleaned_data['message'])
+ if request.user.is_authenticated():
+ flag_request.user = request.user
+ flag_request.save()
+
maints = pkg.maintainers
if not maints:
toemail = settings.NOTIFICATIONS
@@ -65,7 +76,7 @@ def flag(request, name, repo, arch):
tmpl = loader.get_template('packages/outofdate.txt')
ctx = Context({
'email': form.cleaned_data['email'],
- 'message': form.cleaned_data['usermessage'],
+ 'message': form.cleaned_data['message'],
'pkg': pkg,
'packages': flagged_pkgs,
})
@@ -78,7 +89,10 @@ def flag(request, name, repo, arch):
return redirect('package-flag-confirmed', name=name, repo=repo,
arch=arch)
else:
- form = FlagForm()
+ initial = {}
+ if request.user.is_authenticated():
+ initial['email'] = request.user.email
+ form = FlagForm(initial=initial)
context = {
'package': pkg,