Commits

Nathaniel Tucker  committed ba59c6d

Add approval file field for teams
Disable duplication team creation for now

  • Participants
  • Parent commits 250196b

Comments (0)

Files changed (3)

File ahgl/apps/profiles/migrations/0030_auto__add_field_team_approval__chg_field_team_charity.py

+# 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 'Team.approval'
+        db.add_column('profiles_team', 'approval', self.gf('django.db.models.fields.files.FileField')(max_length=100, null=True, blank=True), keep_default=False)
+
+        # Changing field 'Team.charity'
+        db.alter_column('profiles_team', 'charity_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['profiles.Charity']))
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Team.approval'
+        db.delete_column('profiles_team', 'approval')
+
+        # Changing field 'Team.charity'
+        db.alter_column('profiles_team', 'charity_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['profiles.Charity'], on_delete=models.SET_NULL))
+
+
+    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'})
+        },
+        'profiles.charity': {
+            'Meta': {'ordering': "('name',)", 'object_name': 'Charity'},
+            'desc': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'link': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+            'logo': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '60'})
+        },
+        'profiles.profile': {
+            'Meta': {'object_name': 'Profile'},
+            'autosubscribe': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'avatar': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'custom_thumb': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '10', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'photo': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'post_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'blank': 'True'}),
+            'show_signatures': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'signature': ('django.db.models.fields.TextField', [], {'max_length': '1024', 'blank': 'True'}),
+            'signature_html': ('django.db.models.fields.TextField', [], {'max_length': '1054', 'blank': 'True'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
+            'time_zone': ('django.db.models.fields.FloatField', [], {'default': '3.0'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '70', 'blank': 'True'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+            'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+        },
+        'profiles.team': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('name', 'tournament'), ('slug', 'tournament'))", 'object_name': 'Team'},
+            'approval': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'charity': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'teams'", 'null': 'True', 'to': "orm['profiles.Charity']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'losses': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'members': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'teams'", 'to': "orm['profiles.Profile']", 'through': "orm['profiles.TeamMembership']", 'blank': 'True', 'symmetrical': 'False', 'null': 'True'}),
+            'motto': ('django.db.models.fields.CharField', [], {'max_length': '70', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'photo': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'seed': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
+            'tiebreaker': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'tournament': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'teams'", 'to': "orm['tournaments.Tournament']"}),
+            'wins': ('django.db.models.fields.IntegerField', [], {'default': '0'})
+        },
+        'profiles.teammembership': {
+            'Meta': {'ordering': "('-active', '-captain', 'char_name')", 'unique_together': "(('team', 'profile'),)", 'object_name': 'TeamMembership', 'db_table': "'profiles_team_members'"},
+            'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'captain': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'champion': ('django.db.models.fields.CharField', [], {'max_length': '60', 'blank': 'True'}),
+            'char_code': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'char_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
+            'game_profile': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'profile': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'team_membership'", 'to': "orm['profiles.Profile']"}),
+            'questions_answers': ('profiles.fields.HTMLField', [], {'attributes': '[]', 'blank': 'True', 'tags': "['ol', 'ul', 'li', 'strong', 'em', 'p']"}),
+            'race': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}),
+            'team': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'team_membership'", 'to': "orm['profiles.Team']"})
+        },
+        'tournaments.map': {
+            'Meta': {'ordering': "('name',)", 'object_name': 'Map'},
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'primary_key': 'True'}),
+            'photo': ('sorl.thumbnail.fields.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+        },
+        'tournaments.tournament': {
+            'Meta': {'object_name': 'Tournament'},
+            'games_per_match': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '5'}),
+            'map_pool': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['tournaments.Map']", 'symmetrical': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True', 'db_index': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'S'", 'max_length': '1', 'db_index': 'True'}),
+            'structure': ('django.db.models.fields.CharField', [], {'default': "'I'", 'max_length': '1'})
+        }
+    }
+
+    complete_apps = ['profiles']

File ahgl/apps/profiles/models.py

     photo = ImageField(upload_to='team_photos', null=True, blank=True)
     charity = models.ForeignKey('profiles.Charity', null=True, blank=True, on_delete=models.SET_NULL, related_name='teams')
     motto = models.CharField(max_length=70, blank=True)
+    approval = models.FileField(upload_to='team_approvals', null=True, blank=True)
     members = models.ManyToManyField('Profile', null=True, blank=True, related_name='teams', through=TeamMembership)
     tournament = models.ForeignKey('tournaments.Tournament', related_name='teams', db_index=True)
     

File ahgl/apps/profiles/views.py

     def get_form_class(self):
         view = self
         class TeamCreateForm(ModelForm):
-            duplicate = forms.ModelChoiceField(queryset=Team.objects.filter(team_membership__profile__user=view.request.user), required=False)
+            #duplicate = forms.ModelChoiceField(queryset=Team.objects.filter(team_membership__profile__user=view.request.user), required=False)
             char_name = forms.CharField(max_length=TeamMembership._meta.get_field('char_name').max_length, required=True, label="Your char name")
             class Meta:
                 model = Team
                 exclude=('tournament','rank','seed','members',)
-            def clean(self):
+            """def clean(self):
                 if self.cleaned_data.get('duplicate'):
-                    pass
-                else:
-                    return super(TeamCreateForm, self).clean()
+                    dup = self.cleaned_data.get('duplicate')
+                    copy = ('name', 'slug', 'photo', 'charity', 'motto')
+                    for field in copy:
+                        if not self.cleaned_data.get(field):
+                            self.cleaned_data[field] = getattr(dup, field)
+                return super(TeamCreateForm, self).clean()"""
             def save(self, *args, **kwargs):
                 self.instance.tournament = view.tournament
                 super(TeamCreateForm, self).save(*args, **kwargs)