Revision f534fb96

b/snf-astakos-app/astakos/im/api.py
117 117
    return HttpResponse(content=data, mimetype=mimetype)
118 118

  
119 119
def get_menu(request):
120
    if request.method != 'GET':
121
        raise BadRequest('Method not allowed.')
122 120
    location = request.GET.get('location', '')
123 121
    exclude = []
124 122
    index_url = reverse('index')
......
135 133
    l = [{ 'url': absolute(index_url), 'name': "Sign in"}]
136 134
    if request.user.is_authenticated():
137 135
        l = []
138
        l.append({ 'url': absolute(reverse('astakos.im.views.edit_profile')),
136
        l.append({ 'url': absolute(reverse('astakos.im.views.index')),
139 137
                  'name': request.user.email})
140 138
        l.append({ 'url': absolute(reverse('astakos.im.views.edit_profile')),
141 139
                  'name': "View your profile" })
b/snf-astakos-app/astakos/im/context_processors.py
33 33

  
34 34
from astakos.im.settings import IM_MODULES, INVITATIONS_ENABLED, IM_STATIC_URL, \
35 35
        COOKIE_NAME
36
from astakos.im.api import get_menu
37

  
36 38
from django.conf import settings
37 39
from django.core.urlresolvers import reverse
40
from django.utils import simplejson as json
38 41

  
39 42
def im_modules(request):
40 43
    return {'im_modules': IM_MODULES}
......
66 69
            'ACTIVE_SERVICE': CB_ACTIVE_SERVICE,
67 70
            'GET_SERVICES_URL': absolute(reverse('astakos.im.api.get_services')),
68 71
            'GET_MENU_URL': absolute(reverse('astakos.im.api.get_menu'))}
72

  
73
def menu(request):
74
    absolute = lambda (url): request.build_absolute_uri(url)
75
    resp = get_menu(request)
76
    menu_items = json.loads(resp.content)[1:]
77
    for item in menu_items:
78
        item['is_active'] = absolute(request.path) == item['url']
79
    return {'menu':menu_items}
b/snf-astakos-app/astakos/im/synnefo_settings.py
54 54
    'astakos.im.context_processors.next',
55 55
    'astakos.im.context_processors.code',
56 56
    'astakos.im.context_processors.invitations',
57
    'astakos.im.context_processors.menu',
57 58
    'synnefo.lib.context_processors.cloudbar'
58 59
]
59 60

  
b/snf-astakos-app/astakos/im/templates/im/account_base.html
1 1
{% extends "im/base_two_cols.html" %}
2 2

  
3
{% load filters %}
4

  
3 5
{% block page.title %}Profile{% endblock %}
4 6
{% block page.nav.classes %}{% endblock %}
5 7

  
......
10 12
{% endblock %}
11 13

  
12 14
{% block page.nav.items %}
13
    <li class="{% if tab == "im/profile" %}active{% endif %}">
14
        <a href="{% url astakos.im.views.edit_profile %}">Profile</a>
15
    </li>
16
    <li class="{% if not tab %}active{% endif %}">
17
        <a href="{% url django.contrib.auth.views.password_change %}">Change password</a>
18
    </li>
19
    {% if invitations_enabled %}
20
    <li class="{% if tab == "im/invitations" %}active{% endif %}">
21
        <a href="{% url astakos.im.views.invite %}">Invitations</a>
22
    </li>
23
    {% endif %}
24
    <li class="{% if tab == "im/feedback" %}active{% endif %}">
25
        <a href="{% url astakos.im.views.send_feedback %}">Send feedback</a>
26
    </li>
15
    {% for item in menu%}
16
        <li class="{% if item|lookup:"is_active" %}active{% endif %}">
17
            <a href="{{ item|lookup:"url" }}">{{ item|lookup:"name" }}</a>
18
        </li>
19
    {% endfor %}
27 20
{% endblock %}
28 21
    
29 22
{% block page.body %}
b/snf-astakos-app/astakos/im/templatetags/filters.py
1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33

  
34
from django import template
35

  
36
register = template.Library()
37

  
38
@register.filter
39
def lookup(d, key):
40
    return d[key]
b/snf-astakos-app/astakos/im/views.py
117 117
    formclass = 'LoginForm'
118 118
    kwargs = {}
119 119
    if request.user.is_authenticated():
120
        template_name = profile_template_name
121
        formclass = 'ProfileForm'
122
        kwargs.update({'instance':request.user})
120
        return HttpResponseRedirect(reverse('astakos.im.views.edit_profile'))
123 121
    return render_response(template_name,
124 122
                           form = globals()[formclass](**kwargs),
125 123
                           context_instance = get_context(request, extra_context))
b/snf-astakos-app/conf/20-snf-astakos-app-cloudbar.conf
1 1
CLOUDBAR_ACTIVE = True
2
CLOUDBAR_LOCATION = '/static/im/cloudbar'
2
CLOUDBAR_LOCATION = '/static/im/cloudbar/'
3 3
CLOUDBAR_COOKIE_NAME = '_pithos2_a'
4 4
CLOUDBAR_ACTIVE_SERVICE = 'cloud'
5 5
CLOUDBAR_SERVICES_URL = '/im/get_services'
b/snf-astakos-app/setup.py
77 77
INSTALL_REQUIRES = [
78 78
    'Django>=1.2, <1.3',
79 79
    'South>=0.7, <=0.7.3',
80
    'httplib2==0.6.0',
80
    'httplib2>=0.6.0',
81 81
    'snf-common>=0.9.0',
82 82
    'recaptcha-client>=1.0.5'
83 83
]

Also available in: Unified diff