euscanwww: Adding a problem reporting form in package page
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
03cf3b90a4
commit
379a6d2942
@ -1,7 +1,7 @@
|
||||
from djeuscan.models import Package, Version, VersionLog, EuscanResult, \
|
||||
Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer, \
|
||||
RefreshPackageQuery, HerdAssociation, CategoryAssociation, \
|
||||
MaintainerAssociation, PackageAssociation
|
||||
MaintainerAssociation, PackageAssociation, ProblemReport
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@ -52,3 +52,4 @@ admin.site.register(HerdAssociation)
|
||||
admin.site.register(CategoryAssociation)
|
||||
admin.site.register(MaintainerAssociation)
|
||||
admin.site.register(PackageAssociation)
|
||||
admin.site.register(ProblemReport)
|
||||
|
@ -1,5 +1,7 @@
|
||||
from django import forms
|
||||
|
||||
from djeuscan.models import Package, Version, ProblemReport
|
||||
|
||||
|
||||
class WorldForm(forms.Form):
|
||||
world = forms.FileField()
|
||||
@ -7,3 +9,21 @@ class WorldForm(forms.Form):
|
||||
|
||||
class PackagesForm(forms.Form):
|
||||
packages = forms.CharField(widget=forms.Textarea)
|
||||
|
||||
|
||||
class ProblemReportForm(forms.ModelForm):
|
||||
version = forms.ModelChoiceField(queryset=Version.objects.all(),
|
||||
empty_label="all", required=False)
|
||||
message = forms.CharField(
|
||||
widget=forms.Textarea(attrs={'cols': 80, 'rows': 15})
|
||||
)
|
||||
|
||||
def __init__(self, package, *args, **kwargs):
|
||||
super(ProblemReportForm, self).__init__(*args, **kwargs)
|
||||
self.fields["version"].queryset = Version.objects.filter(
|
||||
package=package
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ProblemReport
|
||||
fields = ('version', 'subject', 'message')
|
||||
|
198
euscanwww/djeuscan/migrations/0008_auto__add_problemreport.py
Normal file
198
euscanwww/djeuscan/migrations/0008_auto__add_problemreport.py
Normal file
@ -0,0 +1,198 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'ProblemReport'
|
||||
db.create_table('djeuscan_problemreport', (
|
||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('package', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Package'])),
|
||||
('version', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Version'], null=True, blank=True)),
|
||||
('subject', self.gf('django.db.models.fields.CharField')(max_length=128)),
|
||||
('message', self.gf('django.db.models.fields.TextField')()),
|
||||
('datetime', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
|
||||
))
|
||||
db.send_create_signal('djeuscan', ['ProblemReport'])
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting model 'ProblemReport'
|
||||
db.delete_table('djeuscan_problemreport')
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'djeuscan.categoryassociation': {
|
||||
'Meta': {'unique_together': "(['user', 'category'],)", 'object_name': 'CategoryAssociation'},
|
||||
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||
},
|
||||
'djeuscan.categorylog': {
|
||||
'Meta': {'object_name': 'CategoryLog', '_ormbases': ['djeuscan.Log']},
|
||||
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||
},
|
||||
'djeuscan.euscanresult': {
|
||||
'Meta': {'object_name': 'EuscanResult'},
|
||||
'datetime': ('django.db.models.fields.DateTimeField', [], {}),
|
||||
'ebuild': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'result': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'scan_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
'djeuscan.herd': {
|
||||
'Meta': {'object_name': 'Herd'},
|
||||
'email': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
|
||||
'herd': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||
},
|
||||
'djeuscan.herdassociation': {
|
||||
'Meta': {'unique_together': "(['user', 'herd'],)", 'object_name': 'HerdAssociation'},
|
||||
'herd': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Herd']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||
},
|
||||
'djeuscan.herdlog': {
|
||||
'Meta': {'object_name': 'HerdLog', '_ormbases': ['djeuscan.Log']},
|
||||
'herd': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Herd']"}),
|
||||
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||
},
|
||||
'djeuscan.log': {
|
||||
'Meta': {'object_name': 'Log'},
|
||||
'datetime': ('django.db.models.fields.DateTimeField', [], {}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'n_packages_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_packages_outdated': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_packages_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_versions_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_versions_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_versions_upstream': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||
},
|
||||
'djeuscan.maintainer': {
|
||||
'Meta': {'object_name': 'Maintainer'},
|
||||
'email': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||
},
|
||||
'djeuscan.maintainerassociation': {
|
||||
'Meta': {'unique_together': "(['user', 'maintainer'],)", 'object_name': 'MaintainerAssociation'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'maintainer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Maintainer']"}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||
},
|
||||
'djeuscan.maintainerlog': {
|
||||
'Meta': {'object_name': 'MaintainerLog', '_ormbases': ['djeuscan.Log']},
|
||||
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'}),
|
||||
'maintainer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Maintainer']"})
|
||||
},
|
||||
'djeuscan.package': {
|
||||
'Meta': {'unique_together': "(['category', 'name'],)", 'object_name': 'Package'},
|
||||
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'herds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Herd']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'homepage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'last_version_gentoo': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_gentoo'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||
'last_version_overlay': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_overlay'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||
'last_version_upstream': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_upstream'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||
'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Maintainer']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'n_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_packaged': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'n_versions': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||
},
|
||||
'djeuscan.packageassociation': {
|
||||
'Meta': {'unique_together': "(['user', 'package'],)", 'object_name': 'PackageAssociation'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||
},
|
||||
'djeuscan.problemreport': {
|
||||
'Meta': {'object_name': 'ProblemReport'},
|
||||
'datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'message': ('django.db.models.fields.TextField', [], {}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'subject': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'version': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Version']", 'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
'djeuscan.refreshpackagequery': {
|
||||
'Meta': {'object_name': 'RefreshPackageQuery'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'priority': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||
},
|
||||
'djeuscan.version': {
|
||||
'Meta': {'unique_together': "(['package', 'slot', 'revision', 'version', 'overlay'],)", 'object_name': 'Version'},
|
||||
'alive': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
|
||||
'confidence': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'handler': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128', 'db_index': 'True', 'blank': 'True'}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'slot': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}),
|
||||
'urls': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'version': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'version_type': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'})
|
||||
},
|
||||
'djeuscan.versionlog': {
|
||||
'Meta': {'object_name': 'VersionLog'},
|
||||
'action': ('django.db.models.fields.IntegerField', [], {}),
|
||||
'datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128', 'blank': 'True'}),
|
||||
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||
'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'slot': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}),
|
||||
'version': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||
},
|
||||
'djeuscan.worldlog': {
|
||||
'Meta': {'object_name': 'WorldLog', '_ormbases': ['djeuscan.Log']},
|
||||
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['djeuscan']
|
@ -318,3 +318,14 @@ class CategoryAssociation(models.Model):
|
||||
|
||||
def __unicode__(self):
|
||||
return u'[%s] %s' % (self.user, self.category)
|
||||
|
||||
|
||||
class ProblemReport(models.Model):
|
||||
package = models.ForeignKey(Package)
|
||||
version = models.ForeignKey(Version, null=True, blank=True)
|
||||
subject = models.CharField(max_length=128)
|
||||
message = models.TextField()
|
||||
datetime = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] %s" % (self.datetime, self.package)
|
||||
|
@ -24,6 +24,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if thanks_for_reporting %}
|
||||
<div class="alert alert-success">
|
||||
<strong>Thanks!</strong> Your report has been sent to admins
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h2>
|
||||
{{ package.category }}/{{ package.name }}
|
||||
|
||||
@ -144,6 +151,40 @@
|
||||
{% endif %}
|
||||
</dl>
|
||||
|
||||
<hr/>
|
||||
|
||||
<h3>Report problems</h3>
|
||||
|
||||
<form action="." method="post" class="form-horizontal">
|
||||
<div class="control-group {% if problem_form.version.errors %}error{% endif %}">
|
||||
<label class="control-label" for="version">{{ problem_form.version.label }}</label>
|
||||
<div class="controls">
|
||||
{{ problem_form.version }}
|
||||
<span class="help-inline">{{ problem_form.version.errors.as_text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group {% if problem_form.subject.errors %}error{% endif %}">
|
||||
<label class="control-label" for="subject">{{ problem_form.subject.label }}</label>
|
||||
<div class="controls">
|
||||
{{ problem_form.subject }}
|
||||
<span class="help-inline">{{ problem_form.subject.errors.as_text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group {% if problem_form.message.errors %}error{% endif %}">
|
||||
<label class="control-label" for="message">{{ problem_form.message.label }}</label>
|
||||
<div class="controls">
|
||||
{{ problem_form.message }}
|
||||
<span class="help-inline">{{ problem_form.message.errors.as_text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input class="btn" type="submit" value="Submit" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(".refresh-button").click(function() {
|
||||
var url = "{% url "refresh_package" "XXX" "YYY" %}";
|
||||
|
@ -11,8 +11,8 @@ from django.views.decorators.http import require_POST
|
||||
from djeuscan.helpers import version_key, packages_from_names
|
||||
from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \
|
||||
VersionLog, RefreshPackageQuery, HerdAssociation, MaintainerAssociation, \
|
||||
CategoryAssociation, PackageAssociation
|
||||
from djeuscan.forms import WorldForm, PackagesForm
|
||||
CategoryAssociation, PackageAssociation, ProblemReport
|
||||
from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm
|
||||
from djeuscan.tasks import admin_tasks
|
||||
from djeuscan import charts
|
||||
|
||||
@ -176,6 +176,20 @@ def package(request, category, package):
|
||||
else:
|
||||
favourited = True
|
||||
|
||||
thanks_for_reporting = False
|
||||
if request.method == "POST":
|
||||
problem_form = ProblemReportForm(package, request.POST)
|
||||
if problem_form.is_valid():
|
||||
ProblemReport(
|
||||
package=package,
|
||||
version=problem_form.cleaned_data["version"],
|
||||
subject=problem_form.cleaned_data["subject"],
|
||||
message=problem_form.cleaned_data["message"],
|
||||
).save()
|
||||
thanks_for_reporting = True
|
||||
else:
|
||||
problem_form = ProblemReportForm(package)
|
||||
|
||||
return {
|
||||
'package': package,
|
||||
'packaged': packaged,
|
||||
@ -184,6 +198,8 @@ def package(request, category, package):
|
||||
'vlog': vlog,
|
||||
'last_scan': last_scan,
|
||||
'favourited': favourited,
|
||||
'problem_form': problem_form,
|
||||
'thanks_for_reporting': thanks_for_reporting
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,3 +233,7 @@ th {
|
||||
-moz-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: inherit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user