Permalink
Browse files

Merge pull request #28 from epicserve/pep8_cleanup

PEP 8 cleanup
  • Loading branch information...
2 parents 9065091 + e5c7071 commit d49d340262784097487141b7cd478988dcff3810 @coleifer committed Jan 4, 2013
View
@@ -5,12 +5,14 @@
from relationships.forms import RelationshipStatusAdminForm
from relationships.models import Relationship, RelationshipStatus
+
class RelationshipInline(admin.TabularInline):
model = Relationship
raw_id_fields = ('from_user', 'to_user')
extra = 1
fk_name = 'from_user'
+
class UserRelationshipAdmin(UserAdmin):
inlines = (RelationshipInline,)
@@ -1,6 +1,7 @@
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404
+
def require_user(view):
def inner(request, username, *args, **kwargs):
user = get_object_or_404(User, username=username)
View
@@ -2,6 +2,7 @@
from django.db.models import Q
from relationships.models import RelationshipStatus
+
class RelationshipStatusAdminForm(forms.ModelForm):
class Meta:
model = RelationshipStatus
@@ -35,10 +36,10 @@ def clean_symmetrical_slug(self):
def clean(self):
if self.errors:
return self.cleaned_data
-
+
if self.cleaned_data['from_slug'] == self.cleaned_data['to_slug'] or \
self.cleaned_data['to_slug'] == self.cleaned_data['symmetrical_slug'] or \
self.cleaned_data['symmetrical_slug'] == self.cleaned_data['from_slug']:
raise forms.ValidationError('from, to, and symmetrical slugs must be different')
-
+
return self.cleaned_data
@@ -34,8 +34,10 @@ def mutually_exclusive_fix(sender, instance, created, **kwargs):
DISPATCH_UID = 'relationships.listeners.exclusive_fix'
+
def attach_relationship_listener(func=mutually_exclusive_fix, dispatch_uid=DISPATCH_UID):
signals.post_save.connect(func, sender=Relationship, dispatch_uid=dispatch_uid)
+
def detach_relationship_listener(dispatch_uid=DISPATCH_UID):
signals.post_save.disconnect(sender=Relationship, dispatch_uid=dispatch_uid)
@@ -1,12 +1,11 @@
-
from south.db import db
-from django.db import models
from relationships.models import *
+
class Migration:
-
+
def forwards(self, orm):
-
+
# Adding model 'RelationshipStatus'
db.create_table('relationships_relationshipstatus', (
('id', orm['relationships.RelationshipStatus:id']),
@@ -19,7 +18,7 @@ def forwards(self, orm):
('private', orm['relationships.RelationshipStatus:private']),
))
db.send_create_signal('relationships', ['RelationshipStatus'])
-
+
# Adding model 'Relationship'
db.create_table('relationships_relationship', (
('id', orm['relationships.Relationship:id']),
@@ -29,25 +28,21 @@ def forwards(self, orm):
('created', orm['relationships.Relationship:created']),
))
db.send_create_signal('relationships', ['Relationship'])
-
+
# Creating unique_together for [from_user, to_user, status] on Relationship.
db.create_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id'])
-
-
-
+
def backwards(self, orm):
-
+
# Deleting unique_together for [from_user, to_user, status] on Relationship.
db.delete_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id'])
-
+
# Deleting model 'RelationshipStatus'
db.delete_table('relationships_relationshipstatus')
-
+
# Deleting model 'Relationship'
db.delete_table('relationships_relationship')
-
-
-
+
models = {
'auth.group': {
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
@@ -103,5 +98,5 @@ def backwards(self, orm):
'verb': ('django.db.models.fields.CharField', [], {'max_length': '100'})
}
}
-
+
complete_apps = ['relationships']
@@ -1,24 +1,19 @@
-
from south.db import db
-from django.db import models
from relationships.models import *
+
class Migration:
-
+
def forwards(self, orm):
-
+
# Adding field 'Relationship.site'
db.add_column('relationships_relationship', 'site', orm['relationships.relationship:site'])
-
-
-
+
def backwards(self, orm):
-
+
# Deleting field 'Relationship.site'
db.delete_column('relationships_relationship', 'site_id')
-
-
-
+
models = {
'auth.group': {
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
@@ -81,5 +76,5 @@ def backwards(self, orm):
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
}
}
-
+
complete_apps = ['relationships']
@@ -1,60 +1,55 @@
-
from south.db import db
-from django.db import models
from relationships.models import *
+
class Migration:
-
+
def forwards(self, orm):
-
+
# Deleting unique_together for [symmetrical_slug] on relationshipstatus.
db.delete_unique('relationships_relationshipstatus', ['symmetrical_slug'])
-
+
# Deleting unique_together for [from_slug] on relationshipstatus.
db.delete_unique('relationships_relationshipstatus', ['from_slug'])
-
+
# Deleting unique_together for [to_slug] on relationshipstatus.
db.delete_unique('relationships_relationshipstatus', ['to_slug'])
-
+
# Changing field 'RelationshipStatus.to_slug'
# (to signature: django.db.models.fields.CharField(max_length=100))
db.alter_column('relationships_relationshipstatus', 'to_slug', orm['relationships.relationshipstatus:to_slug'])
-
+
# Changing field 'RelationshipStatus.symmetrical_slug'
# (to signature: django.db.models.fields.CharField(max_length=100))
db.alter_column('relationships_relationshipstatus', 'symmetrical_slug', orm['relationships.relationshipstatus:symmetrical_slug'])
-
+
# Changing field 'RelationshipStatus.from_slug'
# (to signature: django.db.models.fields.CharField(max_length=100))
db.alter_column('relationships_relationshipstatus', 'from_slug', orm['relationships.relationshipstatus:from_slug'])
-
-
-
+
def backwards(self, orm):
-
+
# Changing field 'RelationshipStatus.to_slug'
# (to signature: django.db.models.fields.SlugField(max_length=50, unique=True, db_index=True))
db.alter_column('relationships_relationshipstatus', 'to_slug', orm['relationships.relationshipstatus:to_slug'])
-
+
# Changing field 'RelationshipStatus.symmetrical_slug'
# (to signature: django.db.models.fields.SlugField(max_length=50, unique=True, db_index=True))
db.alter_column('relationships_relationshipstatus', 'symmetrical_slug', orm['relationships.relationshipstatus:symmetrical_slug'])
-
+
# Changing field 'RelationshipStatus.from_slug'
# (to signature: django.db.models.fields.SlugField(max_length=50, unique=True, db_index=True))
db.alter_column('relationships_relationshipstatus', 'from_slug', orm['relationships.relationshipstatus:from_slug'])
-
+
# Creating unique_together for [to_slug] on relationshipstatus.
db.create_unique('relationships_relationshipstatus', ['to_slug'])
-
+
# Creating unique_together for [from_slug] on relationshipstatus.
db.create_unique('relationships_relationshipstatus', ['from_slug'])
-
+
# Creating unique_together for [symmetrical_slug] on relationshipstatus.
db.create_unique('relationships_relationshipstatus', ['symmetrical_slug'])
-
-
-
+
models = {
'auth.group': {
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
@@ -117,5 +112,5 @@ def backwards(self, orm):
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
}
}
-
+
complete_apps = ['relationships']
@@ -1,30 +1,25 @@
-
from south.db import db
-from django.db import models
from relationships.models import *
+
class Migration:
-
+
def forwards(self, orm):
-
+
# Deleting unique_together for [from_user, to_user, status] on relationship.
db.delete_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id'])
-
+
# Creating unique_together for [from_user, to_user, status, site] on Relationship.
db.create_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id', 'site_id'])
-
-
-
+
def backwards(self, orm):
-
+
# Deleting unique_together for [from_user, to_user, status, site] on Relationship.
db.delete_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id', 'site_id'])
-
+
# Creating unique_together for [from_user, to_user, status] on relationship.
db.create_unique('relationships_relationship', ['from_user_id', 'to_user_id', 'status_id'])
-
-
-
+
models = {
'auth.group': {
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
@@ -87,5 +82,5 @@ def backwards(self, orm):
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
}
}
-
+
complete_apps = ['relationships']
@@ -1,23 +1,20 @@
# encoding: 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 field 'Relationship.weight'
db.add_column('relationships_relationship', 'weight', self.gf('django.db.models.fields.FloatField')(default=1.0, null=True, blank=True), keep_default=False)
-
def backwards(self, orm):
-
+
# Deleting field 'Relationship.weight'
db.delete_column('relationships_relationship', 'weight')
-
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
Oops, something went wrong.

0 comments on commit d49d340

Please sign in to comment.