--- a/app/projrev/models.py Sun Aug 09 13:04:03 2009 +0530
+++ b/app/projrev/models.py Sun Aug 09 22:52:45 2009 +0530
@@ -12,6 +12,15 @@
from django.contrib.auth.models import User
+def sort_dict(d):
+ """Function to sort dictionary elements.
+ """
+
+ items = [(v, k) for k, v in d.items()]
+ items.sort()
+ return [(k, v) for v, k in items]
+
+
class Project(models.Model):
"""Model class for NME funded projects.
"""
@@ -38,6 +47,7 @@
}
STATE_CHOICES = {
+ "AN": "Andaman & Nicobar",
"DN": "Dadra and Nagar Haveli",
"DL": "Delhi",
"WB": "West Bengal",
@@ -57,7 +67,6 @@
"RJ": "Rajasthan",
"CH": "Chandigarh",
"CG": "Chattisgarh",
- "AN": "Andaman & Nicobar",
"AP": "Andhra Pradesh",
"AS": "Assam",
"AR": "Arunachal Pradesh",
@@ -668,20 +677,21 @@
# Field containing the Line Item to which the project belongs to.
line_item = models.CharField(max_length=256,
- choices=tuple(LINE_ITEM_CHOICES.items()))
+ choices=sort_dict(LINE_ITEM_CHOICES))
# Field containing the name of the institution working on the
# project.
institution = models.CharField(max_length=256)
# Field containing the state to which the institution belongs to.
- state = models.CharField(max_length=256,
- choices=tuple(STATE_CHOICES.items()))
+ state = models.CharField(
+ max_length=256,
+ choices=sorted(STATE_CHOICES.items(), key=lambda (k,v): (v,k)))
# Field containing the district to which the institution belongs
# to in the state of India.
district = models.CharField(max_length=256,
- choices=tuple(DISTRICT_CHOICES.items()))
+ choices=sort_dict(DISTRICT_CHOICES))
mobile_num = models.CharField(max_length=20)