1. Alex Mayfield
  2. nada

Commits

Alex Mayfield  committed 238d490

Remove signup/start booleans, only show signups before the start date/time.

  • Participants
  • Parent commits 408bdec
  • Branches default

Comments (0)

Files changed (4)

File tourney/admin.py

View file
 
 from tourney.models import League, Contest, Signup, Match, Round, Penalty
 
-# Admin Forms
-class SignupAdminForm(forms.ModelForm):
-    def __init__(self, *args, **kwargs):
-        super(SignupAdminForm, self).__init__(*args, **kwargs)
-
-    class Meta:
-        model = Signup
-        fields = ('user', 'status', 'seed', 'signup_time')
-
 # Admins
 class LeagueAdmin(admin.ModelAdmin):
     pass
 
 class SignupAdminInline(admin.TabularInline):
-    form = SignupAdminForm
+    fields = ('user', 'status', 'seed', 'signup_time')
     model = Signup
+    readonly_fields = ('signup_time',)
 
 class ContestAdmin(admin.ModelAdmin):
+    fieldsets = (
+        (None, {
+                'fields': (
+                    ('name', 'league'),
+                    'live',
+                    ('signup_deadline', 'start_deadline'),
+                    )
+                }
+         )
+        ,)
     inlines = [SignupAdminInline]
     list_display = ('live', 'name', 'signups_count', 'participants_count')
     list_display_links = ('name',)
 
+    def get_formsets(self, request, obj=None):
+        # Disable the signups inline if the contest has started.
+        for inline in self.inline_instances:
+            if isinstance(inline, SignupAdminInline) and not obj is None and \
+                    obj.started() == True:
+                continue
+            yield inline.get_formset(request, obj)
+
 class MatchAdmin(admin.ModelAdmin):
     pass
 

File tourney/migrations/0008_auto__add_field_contest_started.py

