Revision 51c57c9c snf-astakos-app/astakos/im/views.py

b/snf-astakos-app/astakos/im/views.py
56 56
                                                get_model_and_form_class
57 57
                                                )
58 58
from django.views.generic.list_detail import object_list, object_detail
59
from django.http import HttpResponseBadRequest
59 60

  
60 61
from astakos.im.models import (
61 62
    AstakosUser, ApprovalTerms, AstakosGroup, Resource,
62 63
    EmailChange, GroupKind, Membership)
63 64
from astakos.im.activation_backends import get_backend, SimpleBackend
64 65
from astakos.im.util import get_context, prepare_response, set_cookie, get_query
65
from astakos.im.forms import (
66
    LoginForm, InvitationForm, ProfileForm, FeedbackForm,
67
    SignApprovalTermsForm, ExtendedPasswordChangeForm, EmailChangeForm,
68
    AstakosGroupCreationForm, AstakosGroupSearchForm
69
)
66
from astakos.im.forms import (LoginForm, InvitationForm, ProfileForm,
67
                              FeedbackForm, SignApprovalTermsForm,
68
                              ExtendedPasswordChangeForm, EmailChangeForm,
69
                              AstakosGroupCreationForm, AstakosGroupSearchForm,
70
                              AstakosGroupUpdateForm)
70 71
from astakos.im.functions import (send_feedback, SendMailError,
71
                                  invite as invite_func, logout as auth_logout, activate as activate_func,
72
                                  switch_account_to_shibboleth, send_admin_notification, SendNotificationError
73
                                  )
72
                                  invite as invite_func, logout as auth_logout,
73
                                  activate as activate_func,
74
                                  switch_account_to_shibboleth,
75
                                  send_admin_notification,
76
                                  SendNotificationError)
74 77
from astakos.im.settings import (
75 78
    COOKIE_NAME, COOKIE_DOMAIN, SITENAME, LOGOUT_NEXT,
76 79
    LOGGING_LEVEL
......
80 83
logger = logging.getLogger(__name__)
81 84

  
82 85

  
83
def render_response(template, tab=None, status=200, reset_cookie=False, context_instance=None, **kwargs):
86
def render_response(template, tab=None, status=200, reset_cookie=False,
87
                    context_instance=None, **kwargs):
84 88
    """
85 89
    Calls ``django.template.loader.render_to_string`` with an additional ``tab``
86 90
    keyword argument and returns an ``django.http.HttpResponse`` with the
......
723 727
        group = AstakosGroup.objects.select_related().get(id=group_id)
724 728
    except AstakosGroup.DoesNotExist:
725 729
        return HttpResponseBadRequest(_('Invalid group.'))
730
    form = AstakosGroupUpdateForm(instance=group)
726 731
    return object_detail(request,
727 732
                         AstakosGroup.objects.all(),
728 733
                         object_id=group_id,
729
                         extra_context={'quota': group.quota}
734
                         extra_context={'quota': group.quota,
735
                                        'form': form}
730 736
                         )
731 737

  
732 738

  
739
def group_update(request, group_id):
740
    if request.method != 'POST':
741
        return HttpResponseBadRequest('Method not allowed.')
742
    try:
743
        group = AstakosGroup.objects.select_related().get(id=group_id)
744
    except AstakosGroup.DoesNotExist:
745
        return HttpResponseBadRequest(_('Invalid group.'))
746
    form = AstakosGroupUpdateForm(request.POST, instance=group)
747
    if form.is_valid():
748
        form.save()
749
    return group_detail(request, group_id)
733 750

  
734 751
@signed_terms_required
735 752
@login_required

Also available in: Unified diff