Revision 51c57c9c

b/snf-astakos-app/astakos/im/forms.py
567 567
                    continue
568 568
                yield (suffix, value)
569 569

  
570
class AstakosGroupUpdateForm(forms.ModelForm):
571
    class Meta:
572
        model = AstakosGroup
573
        fields = ('homepage', 'desc')
570 574

  
571 575
class AstakosGroupSearchForm(forms.Form):
572 576
    q = forms.CharField(max_length=200, label='Search group')
b/snf-astakos-app/astakos/im/templates/im/astakosgroup_detail.html
36 36
			 </dl>
37 37
		</div>
38 38
		<div class="editable" style="display:none;">
39
			<!-- demo form-->
40
			<form class="innerlabels" method="post" action=""><div style="display:none"><input type="hidden" value="d1d4677634f858843ca84e2cac5bbebc" name="csrfmiddlewaretoken" autocomplete="off"></div>
41
	           
42
	            <div class="form-errors all"></div>
43
				<div class="form-row   ">
44
				        
45
				     <p class="clearfix ">
46
				        <label for="id_homepage">Homepage</label>
47
				        <input type="text" id="id_homepage" name="homepage" autocomplete="off" value="{{ object.homepage }}">
48
				        <span class="extra-img">&nbsp;</span>
49
				        
50
				     </p>
51
				</div>
52
				
53
				<div class="form-row   ">
54
				        
55
				     <p class="clearfix ">
56
				        <label for="id_desc">Description</label>
57
				        <textarea name="desc" cols="40" rows="10" id="id_desc">{{ object.desc }}</textarea>
58
				        <span class="extra-img">&nbsp;</span>
59
				        
60
				     </p>
61
				</div>
62
				 
63
				<div class="form-row submit">
64
				     <input type="submit" value="SUBMIT" class="submit altcol" autocomplete="off">
65
				</div>
66
				</form>
67
			<!-- end of demo form-->
39
		<form action="{% url astakos.im.views.group_update object.id %}" method="post"
40
	            class="withlabels">{% csrf_token %}
41
	            {% include "im/form_render.html" %}
42
	            <div class="form-row submit">
43
	                <input type="submit" class="submit altcol" value="SUBMIT" />
44
	            </div>
45
	    </form>
68 46
		</div>
69 47
	 </div>
70 48
	 <div class="full-dotted">
......
72 50
		 <dl class="alt-style">
73 51
		 	<dt>Name</dt>
74 52
		 	<dd>{{object.name}}&nbsp;</dd>
75
		 	<dt>Homepage</dt>
76
		 	<dd>{{object.homepage}}&nbsp;</dd>
77 53
		 	<dt>Type</dt>
78 54
		 	<dd>{{object.kind|capfirst}}&nbsp;</dd>
79 55
		 	<dt>Issue date:</dt>
b/snf-astakos-app/astakos/im/urls.py
64 64
                           'group_list', {}, name='group_list'),
65 65
                       url(r'^group/(?P<group_id>\d+)/?$', 'group_detail', {},
66 66
                           name='group_detail'),
67
                       url(r'^group/update/(?P<group_id>\d+)/?$',
68
                           'group_update', {}, name='group_update'),
67 69
                       url(r'^group/search/?$',
68 70
                           'group_search', {}, name='group_search'),
69 71
                       url(
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