1. Jernej Kos
  2. teapoll

Commits

Jernej Kos  committed 33126bf

Made subject identifiers numeric.

  • Participants
  • Parent commits 743657a
  • Branches default

Comments (0)

Files changed (2)

File survey/models.py

View file
   def __unicode__(self):
     return self.title
 
-def generate_subject_sid():
-  return "".join([random.choice(string.uppercase + string.digits) for i in xrange(4)])
-
 class Subject(models.Model):
   class Meta:
     ordering = ['sid']
 
-  sid = models.CharField(primary_key = True, max_length = 15, editable = False, default = generate_subject_sid)
+  sid = models.AutoField(primary_key = True)
   created_at = models.DateTimeField(auto_now_add = True)
 
 class Answer(models.Model):

File templates/survey/list.html

View file
 Subjects:
 <hr/>
 {% for subject in survey.get_subjects %}
-<a href="{% url edit_survey survey.pk subject.pk %}">{{ subject.pk }}</a> ({{ subject.created_at }})<br/>
+<a href="{% url edit_survey survey.pk subject.pk %}">Subject {{ subject.pk }}</a> ({{ subject.created_at }})<br/>
 {% endfor %}
 <hr/>
 <a href="{% url enter_survey survey.pk %}">Enter new subject</a>