Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
Respect My Net
Commits
7a36ad35
Commit
7a36ad35
authored
Oct 21, 2012
by
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
Changes
22
Show whitespace changes
Inline
Side-by-side
.gitignore
View file @
7a36ad35
# ignore python compiled files
*.pyc
# ignore mac files
.DS_Store
# ignore setup.py build dirs
build/
nnmon.egg-info/
# ignore sqlite db
*.db
*.db
*.pyc
*.pyc
bt/admin.py
View file @
7a36ad35
...
@@ -7,7 +7,7 @@ class CommentInline(admin.TabularInline):
...
@@ -7,7 +7,7 @@ class CommentInline(admin.TabularInline):
class
ViolationAdmin
(
admin
.
ModelAdmin
):
class
ViolationAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'state'
,
'country'
,
'operator'
,
'contract'
,
'resource_name'
,
'media'
,
'activationid'
)
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
,
]
inlines
=
[
CommentInline
,
]
admin
.
site
.
register
(
models
.
Violation
,
ViolationAdmin
)
admin
.
site
.
register
(
models
.
Violation
,
ViolationAdmin
)
...
@@ -22,9 +22,15 @@ admin.site.register(models.Attachment, AttachmentAdmin)
...
@@ -22,9 +22,15 @@ admin.site.register(models.Attachment, AttachmentAdmin)
class
ConfirmationAdmin
(
admin
.
ModelAdmin
):
class
ConfirmationAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'violation'
,
'key'
)
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
)
admin
.
site
.
register
(
models
.
Confirmation
,
ConfirmationAdmin
)
class
FeaturedCaseAdmin
(
admin
.
ModelAdmin
):
class
FeaturedCaseAdmin
(
admin
.
ModelAdmin
):
pass
pass
admin
.
site
.
register
(
models
.
FeaturedCase
,
FeaturedCaseAdmin
)
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
bt/api.py
View file @
7a36ad35
#from django.contrib.auth.models import User
#from django.contrib.auth.models import User
from
tastypie
import
fields
from
tastypie
import
fields
from
tastypie.authorization
import
DjangoAuthorization
from
tastypie.authorization
import
DjangoAuthorization
from
tastypie.resources
import
ModelResource
,
ALL
#
, ALL_WITH_RELATIONS
from
tastypie.resources
import
ModelResource
,
ALL
,
ALL_WITH_RELATIONS
from
bt.models
import
Violation
from
bt.models
import
Violation
,
Operator
#class UserResource(ModelResource):
#class UserResource(ModelResource):
...
@@ -11,8 +11,21 @@ from bt.models import Violation
...
@@ -11,8 +11,21 @@ from bt.models import Violation
# resource_name = 'auth/user'
# resource_name = 'auth/user'
# excludes = ['email', 'password', 'is_superuser']
# 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
):
class
APIResource
(
ModelResource
):
operator
=
fields
.
ForeignKey
(
OperatorResource
,
'operator_ref'
)
# user = fields.ForeignKey(UserResource, 'user')
# user = fields.ForeignKey(UserResource, 'user')
class
Meta
:
class
Meta
:
...
@@ -23,7 +36,6 @@ class APIResource(ModelResource):
...
@@ -23,7 +36,6 @@ class APIResource(ModelResource):
authorization
=
DjangoAuthorization
()
authorization
=
DjangoAuthorization
()
filtering
=
{
filtering
=
{
'country'
:
ALL
,
'country'
:
ALL
,
'operator'
:
ALL
,
'operator
_ref
'
:
ALL
_WITH_RELATIONS
,
'activationid'
:
ALL
,
'activationid'
:
ALL
,
}
}
bt/feeds.py
View file @
7a36ad35
...
@@ -12,7 +12,7 @@ class RssSiteNewsFeed(Feed):
...
@@ -12,7 +12,7 @@ class RssSiteNewsFeed(Feed):
return
Violation
.
objects
.
filter
(
activationid
=
''
).
order_by
(
'-id'
)[:
10
]
return
Violation
.
objects
.
filter
(
activationid
=
''
).
order_by
(
'-id'
)[:
10
]
def
item_link
(
self
,
item
):
def
item_link
(
self
,
item
):
return
"/view/%s"
%
item
.
pk
return
item
.
get_absolute_url
()
def
item_title
(
self
,
item
):
def
item_title
(
self
,
item
):
return
"%s (%s) %s"
%
(
item
.
operator
,
item
.
country
,
item
.
contract
)
return
"%s (%s) %s"
%
(
item
.
operator
,
item
.
country
,
item
.
contract
)
...
...
bt/migrations/0001_initial.py
0 → 100644
View file @
7a36ad35
# -*- 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
bt/migrations/0002_auto__add_operator__add_field_violation_operator_ref.py
0 → 100644
View file @
7a36ad35
# -*- 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
bt/migrations/0003_operator_data.py
0 → 100644
View file @
7a36ad35
# -*- 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
bt/migrations/0004_auto__del_field_violation_operator__chg_field_violation_operator_ref.py
0 → 100644
View file @
7a36ad35
# -*- 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
bt/migrations/__init__.py
0 → 100644
View file @
7a36ad35
bt/models.py
View file @
7a36ad35
...
@@ -59,9 +59,24 @@ STATUS = (
...
@@ -59,9 +59,24 @@ STATUS = (
(
'closed'
,
_
(
'Closed'
)),
(
'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
):
class
Violation
(
models
.
Model
):
country
=
models
.
CharField
(
max_length
=
2
,
choices
=
COUNTRIES
)
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
)
contract
=
models
.
CharField
(
max_length
=
256
,
blank
=
True
)
resource
=
models
.
CharField
(
max_length
=
20
,
choices
=
RESOURCES
,
blank
=
True
)
resource
=
models
.
CharField
(
max_length
=
20
,
choices
=
RESOURCES
,
blank
=
True
)
resource_name
=
models
.
CharField
(
max_length
=
4096
,
blank
=
True
)
resource_name
=
models
.
CharField
(
max_length
=
4096
,
blank
=
True
)
...
@@ -81,6 +96,15 @@ class Violation(models.Model):
...
@@ -81,6 +96,15 @@ class Violation(models.Model):
class
Admin
:
class
Admin
:
pass
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
):
def
__unicode__
(
self
):
return
"#%s %s/%s"
%
(
self
.
pk
,
self
.
country
,
self
.
operator
)
return
"#%s %s/%s"
%
(
self
.
pk
,
self
.
country
,
self
.
operator
)
...
...
bt/views.py
View file @
7a36ad35
from
forms
import
AddViolation
,
SearchViolation
from