Made Timeline model to refer to Event model not vice-versa.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Wed, 21 Jul 2010 02:05:33 +0530
changeset 136 267d9eee024b
parent 135 782f958b2cb2
child 137 ec6e58c639bf
Made Timeline model to refer to Event model not vice-versa.
project/scipycon/base/admin.py
project/scipycon/base/models.py
--- a/project/scipycon/base/admin.py	Wed Jul 21 02:04:48 2010 +0530
+++ b/project/scipycon/base/admin.py	Wed Jul 21 02:05:33 2010 +0530
@@ -10,7 +10,7 @@
     search_fields = ('name', 'turn', 'status',)
     fieldsets = (
         ('Details', {
-            'fields': ('name', 'turn', 'status', 'scope', 'timeline')
+            'fields': ('name', 'turn', 'status', 'scope')
         }),
     )
 
@@ -19,11 +19,11 @@
     list_display = ('registration_start', 'registration_end', 'cfp_start',
                     'cfp_end', 'accepted_papers_announced',
                     'proceedings_paper_deadline', 'event_start',
-                    'event_end')
+                    'event_end', 'event')
     list_filter = ('registration_start', 'registration_end', 'cfp_start',
                    'cfp_end', 'accepted_papers_announced',
                    'proceedings_paper_deadline', 'event_start',
-                   'event_end')
+                   'event_end', 'event')
     search_fields = ('registration_start', 'registration_end', 'cfp_start',
                      'cfp_end', 'accepted_papers_announced',
                      'proceedings_paper_deadline', 'event_start',
@@ -37,7 +37,7 @@
                        'proceedings_paper_deadline')
         }),
         ('Event', {
-            'fields': ('event_start', 'event_end')
+            'fields': ('event_start', 'event_end', 'event')
         }),
     )
 
--- a/project/scipycon/base/models.py	Wed Jul 21 02:04:48 2010 +0530
+++ b/project/scipycon/base/models.py	Wed Jul 21 02:05:33 2010 +0530
@@ -1,10 +1,39 @@
 from django.db import models
 
 
+class Event(models.Model):
+    """Data model which holds the data related to the scope or the event.
+    """
+
+    # Different states the Event can be in
+    STATUS_CHOICES = (
+        ('active', 'Active'),
+        ('inactive', 'Inactive'),
+    )
+
+    # Scope of the program, used as a URL prefix
+    scope = models.CharField(max_length=255)
+
+    # Name of the program
+    name = models.CharField(max_length=255)
+
+    # Event specific i.e version of the event
+    turn = models.CharField(max_length=255)
+
+    # Status of the program
+    status = models.CharField(max_length=255, choices=STATUS_CHOICES)
+
+    def __unicode__(self):
+        return '%s %s' % (self.name, self.turn)
+
+
 class Timeline(models.Model):
     """Timeline of the program
     """
 
+    # Event with which this timeline is associated
+    event = models.OneToOneField(Event)
+
     # Start of registration for the program
     registration_start = models.DateTimeField(blank=True, null=True)
 
@@ -29,31 +58,8 @@
     # End of the actual program
     event_end = models.DateTimeField(blank=True, null=True)
 
-
-class Event(models.Model):
-    """Data model which holds the data related to the scope or the event.
-    """
-
-    # Different states the Event can be in
-    STATUS_CHOICES = (
-        ('active', 'Active'),
-        ('inactive', 'Inactive'),
-    )
-
-    # Scope of the program, used as a URL prefix
-    scope = models.CharField(max_length=255)
-
-    # Name of the program
-    name = models.CharField(max_length=255)
-
-    # Event specific i.e version of the event
-    turn = models.CharField(max_length=255)
-
-    # Time associated with the program
-    timeline = models.OneToOneField(Timeline)
-
-    # Status of the program
-    status = models.CharField(max_length=255, choices=STATUS_CHOICES)
+    def __unicode__(self):
+        return '%s %s' % (self.event.name, self.event.turn)
 
 
 class ScopedBase(models.Model):