Exemplo n.º 1
0
 def save_model(self, request, obj, form, change):
     org = obj.save()
     #Note: This will only ever execute for superuser(s)
     #create group with similar name
     logger.error('Org details %s: ' % obj.org_id)
     grp_name = slugify(obj.org_name).replace('-','')
     slot = utility.auto_alloc_slot(obj.org_admin.member_profile)
     g = Groups.create(obj.org_admin.member_profile, grp_name, slot, org = obj)
     logger.error('Created Group %s for org %s' % (obj, g))
Exemplo n.º 2
0
 def save_model(self, request, obj, form, change):
     obj.save()
     #if adding new user then they'll be added to default
     #group for that organization
     if not change:
         if request.user.is_superuser:
             pass #catch this on the form
         else:
             slot = utility.auto_alloc_slot(obj)
             org = Organization.objects.get(org_admin = request.user)
             grp_name = slugify(org.org_name).replace('-','')
             group = Groups.objects.get(group_name = grp_name, org = org)
             obj.join_group(group, slot, None, False)
Exemplo n.º 3
0
 def save(self, force_insert=False, force_update=False, commit=True):
     ug_form = super(UserGroupsForm,self).save(commit=False)
     
     #for new users auto alloc slot. self.initial == {} for new records
     if self.initial == {}:
         ug_form.slot = utility.auto_alloc_slot(ug_form.user)
     
     #if quiet state changed use methods in model
     ug_db = UserGroups.objects.filter(user_group_id = ug_form.user_group_id)
     
     if len(ug_db) > 0: #if it's an edit then ug_db is no empty
         if ug_db[0].is_quiet != ug_form.is_quiet:
             if ug_form.is_quiet == 'yes':
                 ug_form.group.set_quiet(ug_form.user)
             else:
                 ug_form.group.unquiet(ug_form.user)
     
     ug_form.save()
     
     return ug_form