Commit 7e490c7c authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

named reverse urls

parent f1beb8d3
......@@ -161,27 +161,24 @@ def get_menu(request, with_extra_links=False, with_signout=True):
pass
else:
l = []
l.append({ 'url': absolute(reverse('astakos.im.views.index')),
'name': user.email})
l.append({ 'url': absolute(reverse('astakos.im.views.edit_profile')),
'name': "My account" })
l.append(dict(url=absolute(reverse('index')), name=user.email))
l.append(dict(url=absolute(reverse('edit_profile')), name="My account"))
if with_extra_links:
if user.has_usable_password() and user.provider == 'local':
l.append({ 'url': absolute(reverse('password_change')),
'name': "Change password" })
l.append(dict(url=absolute(reverse('password_change')), name="Change password"))
if EMAILCHANGE_ENABLED:
l.append({'url':absolute(reverse('email_change')),
'name': "Change email"})
l.append(dict(url=absolute(reverse('email_change')), name="Change email"))
if INVITATIONS_ENABLED:
l.append({ 'url': absolute(reverse('astakos.im.views.invite')),
'name': "Invitations" })
l.append({ 'url': absolute(reverse('astakos.im.views.feedback')),
'name': "Feedback" })
l.append({ 'url': absolute(reverse('group_add')),
'name': "Add group" })
l.append(dict(url=absolute(reverse('invite')), name="Invitations"))
l.append(dict(url=absolute(reverse('feedback')), name="Feedback"))
if request.user.has_perm('im.add_astakosgroup'):
l.append(dict(url=absolute(reverse('group_add')), name="Add group"))
url = absolute(reverse('group_list'))
l.append(dict(url=url, name="Subscribed groups"))
url = '%s?relation=owner' % url
l.append(dict(url=url, name="My groups"))
if with_signout:
l.append({ 'url': absolute(reverse('astakos.im.views.logout')),
'name': "Sign out"})
l.append(dict(url=absolute(reverse('logout')), name="Sign out"))
callback = request.GET.get('callback', None)
data = json.dumps(tuple(l))
......
......@@ -81,9 +81,9 @@ def send_verification(user, template_name='im/activation_email.txt'):
Raises SendVerificationError
"""
url = '%s?auth=%s&next=%s' % (urljoin(BASEURL, reverse('astakos.im.views.activate')),
url = '%s?auth=%s&next=%s' % (urljoin(BASEURL, reverse('activate')),
quote(user.auth_token),
quote(urljoin(BASEURL, reverse('astakos.im.views.index'))))
quote(urljoin(BASEURL, reverse('index'))))
message = render_to_string(template_name, {
'user': user,
'url': url,
......@@ -158,7 +158,7 @@ def send_invitation(invitation, template_name='im/invitation.txt'):
Raises SendInvitationError
"""
subject = _('Invitation to %s alpha2 testing' % SITENAME)
url = '%s?code=%d' % (urljoin(BASEURL, reverse('astakos.im.views.index')), invitation.code)
url = '%s?code=%d' % (urljoin(BASEURL, reverse('index')), invitation.code)
message = render_to_string('im/invitation.txt', {
'invitation': invitation,
'url': url,
......@@ -184,7 +184,7 @@ def send_greeting(user, email_template_name='im/welcome_email.txt'):
subject = _('Welcome to %s alpha2 testing' % SITENAME)
message = render_to_string(email_template_name, {
'user': user,
'url': urljoin(BASEURL, reverse('astakos.im.views.index')),
'url': urljoin(BASEURL, reverse('index')),
'baseurl': BASEURL,
'site_name': SITENAME,
'support': DEFAULT_CONTACT_EMAIL})
......
......@@ -118,7 +118,7 @@ def login(request):
next = urlunsplit(parts)
# build url location
parts[2] = reverse('astakos.im.views.index')
parts[2] = reverse('index')
params = {'next':next}
parts[3] = urlencode(params)
url = urlunsplit(parts)
......
......@@ -18,7 +18,7 @@
{% block page.quicknav.items %}
<li class="{% block signup_class %}{% endblock %}">
<a href="{% url astakos.im.views.logout %}">LOGOUT</a>
<a href="{% url logout %}">LOGOUT</a>
</li>
{% endblock %}
......
{% extends "im/account_base.html" %}
{% block body %}
<form action="{% url astakos.im.views.feedback %}" method="post"
<form action="{% url feedback %}" method="post"
class="withlabels">{% csrf_token %}
{% with feedback_form as form %}
......
......@@ -31,7 +31,7 @@
<div class="rightcol">
{% if inviter.invitations %}
<form action="{% url astakos.im.views.invite %}" method="post"
<form action="{% url invite %}" method="post"
class="innerlabels">{% csrf_token %}
<h2>INVITE SOMEONE ELSE</h2>
{% with invitation_form as form %}
......
......@@ -59,7 +59,7 @@ Login
{% endfor %}
<div class="bottom">
{% block body.login.signup %}
new to okeanos ? <a href="{% url astakos.im.views.signup %}{% ifnotequal code "" %}?code={{ code|urlencode }}{% endifnotequal %}">CREATE ACCOUNT</a>
new to okeanos ? <a href="{% url signup %}{% ifnotequal code "" %}?code={{ code|urlencode }}{% endifnotequal %}">CREATE ACCOUNT</a>
{% endblock %}
</div>
</div>
......
......@@ -2,7 +2,7 @@
{% block body %}
<form action={%url astakos.im.views.edit_profile %} method="post"
<form action={%url edit_profile %} method="post"
class="withlabels">{% csrf_token %}
{% with profile_form as form %}
......
......@@ -5,7 +5,7 @@
{% endblock title%}
{% block body %}
<form action={%url astakos.im.views.register%} method="post">{% csrf_token %}
<form action={%url register%} method="post">{% csrf_token %}
{{ form.as_p }}
<div>
<button type="submit" class="btn primary">Register</button>
......
......@@ -25,7 +25,7 @@
{% block body.right %}
{% if "local" in im_modules %}
<div class="form-stacked">
<form action="{% url astakos.im.views.signup %}" method="post"
<form action="{% url signup %}" method="post"
class="innerlabels signup">{% csrf_token %}
<h2><span>SIGN UP</span></h2>
<input type="hidden" name="next" value="{{ next }}">
......
......@@ -10,7 +10,7 @@
</div>
<div class="section">
<form action="{% url astakos.im.views.signup %}" method="post" class="login innerlabels">{% csrf_token %}
<form action="{% url signup %}" method="post" class="login innerlabels">{% csrf_token %}
{% with thirdparty_signup_form as form %}
{% include "im/form_render.html" %}
{% endwith %}
......
......@@ -15,7 +15,7 @@
{% block body.right %}
{% if "local" in im_modules %}
<div class="form-stacked">
<form action="{% url astakos.im.views.signup %}" method="post"
<form action="{% url signup %}" method="post"
class="innerlabels signup">{% csrf_token %}
<h2><span>Provide an email address to complete the registration:</span></h2>
<input type="hidden" name="next" value="{{ next }}">
......
{% extends "im/account_base.html" %}
{% block body %}
<form action="{% url astakos.im.views.change_email %}" method="post"
<form action="{% url email_change %}" method="post"
class="withlabels">{% csrf_token %}
{% include "im/form_render.html" %}
......
......@@ -3,6 +3,6 @@
{%block page.title %}Logout{% endblock %}
{% block body %}
<div class="section">
<h2>You have successfully logged out. <a href="{% url astakos.im.views.index %}">Login</a>.</h2>
<h2>You have successfully logged out. <a href="{% url index %}">Login</a>.</h2>
</div>
{% endblock %}
......@@ -41,16 +41,16 @@ from astakos.im.settings import IM_MODULES, INVITATIONS_ENABLED, EMAILCHANGE_ENA
urlpatterns = patterns('astakos.im.views',
url(r'^$', 'index', {}, name='index'),
url(r'^login/?$', 'index', {}, name='login'),
url(r'^profile/?$', 'edit_profile'),
url(r'^feedback/?$', 'feedback'),
url(r'^signup/?$', 'signup', {'on_success':'im/login.html', 'extra_context':{'login_form':LoginForm()}}),
url(r'^logout/?$', 'logout', {'template':'im/login.html', 'extra_context':{'login_form':LoginForm()}}),
url(r'^activate/?$', 'activate'),
url(r'^profile/?$', 'edit_profile', {}, name='edit_profile'),
url(r'^feedback/?$', 'feedback', {}, name='feedback'),
url(r'^signup/?$', 'signup', {'on_success':'im/login.html', 'extra_context':{'login_form':LoginForm()}}, name='signup'),
url(r'^logout/?$', 'logout', {'template':'im/login.html', 'extra_context':{'login_form':LoginForm()}}, name='logout'),
url(r'^activate/?$', 'activate', {}, name='activate'),
url(r'^approval_terms/?$', 'approval_terms', {}, name='latest_terms'),
url(r'^approval_terms/(?P<term_id>\d+)/?$', 'approval_terms'),
url(r'^password/?$', 'change_password', {}, name='password_change'),
url(r'^group/add/?$', 'group_add', {}, name='group_add'),
url(r'^group/list?$', 'user_group_list', {}, name='user_group_list'),
url(r'^group/list/?$', 'group_list', {}, name='group_list'),
url(r'^group/(?P<group_id>\d+)/?$', 'group_detail', {}, name='group_detail'),
url(r'^group/(?P<group_id>\d+)/policies/list/?$', 'group_policies_list', {}, name='group_policies_list'),
url(r'^group/(?P<group_id>\d+)/policies/add/?$', 'group_policies_add', {}, name='group_policies_add'),
......@@ -86,7 +86,7 @@ if 'local' in IM_MODULES:
if INVITATIONS_ENABLED:
urlpatterns += patterns('astakos.im.views',
url(r'^invite/?$', 'invite')
url(r'^invite/?$', 'invite', {}, name='invite')
)
if 'shibboleth' in IM_MODULES:
......
......@@ -119,7 +119,7 @@ def prepare_response(request, user, next='', renew=False):
params = ''
if next:
params = '?' + urlencode({'next': next})
next = reverse('astakos.im.views.edit_profile') + params
next = reverse('edit_profile') + params
response = HttpResponse()
......@@ -130,7 +130,7 @@ def prepare_response(request, user, next='', renew=False):
request.session.set_expiry(user.auth_token_expires)
if not next:
next = reverse('astakos.im.views.index')
next = reverse('index')
response['Location'] = next
response.status_code = 302
......
......@@ -138,7 +138,7 @@ def index(request, login_template_name='im/login.html', profile_template_name='i
"""
template_name = login_template_name
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('astakos.im.views.edit_profile'))
return HttpResponseRedirect(reverse('edit_profile'))
return render_response(template_name,
login_form = LoginForm(request=request),
context_instance = get_context(request, extra_context))
......@@ -315,7 +315,7 @@ def signup(request, template_name='im/signup.html', on_success='im/signup_comple
im/signup_complete.html or ``on_success`` keyword argument.
"""
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('astakos.im.views.edit_profile'))
return HttpResponseRedirect(reverse('edit_profile'))
provider = get_query(request).get('provider', 'local')
try:
......@@ -512,14 +512,14 @@ def approval_terms(request, term_id=None, template_name='im/approval_terms.html'
pass
if not term:
return HttpResponseRedirect(reverse('astakos.im.views.index'))
return HttpResponseRedirect(reverse('index'))
f = open(term.location, 'r')
terms = f.read()
if request.method == 'POST':
next = request.POST.get('next')
if not next:
next = reverse('astakos.im.views.index')
next = reverse('index')
form = SignApprovalTermsForm(request.POST, instance=request.user)
if not form.is_valid():
return render_response(template_name,
......@@ -540,7 +540,7 @@ def approval_terms(request, term_id=None, template_name='im/approval_terms.html'
@signed_terms_required
def change_password(request):
return password_change(request,
post_change_redirect=reverse('astakos.im.views.edit_profile'),
post_change_redirect=reverse('edit_profile'),
password_change_form=ExtendedPasswordChangeForm)
@signed_terms_required
......@@ -570,7 +570,7 @@ def change_email(request, activation_key=None,
if not request.user.is_authenticated():
path = quote(request.get_full_path())
url = request.build_absolute_uri(reverse('astakos.im.views.index'))
url = request.build_absolute_uri(reverse('index'))
return HttpResponseRedirect(url + '?next=' + path)
form = EmailChangeForm(request.POST or None)
if request.method == 'POST' and form.is_valid():
......@@ -619,7 +619,7 @@ def group_detail(request, group_id):
try:
group = AstakosGroup.objects.select_related().get(id=group_id)
except AstakosGroup.DoesNotExist:
raise HttpResponseBadRequest(_('Invalid group.'))
return HttpResponseBadRequest(_('Invalid group.'))
d = {}
for resource in group.policy.all():
d[resource.name] = group.policy.through.objects.get(resource__id=resource.id,
......
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