mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
Create and track a mapping between bug ids and messageids
Not used yet (though a prototype redirect view is present) since we need to populate it with data from the past, but with this we start collecting the mapping for future bugs.
This commit is contained in:
23
pgweb/misc/migrations/0001_bugidmap.py
Normal file
23
pgweb/misc/migrations/0001_bugidmap.py
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.10 on 2019-01-17 08:41
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='BugIdMap',
|
||||
fields=[
|
||||
('id', models.IntegerField(primary_key=True, serialize=False)),
|
||||
('messageid', models.CharField(max_length=500)),
|
||||
],
|
||||
),
|
||||
]
|
0
pgweb/misc/migrations/__init__.py
Normal file
0
pgweb/misc/migrations/__init__.py
Normal file
@ -1,3 +1,7 @@
|
||||
#from django.db import models
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class BugIdMap(models.Model):
|
||||
# Explicit id field because we don't want a SERIAL here, since we generate
|
||||
# the actual bug IDs externally.
|
||||
id = models.IntegerField(null=False, blank=False, primary_key=True)
|
||||
messageid = models.CharField(max_length=500, null=False, blank=False)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from pgweb.util.decorators import login_required
|
||||
from django.http import HttpResponse
|
||||
from django.db import connection
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.db import connection, transaction
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.conf import settings
|
||||
|
||||
import os
|
||||
@ -12,6 +13,7 @@ from pgweb.util.helpers import template_to_string
|
||||
from pgweb.util.misc import send_template_mail
|
||||
|
||||
from pgweb.core.models import Version
|
||||
from pgweb.misc.models import BugIdMap
|
||||
|
||||
from forms import SubmitBugForm
|
||||
|
||||
@ -26,10 +28,15 @@ def submitbug(request):
|
||||
if request.method == 'POST':
|
||||
form = SubmitBugForm(request.POST)
|
||||
if form.is_valid():
|
||||
with transaction.atomic():
|
||||
c = connection.cursor()
|
||||
c.execute("SELECT nextval('bug_id_seq')")
|
||||
bugid = c.fetchall()[0][0]
|
||||
|
||||
messageid = _make_bugs_messageid(bugid)
|
||||
|
||||
BugIdMap(id=bugid, messageid=messageid.strip('<>')).save()
|
||||
|
||||
send_template_mail(
|
||||
settings.BUGREPORT_NOREPLY_EMAIL,
|
||||
settings.BUGREPORT_EMAIL,
|
||||
@ -43,7 +50,7 @@ def submitbug(request):
|
||||
cc=form.cleaned_data['email'],
|
||||
replyto='%s, %s' % (form.cleaned_data['email'], settings.BUGREPORT_EMAIL),
|
||||
sendername="PG Bug reporting form",
|
||||
messageid=_make_bugs_messageid(bugid),
|
||||
messageid=messageid,
|
||||
)
|
||||
|
||||
return render_pgweb(request, 'support', 'misc/bug_completed.html', {
|
||||
@ -69,6 +76,11 @@ def submitbug(request):
|
||||
})
|
||||
|
||||
|
||||
def bugs_redir(request, bugid):
|
||||
r = get_object_or_404(BugIdMap, id=bugid)
|
||||
|
||||
return HttpResponseRedirect("{0}/message-id/{1}".format(settings.SITE_ROOT, r.messageid))
|
||||
|
||||
# A crash testing URL. If the file /tmp/crashtest exists, raise a http 500
|
||||
# error. Otherwise, just return a fixed text response
|
||||
def crashtest(request):
|
||||
|
@ -83,6 +83,7 @@ urlpatterns = [
|
||||
url(r'^account/submitbug/$', pgweb.misc.views.submitbug),
|
||||
url(r'^support/submitbug/$', RedirectView.as_view(url='/account/submitbug/', permanent=True)),
|
||||
url(r'^support/versioning/$', pgweb.core.views.versions),
|
||||
url(r'^bugs_redir/(\d+)/$', pgweb.misc.views.bugs_redir),
|
||||
|
||||
url(r'^about/sponsors/$', pgweb.sponsors.views.sponsors),
|
||||
url(r'^about/servers/$', pgweb.sponsors.views.servers),
|
||||
|
Reference in New Issue
Block a user