Revision dcf55476

/dev/null
1
{% extends 'base.html'%}
2

  
3
{% block title%}
4
        <h2>Welcome</h2>
5
        <p>Choose how to login. Or move on to <a href="admin">admin</a>.</p>
6
        <p>Don't have an account? <a href="{% url astakos.im.views.signup %}">Sign up</a>.</p>
7
{% endblock title%}
8
    
9
{% block body%}
10
    <div class="row">
11
    {% if "local" in im_modules %}
12
      <div class="span4">
13
        <h4>Local account</h4>
14
        <form action="{% url astakos.im.target.local.login %}" method="post" class="form-stacked">{% csrf_token %}
15
          {{ form.as_p }}
16
         <div>
17
            <a href="{% url django.contrib.auth.views.password_reset %}">Forgot your password?</a>
18
         </div>
19
         <br>
20
          <div class="">
21
            <input type="hidden" name="next" value="{{ next }}">
22
            <button type="submit" class="btn primary">Go</button>
23
          </div>
24
        </form>
25
      </div>
26
    {% endif %}
27
      <div class="span8">
28
        {% for o in im_modules %}
29
            {% if o != 'local' %}
30
                <a href="/im/login/{{ o }}{% ifnotequal next "" %}?next={{ next|urlencode }}{% endifnotequal %}" alt="{{ o|title }}"><img src="/im/static/{{ o }}.png" width="120" height="120"></a>
31
            {% endif %}
32
        {% endfor %}
33
      </div>
34
    </div>
35
{% endblock body%}
b/astakos/im/templates/login.html
1
{% extends 'base.html'%}
2

  
3
{% block title%}
4
        <h2>Welcome</h2>
5
        <p>Choose how to login. Or move on to <a href="admin">admin</a>.</p>
6
        <p>Don't have an account? <a href="{% url astakos.im.views.signup %}">Sign up</a>.</p>
7
{% endblock title%}
8
    
9
{% block body%}
10
    <div class="row">
11
    {% if "local" in im_modules %}
12
      <div class="span4">
13
        <h4>Local account</h4>
14
        <form action="{% url astakos.im.target.local.login %}" method="post" class="form-stacked">{% csrf_token %}
15
          {{ form.as_p }}
16
         <div>
17
            <a href="{% url django.contrib.auth.views.password_reset %}">Forgot your password?</a>
18
         </div>
19
         <br>
20
          <div class="">
21
            <input type="hidden" name="next" value="{{ next }}">
22
            <button type="submit" class="btn primary">Go</button>
23
          </div>
24
        </form>
25
      </div>
26
    {% endif %}
27
      <div class="span8">
28
        {% for o in im_modules %}
29
            {% if o != 'local' %}
30
                <a href="/im/login/{{ o }}{% ifnotequal next "" %}?next={{ next|urlencode }}{% endifnotequal %}" alt="{{ o|title }}"><img src="/im/static/{{ o }}.png" width="120" height="120"></a>
31
            {% endif %}
32
        {% endfor %}
33
      </div>
34
    </div>
35
{% endblock body%}
b/astakos/im/views.py
79 79
    html = render_to_string(template, kwargs, context_instance=context_instance)
80 80
    return HttpResponse(html, status=status)
81 81

  
82
def index(request, template_name='index.html', extra_context={}):
82
def index(request, login_template_name='login.html', profile_template_name='profile.html', extra_context={}):
83 83
    """
84
    Renders the index (login) page
84
    If there is logged on user renders the profile page otherwise renders login page.
85 85
    
86 86
    **Arguments**
87 87
    
88
    ``template_name``
89
        A custom template to use. This is optional; if not specified,
90
        this will default to ``index.html``.
88
    ``login_template_name``
89
        A custom login template to use. This is optional; if not specified,
90
        this will default to ``login.html``.
91
    
92
    ``profile_template_name``
93
        A custom profile template to use. This is optional; if not specified,
94
        this will default to ``login.html``.
91 95
    
92 96
    ``extra_context``
93 97
        An dictionary of variables to add to the template context.
......
97 101
    index.html or ``template_name`` keyword argument.
98 102
    
99 103
    """
104
    template_name = login_template_name
105
    formclass = 'LoginForm'
106
    kwargs = {}
107
    if request.user.is_authenticated():
108
        template_name = profile_template_name
109
        formclass = 'ProfileForm'
110
        kwargs.update({'instance':request.user})
100 111
    return render_response(template_name,
101
                           form = LoginForm(),
112
                           form = globals()[formclass](**kwargs),
102 113
                           context_instance = get_context(request, extra_context))
103 114

  
104 115
def _generate_invitation_code():

Also available in: Unified diff