def save(self, commit=True): project_user_membership = super(ProjectUserMembershipAdminForm, self).save(commit=False) if self.initial_status != project_user_membership.status: update_openldap_project_membership(project_user_membership) if commit: project_user_membership.save() return project_user_membership
def form_valid(self, form): response = super().form_valid(form) if 'status' in form.changed_data: update_openldap_project_membership( project_membership=form.instance) if self.request.is_ajax(): return JsonResponse({'message': 'Successfully updated.'}) else: return response
def activate_project_memberships(self, request, queryset): rows_updated = 0 for membership in queryset: membership.status = ProjectUserMembership.AUTHORISED membership.save() update_openldap_project_membership(membership) rows_updated += 1 message = self._project_membership_action_message(rows_updated) self.message_user( request, '{message} successfully submitted for activation.'.format( message=message))
def save(self, commit=True): project_user_membership = super(ProjectUserMembershipAdminForm, self).save(commit=False) if self.initial_status != project_user_membership.status: if project_user_membership.status == ProjectUserMembership.AUTHORISED: user = project_user_membership.user if user.profile.institution and user.profile.institution.needs_user_approval: user.profile.activate() update_openldap_project_membership(project_user_membership) if commit: project_user_membership.save() return project_user_membership
def form_valid(self, form): response = super().form_valid(form) if 'status' in form.changed_data: membership = form.instance if membership.status == ProjectUserMembership.AUTHORISED: user = membership.user if user.profile.institution and membership.user.profile.institution.needs_user_approval: membership.user.profile.activate() update_openldap_project_membership( project_membership=form.instance) if self.request.is_ajax(): return JsonResponse({'message': 'Successfully updated.'}) else: return response
def form_valid(self, form): response = super().form_valid(form) if 'status' in form.changed_data: try: update_openldap_project_membership( project_membership=form.instance) except: return JsonResponse( { 'message': 'We\'re sorry, something went wrong adding this use.' }, status=500) if self.request.is_ajax(): return JsonResponse({'message': 'Successfully updated.'}) else: return response