def create_Shaastra (): """ Create the highest level group - Shaastra! """ try: top_level_group = Group.objects.get (label__name = 'Festival') except: top_level_group = Group () top_level_group.label = Label.objects.get (name = 'Festival') top_level_group.name = 'Shaastra' top_level_group.save ()
def create_depts (): """ Create all the departments with names as given DEP_CHOICES. """ top_level_group = Group.objects.get (label__name = 'Festival') for name, description in DEP_CHOICES: try: dept = Group.objects.get (label__name = 'Department', name = name) except: new_dept = Group () new_dept.label = Label.objects.get (name = 'Department') new_dept.name = name new_dept.parent = top_level_group new_dept.save () print 'Department %s created' % (name) else: print 'Department %s exists' % (name)