View file
+# 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 'Contest.started'
+        db.add_column('tourney_contest', 'started', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Contest.started'
+        db.delete_column('tourney_contest', 'started')
+
+
+    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'})
+        },
+        'tourney.contest': {
+            'Meta': {'object_name': 'Contest'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'league': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.League']"}),
+            'live': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'scored': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'signup_deadline': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'signups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'through': "orm['tourney.Signup']", 'symmetrical': 'False'}),
+            'signups_open': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'start_deadline': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'started': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'status': ('django.db.models.fields.IntegerField', [], {'default': '0'})
+        },
+        'tourney.league': {
+            'Meta': {'object_name': 'League'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'tourney.match': {
+            'Meta': {'object_name': 'Match'},
+            'contest': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Contest']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'match_of_contest': ('django.db.models.fields.IntegerField', [], {}),
+            'player_a': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_player_a'", 'to': "orm['auth.User']"}),
+            'player_b': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_player_b'", 'to': "orm['auth.User']"}),
+            'winner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_winner'", 'to': "orm['auth.User']"})
+        },
+        'tourney.penalty': {
+            'Meta': {'object_name': 'Penalty'},
+            'admin_notes': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'match': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Match']"}),
+            'points': ('django.db.models.fields.IntegerField', [], {}),
+            'reason': ('django.db.models.fields.TextField', [], {}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'tourney.round': {
+            'Meta': {'object_name': 'Round'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'log': ('django.db.models.fields.TextField', [], {}),
+            'match': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Match']"}),
+            'round_map': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['wadinfo.Map']"}),
+            'round_of_match': ('django.db.models.fields.IntegerField', [], {}),
+            'score_a': ('django.db.models.fields.IntegerField', [], {}),
+            'score_b': ('django.db.models.fields.IntegerField', [], {}),
+            'winner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'tourney.signup': {
+            'Meta': {'object_name': 'Signup'},
+            'contest': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Contest']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'seed': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'signup_time': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'wadinfo.map': {
+            'Meta': {'object_name': 'Map'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lump': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'wad': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['wadinfo.Wad']"})
+        },
+        'wadinfo.wad': {
+            'Meta': {'object_name': 'Wad'},
+            'filename': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['tourney']

File tourney/migrations/0009_auto__del_field_contest_started__del_field_contest_signups_open.py

View file
+# 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):
+        
+        # Deleting field 'Contest.started'
+        db.delete_column('tourney_contest', 'started')
+
+        # Deleting field 'Contest.signups_open'
+        db.delete_column('tourney_contest', 'signups_open')
+
+
+    def backwards(self, orm):
+        
+        # Adding field 'Contest.started'
+        db.add_column('tourney_contest', 'started', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+        # Adding field 'Contest.signups_open'
+        db.add_column('tourney_contest', 'signups_open', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False)
+
+
+    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'})
+        },
+        'tourney.contest': {
+            'Meta': {'object_name': 'Contest'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'league': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.League']"}),
+            'live': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'scored': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'signup_deadline': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'signups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'through': "orm['tourney.Signup']", 'symmetrical': 'False'}),
+            'start_deadline': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.IntegerField', [], {'default': '0'})
+        },
+        'tourney.league': {
+            'Meta': {'object_name': 'League'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'tourney.match': {
+            'Meta': {'object_name': 'Match'},
+            'contest': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Contest']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'match_of_contest': ('django.db.models.fields.IntegerField', [], {}),
+            'player_a': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_player_a'", 'to': "orm['auth.User']"}),
+            'player_b': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_player_b'", 'to': "orm['auth.User']"}),
+            'winner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tourney_match_winner'", 'to': "orm['auth.User']"})
+        },
+        'tourney.penalty': {
+            'Meta': {'object_name': 'Penalty'},
+            'admin_notes': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'match': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Match']"}),
+            'points': ('django.db.models.fields.IntegerField', [], {}),
+            'reason': ('django.db.models.fields.TextField', [], {}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'tourney.round': {
+            'Meta': {'object_name': 'Round'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'log': ('django.db.models.fields.TextField', [], {}),
+            'match': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Match']"}),
+            'round_map': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['wadinfo.Map']"}),
+            'round_of_match': ('django.db.models.fields.IntegerField', [], {}),
+            'score_a': ('django.db.models.fields.IntegerField', [], {}),
+            'score_b': ('django.db.models.fields.IntegerField', [], {}),
+            'winner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'tourney.signup': {
+            'Meta': {'object_name': 'Signup'},
+            'contest': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['tourney.Contest']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'seed': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'signup_time': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'wadinfo.map': {
+            'Meta': {'object_name': 'Map'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lump': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'wad': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['wadinfo.Wad']"})
+        },
+        'wadinfo.wad': {
+            'Meta': {'object_name': 'Wad'},
+            'filename': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['tourney']

File tourney/models.py

View file
         (PREPARATION_STATUS, "Preparation"),
         (ACTIVE_STATUS, "Active"),
         )
-    league = models.ForeignKey(League)
+    league = models.ForeignKey(League, help_text="League to which the "
+                               "contest belongs to.")
     live = models.BooleanField(help_text="Should the contest be shown on "
                                "the site?")
     name = models.CharField(max_length=50, help_text="Name of the contest.")
     scored = models.BooleanField(default=False, editable=False)
     signups = models.ManyToManyField(User, through='Signup')
-    signups_open = models.BooleanField(default=True, help_text="Are signups "
-            "open to the public?  Note that this setting is overridden by the "
-            "deadline.")
     signup_deadline = models.DateTimeField(blank=True, default=None,
-            null=True, help_text="After this time signups are automatically "
-            "closed to the public.")
+            null=True, help_text="After this time signups are closed to the "
+            "public.")
     start_deadline = models.DateTimeField(blank=True, default=None, null=True,
-            help_text="After this time the contest starts automatically and "
-            "matches are populated.")
+            help_text="After this time the contest is considered underway.")
     status = models.IntegerField(choices=STATUS_CHOICES,
                                  default=POPULATION_STATUS, editable=False)
 
     def __unicode__(self):
         return self.name
 
+    def signups_open(self):
+        if self.signup_deadline is None:
+            return False
+        return datetime.now() > self.signup_deadline
+
+    def started(self):
+        if self.start_deadline is None:
+            return False
+        return datetime.now() > self.start_deadline
+
     def signups_count(self):
         return self.signups.through.objects.filter(
             status=Signup.SIGNED_UP_STATUS, contest=self.id).count()
     user = models.ForeignKey(User)
 
     def __unicode__(self):
-        return "{0} is {0} for {0}".format((self.user, self.status,
-                                            self.contest))
+        nice_status = {
+            self.SIGNED_UP_STATUS: "has signed up for",
+            self.INVITED_STATUS: "has been invited to play in",
+            self.PARTICIPANT_STATUS: "is participating in",
+            self.ADMIN_DENIED_STATUS: "has been denied entry to",
+            self.USER_DECLINED_STATUS: "has declined to participate in",
+            }
+        return "{0} {1} {2}".format(self.user.username,
+                                    nice_status[self.status],
+                                    self.contest.name)
 
     def save(self, *args, **kwargs):
         # Save the time of our first "Signed Up" status