Commit 7a36ad35 authored by Stefan Marsiske's avatar Stefan Marsiske
Browse files

Merge pull request #63 from ssaboum/cleanup_url_violations

Cleanup for urls and added Logo pics for Operators
parents 5f64b380 7d8e7565
# ignore python compiled files
*.pyc
# ignore mac files
.DS_Store
# ignore setup.py build dirs
build/
nnmon.egg-info/
# ignore sqlite db
*.db
*.pyc
......@@ -7,7 +7,7 @@ class CommentInline(admin.TabularInline):
class ViolationAdmin(admin.ModelAdmin):
list_display = ('state', 'country', 'operator', 'contract', 'resource_name', 'media', 'activationid')
list_filter = ('state', 'operator', 'contract', 'resource_name', 'media', 'country')
list_filter = ('state', 'operator_ref', 'contract', 'resource_name', 'media', 'country')
inlines = [CommentInline, ]
admin.site.register(models.Violation, ViolationAdmin)
......@@ -22,9 +22,15 @@ admin.site.register(models.Attachment, AttachmentAdmin)
class ConfirmationAdmin(admin.ModelAdmin):
list_display = ('violation', 'key')
list_filter = ('violation__operator', 'violation__contract', 'violation__resource_name', 'violation__media', 'violation__country')
list_filter = ('violation__operator_ref', 'violation__contract', 'violation__resource_name', 'violation__media', 'violation__country')
admin.site.register(models.Confirmation, ConfirmationAdmin)
class FeaturedCaseAdmin(admin.ModelAdmin):
pass
admin.site.register(models.FeaturedCase, FeaturedCaseAdmin)
class OperatorAdmin(admin.ModelAdmin):
list_display = ("__unicode__", "reported_violations")
search_fields = ('name', )
pass
admin.site.register(models.Operator, OperatorAdmin)
\ No newline at end of file
#from django.contrib.auth.models import User
from tastypie import fields
from tastypie.authorization import DjangoAuthorization
from tastypie.resources import ModelResource, ALL#, ALL_WITH_RELATIONS
from bt.models import Violation
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
from bt.models import Violation, Operator
#class UserResource(ModelResource):
......@@ -11,8 +11,21 @@ from bt.models import Violation
# resource_name = 'auth/user'
# excludes = ['email', 'password', 'is_superuser']
class OperatorResource(ModelResource):
class Meta:
queryset = Operator.objects.all()
list_allowed_methods = ['get', 'post']
detail_allowed_methods = ['get', 'post', 'put', 'delete']
resource_name = 'operators'
authorization = DjangoAuthorization()
filtering = {
'name': ALL,
}
class APIResource(ModelResource):
operator = fields.ForeignKey(OperatorResource, 'operator_ref')
# user = fields.ForeignKey(UserResource, 'user')
class Meta:
......@@ -23,7 +36,6 @@ class APIResource(ModelResource):
authorization = DjangoAuthorization()
filtering = {
'country': ALL,
'operator': ALL,
'operator_ref': ALL_WITH_RELATIONS,
'activationid': ALL,
}
......@@ -12,7 +12,7 @@ class RssSiteNewsFeed(Feed):
return Violation.objects.filter(activationid='').order_by('-id')[:10]
def item_link(self, item):
return "/view/%s" % item.pk
return item.get_absolute_url()
def item_title(self, item):
return "%s (%s) %s" % (item.operator, item.country, item.contract)
......
# -*- 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 'Violation'
db.create_table('bt_violation', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('country', self.gf('django.db.models.fields.CharField')(max_length=2)),
('operator', self.gf('django.db.models.fields.CharField')(max_length=256)),
('contract', self.gf('django.db.models.fields.CharField')(max_length=256, blank=True)),
('resource', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
('resource_name', self.gf('django.db.models.fields.CharField')(max_length=4096, blank=True)),
('type', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
('media', self.gf('django.db.models.fields.CharField')(max_length=20, blank=True)),
('temporary', self.gf('django.db.models.fields.BooleanField')(default=False)),
('contractual', self.gf('django.db.models.fields.BooleanField')(default=False)),
('contract_excerpt', self.gf('django.db.models.fields.TextField')(blank=True)),
('loophole', self.gf('django.db.models.fields.BooleanField')(default=False)),
('activationid', self.gf('django.db.models.fields.CharField')(max_length=128, blank=True)),
('state', self.gf('django.db.models.fields.CharField')(default='new', max_length=20, blank=True)),
('editorial', self.gf('django.db.models.fields.TextField')(blank=True)),
))
db.send_create_signal('bt', ['Violation'])
# Adding model 'Comment'
db.create_table('bt_comment', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('submitter_email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
('submitter_name', self.gf('django.db.models.fields.CharField')(max_length=20)),
('consent', self.gf('django.db.models.fields.BooleanField')(default=False)),
('comment', self.gf('django.db.models.fields.TextField')()),
('timestamp', self.gf('django.db.models.fields.DateTimeField')()),
('violation', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['bt.Violation'])),
))
db.send_create_signal('bt', ['Comment'])
# Adding model 'Attachment'
db.create_table('bt_attachment', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('storage', self.gf('django.db.models.fields.files.FileField')(max_length=100)),
('name', self.gf('django.db.models.fields.CharField')(max_length=512)),
('type', self.gf('django.db.models.fields.CharField')(max_length=512)),
('comment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['bt.Comment'])),
))
db.send_create_signal('bt', ['Attachment'])
# Adding model 'Confirmation'
db.create_table('bt_confirmation', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('key', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
('email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
('violation', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['bt.Violation'])),
))
db.send_create_signal('bt', ['Confirmation'])
# Adding model 'FeaturedCase'
db.create_table('bt_featuredcase', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('case', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['bt.Violation'], unique=True)),
))
db.send_create_signal('bt', ['FeaturedCase'])
def backwards(self, orm):
# Deleting model 'Violation'
db.delete_table('bt_violation')
# Deleting model 'Comment'
db.delete_table('bt_comment')
# Deleting model 'Attachment'
db.delete_table('bt_attachment')
# Deleting model 'Confirmation'
db.delete_table('bt_confirmation')
# Deleting model 'FeaturedCase'
db.delete_table('bt_featuredcase')
models = {
'bt.attachment': {
'Meta': {'object_name': 'Attachment'},
'comment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Comment']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
'storage': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '512'})
},
'bt.comment': {
'Meta': {'object_name': 'Comment'},
'comment': ('django.db.models.fields.TextField', [], {}),
'consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'submitter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'submitter_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.confirmation': {
'Meta': {'object_name': 'Confirmation'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.featuredcase': {
'Meta': {'object_name': 'FeaturedCase'},
'case': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['bt.Violation']", 'unique': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'bt.violation': {
'Meta': {'object_name': 'Violation'},
'activationid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
'contract': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
'contract_excerpt': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'contractual': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
'editorial': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'loophole': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'media': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'operator': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'resource': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'resource_name': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'blank': 'True'}),
'state': ('django.db.models.fields.CharField', [], {'default': "'new'", 'max_length': '20', 'blank': 'True'}),
'temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
}
}
complete_apps = ['bt']
\ No newline at end of file
# -*- 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 'Operator'
db.create_table('bt_operator', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=256)),
('logo', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)),
))
db.send_create_signal('bt', ['Operator'])
# Adding field 'Violation.operator_ref'
db.add_column('bt_violation', 'operator_ref',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='violations', null=True, to=orm['bt.Operator']),
keep_default=False)
def backwards(self, orm):
# Deleting model 'Operator'
db.delete_table('bt_operator')
# Deleting field 'Violation.operator_ref'
db.delete_column('bt_violation', 'operator_ref_id')
models = {
'bt.attachment': {
'Meta': {'object_name': 'Attachment'},
'comment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Comment']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
'storage': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '512'})
},
'bt.comment': {
'Meta': {'object_name': 'Comment'},
'comment': ('django.db.models.fields.TextField', [], {}),
'consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'submitter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'submitter_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.confirmation': {
'Meta': {'object_name': 'Confirmation'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.featuredcase': {
'Meta': {'object_name': 'FeaturedCase'},
'case': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['bt.Violation']", 'unique': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'bt.operator': {
'Meta': {'object_name': 'Operator'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'})
},
'bt.violation': {
'Meta': {'object_name': 'Violation'},
'activationid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
'contract': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
'contract_excerpt': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'contractual': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
'editorial': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'loophole': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'media': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'operator': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'operator_ref': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'violations'", 'null': 'True', 'to': "orm['bt.Operator']"}),
'resource': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'resource_name': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'blank': 'True'}),
'state': ('django.db.models.fields.CharField', [], {'default': "'new'", 'max_length': '20', 'blank': 'True'}),
'temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
}
}
complete_apps = ['bt']
\ No newline at end of file
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
"Populate new operator foreign key field"
for violation in orm['bt.Violation'].objects.all():
operator, created = orm['bt.Operator'].objects.get_or_create(name=violation.operator)
violation.operator_ref = operator
violation.save()
def backwards(self, orm):
"No need for backward pass"
pass
models = {
'bt.attachment': {
'Meta': {'object_name': 'Attachment'},
'comment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Comment']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
'storage': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '512'})
},
'bt.comment': {
'Meta': {'object_name': 'Comment'},
'comment': ('django.db.models.fields.TextField', [], {}),
'consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'submitter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'submitter_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.confirmation': {
'Meta': {'object_name': 'Confirmation'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.featuredcase': {
'Meta': {'object_name': 'FeaturedCase'},
'case': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['bt.Violation']", 'unique': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'bt.operator': {
'Meta': {'object_name': 'Operator'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'})
},
'bt.violation': {
'Meta': {'object_name': 'Violation'},
'activationid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
'contract': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
'contract_excerpt': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'contractual': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
'editorial': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'loophole': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'media': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'operator': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'operator_ref': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'violations'", 'null': 'True', 'to': "orm['bt.Operator']"}),
'resource': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'resource_name': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'blank': 'True'}),
'state': ('django.db.models.fields.CharField', [], {'default': "'new'", 'max_length': '20', 'blank': 'True'}),
'temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
}
}
complete_apps = ['bt']
symmetrical = True
# -*- 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):
# Deleting field 'Violation.operator'
db.delete_column('bt_violation', 'operator')
# Changing field 'Violation.operator_ref'
db.alter_column('bt_violation', 'operator_ref_id', self.gf('django.db.models.fields.related.ForeignKey')(default=0, to=orm['bt.Operator']))
def backwards(self, orm):
# Adding field 'Violation.operator'
db.add_column('bt_violation', 'operator',
self.gf('django.db.models.fields.CharField')(default=0, max_length=256),
keep_default=False)
# Changing field 'Violation.operator_ref'
db.alter_column('bt_violation', 'operator_ref_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['bt.Operator']))
models = {
'bt.attachment': {
'Meta': {'object_name': 'Attachment'},
'comment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Comment']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
'storage': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '512'})
},
'bt.comment': {
'Meta': {'object_name': 'Comment'},
'comment': ('django.db.models.fields.TextField', [], {}),
'consent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'submitter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'submitter_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.confirmation': {
'Meta': {'object_name': 'Confirmation'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
'violation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['bt.Violation']"})
},
'bt.featuredcase': {
'Meta': {'object_name': 'FeaturedCase'},
'case': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['bt.Violation']", 'unique': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'bt.operator': {
'Meta': {'object_name': 'Operator'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'})
},
'bt.violation': {
'Meta': {'object_name': 'Violation'},
'activationid': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
'contract': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
'contract_excerpt': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'contractual': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
'editorial': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'loophole': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'media': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'operator_ref': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'violations'", 'to': "orm['bt.Operator']"}),
'resource': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'resource_name': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'blank': 'True'}),
'state': ('django.db.models.fields.CharField', [], {'default': "'new'", 'max_length': '20', 'blank': 'True'}),
'temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'})
}
}
complete_apps = ['bt']
\ No newline at end of file
......@@ -59,9 +59,24 @@ STATUS = (
('closed', _('Closed')),
)
class Operator(models.Model):
"""
Define the concept of an internet provider/network operator
"""
name = models.CharField(max_length=256)
logo = models.ImageField(upload_to='operator_logo', null=True, blank=True)
def reported_violations(self):
return self.violations.count()
reported_violations.short_description = 'Reported Violations'
def __unicode__(self):
return self.name
class Violation(models.Model):
country = models.CharField(max_length=2, choices=COUNTRIES)
operator = models.CharField(max_length=256)
operator_ref = models.ForeignKey(Operator, related_name="violations")
contract = models.CharField(max_length=256, blank=True)
resource = models.CharField(max_length=20, choices=RESOURCES, blank=True)
resource_name = models.CharField(max_length=4096, blank=True)
......@@ -81,6 +96,15 @@ class Violation(models.Model):
class Admin:
pass
@property
def operator(self):
return self.operator_ref.name
@models.permalink
def get_absolute_url(self):
return ('violation_url', (),
{'id': self.pk })
def __unicode__(self):
return "#%s %s/%s" % (self.pk, self.country, self.operator)
......
from forms import AddViolation, SearchViolation
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext, loader, Context
from django.core.files import File
from django.core.servers.basehttp import FileWrapper
......@@ -80,9 +80,9 @@ def moderate(request):
messages.add_message(request, messages.INFO, _('No such key'))
return HttpResponseRedirect('/') # Redirect after POST
if request.GET.get('action','')=='approve':
messages.add_message(request, messages.INFO, _('Thank you for approving the <a href="/view/%s">submission</a>.' % v.id))
messages.add_message(request, messages.INFO, _('Thank you for approving the <a href="%s">submission</a>.' % v.get_absolute_url))
msg = MIMEText(_("Your report has been approved.\nTo see it, please visit: %s/view/%s") % (settings.ROOT_URL or 'http://localhost:8001/', v.id), _charset="utf-8")
msg = MIMEText(_("Your report has been approved.\nTo see it, please visit: %s%s") % (settings.ROOT_URL or 'http://localhost:8001/', v.get_absolute_url()), _charset="utf-8")
msg['Subject'] = Header(_('NNMon submission approved').encode("Utf-8"), 'utf-8')
msg['From'] = 'nnmon@respectmynet.eu'
msg['To'] = v.comment_set.get().submitter_email
......@@ -96,7 +96,7 @@ def moderate(request):
pass
v.activationid=''
v.save()
return HttpResponseRedirect('/view/%s' % v.id ) # Redirect after POST
return redirect(v) # Redirect after POST to violation url
if request.GET.get('action','')=='delete':
v.delete()
messages.add_message(request, messages.INFO, _('Thank you for deleting the submission.'))
......@@ -141,9 +141,10 @@ def add(request):
if form.is_valid():
msg=_("Thank you for submitting a new report. To finalize your submission please confirm using your validation key.\nYour verification key is %s/%s%s\nPlease note that reports are moderated, it might take some time before your report appears online. Thank you for your patience.")
actid=sendverifymail('activate?key=',form.cleaned_data['email'], msg)
operator, created = Operator.objects.get_or_create(name=form.cleaned_data['operator'])
v=Violation(
country = form.cleaned_data['country'],
operator = form.cleaned_data['operator'],
operator_ref = operator,
contract = form.cleaned_data['contract'],
resource = form.cleaned_data['resource'],
resource_name = form.cleaned_data['resource_name'],
......@@ -207,8 +208,8 @@ def index(request):
confirms=sorted([(i['total'],i['country'])