Commit 1829985b authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Group owner can update group description & homepage

Refs: #2793
parent 02780220
......@@ -567,6 +567,10 @@ class AstakosGroupCreationForm(forms.ModelForm):
continue
yield (suffix, value)
class AstakosGroupUpdateForm(forms.ModelForm):
class Meta:
model = AstakosGroup
fields = ('homepage', 'desc')
class AstakosGroupSearchForm(forms.Form):
q = forms.CharField(max_length=200, label='Search group')
......@@ -36,35 +36,13 @@
</dl>
</div>
<div class="editable" style="display:none;">
<!-- demo form-->
<form class="innerlabels" method="post" action=""><div style="display:none"><input type="hidden" value="d1d4677634f858843ca84e2cac5bbebc" name="csrfmiddlewaretoken" autocomplete="off"></div>
<div class="form-errors all"></div>
<div class="form-row ">
<p class="clearfix ">
<label for="id_homepage">Homepage</label>
<input type="text" id="id_homepage" name="homepage" autocomplete="off" value="{{ object.homepage }}">
<span class="extra-img">&nbsp;</span>
</p>
</div>
<div class="form-row ">
<p class="clearfix ">
<label for="id_desc">Description</label>
<textarea name="desc" cols="40" rows="10" id="id_desc">{{ object.desc }}</textarea>
<span class="extra-img">&nbsp;</span>
</p>
</div>
<div class="form-row submit">
<input type="submit" value="SUBMIT" class="submit altcol" autocomplete="off">
</div>
</form>
<!-- end of demo form-->
<form action="{% url astakos.im.views.group_update object.id %}" method="post"
class="withlabels">{% csrf_token %}
{% include "im/form_render.html" %}
<div class="form-row submit">
<input type="submit" class="submit altcol" value="SUBMIT" />
</div>
</form>
</div>
</div>
<div class="full-dotted">
......@@ -72,8 +50,6 @@
<dl class="alt-style">
<dt>Name</dt>
<dd>{{object.name}}&nbsp;</dd>
<dt>Homepage</dt>
<dd>{{object.homepage}}&nbsp;</dd>
<dt>Type</dt>
<dd>{{object.kind|capfirst}}&nbsp;</dd>
<dt>Issue date:</dt>
......
......@@ -64,6 +64,8 @@ urlpatterns = patterns('astakos.im.views',
'group_list', {}, name='group_list'),
url(r'^group/(?P<group_id>\d+)/?$', 'group_detail', {},
name='group_detail'),
url(r'^group/update/(?P<group_id>\d+)/?$',
'group_update', {}, name='group_update'),
url(r'^group/search/?$',
'group_search', {}, name='group_search'),
url(
......
......@@ -56,21 +56,24 @@ from django.views.generic.create_update import (create_object, delete_object,
get_model_and_form_class
)
from django.views.generic.list_detail import object_list, object_detail
from django.http import HttpResponseBadRequest
from astakos.im.models import (
AstakosUser, ApprovalTerms, AstakosGroup, Resource,
EmailChange, GroupKind, Membership)
from astakos.im.activation_backends import get_backend, SimpleBackend
from astakos.im.util import get_context, prepare_response, set_cookie, get_query
from astakos.im.forms import (
LoginForm, InvitationForm, ProfileForm, FeedbackForm,
SignApprovalTermsForm, ExtendedPasswordChangeForm, EmailChangeForm,
AstakosGroupCreationForm, AstakosGroupSearchForm
)
from astakos.im.forms import (LoginForm, InvitationForm, ProfileForm,
FeedbackForm, SignApprovalTermsForm,
ExtendedPasswordChangeForm, EmailChangeForm,
AstakosGroupCreationForm, AstakosGroupSearchForm,
AstakosGroupUpdateForm)
from astakos.im.functions import (send_feedback, SendMailError,
invite as invite_func, logout as auth_logout, activate as activate_func,
switch_account_to_shibboleth, send_admin_notification, SendNotificationError
)
invite as invite_func, logout as auth_logout,
activate as activate_func,
switch_account_to_shibboleth,
send_admin_notification,
SendNotificationError)
from astakos.im.settings import (
COOKIE_NAME, COOKIE_DOMAIN, SITENAME, LOGOUT_NEXT,
LOGGING_LEVEL
......@@ -80,7 +83,8 @@ from astakos.im.tasks import request_billing
logger = logging.getLogger(__name__)
def render_response(template, tab=None, status=200, reset_cookie=False, context_instance=None, **kwargs):
def render_response(template, tab=None, status=200, reset_cookie=False,
context_instance=None, **kwargs):
"""
Calls ``django.template.loader.render_to_string`` with an additional ``tab``
keyword argument and returns an ``django.http.HttpResponse`` with the
......@@ -723,13 +727,26 @@ def group_detail(request, group_id):
group = AstakosGroup.objects.select_related().get(id=group_id)
except AstakosGroup.DoesNotExist:
return HttpResponseBadRequest(_('Invalid group.'))
form = AstakosGroupUpdateForm(instance=group)
return object_detail(request,
AstakosGroup.objects.all(),
object_id=group_id,
extra_context={'quota': group.quota}
extra_context={'quota': group.quota,
'form': form}
)
def group_update(request, group_id):
if request.method != 'POST':
return HttpResponseBadRequest('Method not allowed.')
try:
group = AstakosGroup.objects.select_related().get(id=group_id)
except AstakosGroup.DoesNotExist:
return HttpResponseBadRequest(_('Invalid group.'))
form = AstakosGroupUpdateForm(request.POST, instance=group)
if form.is_valid():
form.save()
return group_detail(request, group_id)
@signed_terms_required
@login_required
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment