From: Radek Czajka Date: Tue, 19 Mar 2013 15:36:08 +0000 (+0100) Subject: Move to Django 1.5, some styling changes. X-Git-Url: https://git.mdrn.pl/cas.git/commitdiff_plain/2c9debf2812dfbd4ff59348559ae57cd49858e8b?ds=sidebyside Move to Django 1.5, some styling changes. --- diff --git a/.gitignore b/.gitignore index 951b9a9..f1e760b 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc *.sqlite +localsettings.py diff --git a/provider/AUTHORS.txt b/provider/AUTHORS.txt deleted file mode 100644 index c5710e7..0000000 --- a/provider/AUTHORS.txt +++ /dev/null @@ -1,2 +0,0 @@ -Chris Williams -Marek Stepniowski diff --git a/provider/LICENSE b/provider/LICENSE deleted file mode 100644 index ec58004..0000000 --- a/provider/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2009, Chris Williams -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the author nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/provider/MANIFEST.in b/provider/MANIFEST.in deleted file mode 100644 index 0dc3951..0000000 --- a/provider/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -recursive-include cas_provider/templates *.html -include README.rst -include LICENSE \ No newline at end of file diff --git a/provider/README.rst b/provider/README.rst deleted file mode 100644 index d197fbe..0000000 --- a/provider/README.rst +++ /dev/null @@ -1,26 +0,0 @@ -=================== -django-cas-provider -=================== - -OVERVIEW -========= - -django-cas-provider is a provider for the `Central Authentication Service `_. It supports CAS version 1.0 and parts of CAS version 2.0 protocol. It allows remote services to authenticate users for the purposes of Single Sign-On (SSO). For example, a user logs into a CAS server -(provided by django-cas-provider) and can then access other services (such as email, calendar, etc) without re-entering her password for each service. For more details, see the `CAS wiki `_ and `Single Sign-On on Wikipedia `_. - -INSTALLATION -============= - -To install, run the following command from this directory:: - - python setup.py install - -Or, put `cas_provider` somewhere on your Python path. - -USAGE -====== - -#. Add ``'cas_provider'`` to your ``INSTALLED_APPS`` tuple in *settings.py*. -#. In *settings.py*, set ``LOGIN_URL`` to ``'/cas/login/'`` and ``LOGOUT_URL`` to ``'/cas/logout/'`` -#. In *urls.py*, put the following line: ``(r'^cas/', include('cas_provider.urls')),`` -#. Create login/logout templates (or modify the samples) diff --git a/provider/cas_provider/__init__.py b/provider/cas_provider/__init__.py deleted file mode 100644 index b70697c..0000000 --- a/provider/cas_provider/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.conf import settings - -__all__ = [] - -_DEFAULTS = { - 'CAS_TICKET_EXPIRATION': 5, # In minutes - 'CAS_CUSTOM_ATTRIBUTES_CALLBACK': None, -} - -for key, value in _DEFAULTS.iteritems(): - try: - getattr(settings, key) - except AttributeError: - setattr(settings, key, value) - except ImportError: - pass \ No newline at end of file diff --git a/provider/cas_provider/admin.py b/provider/cas_provider/admin.py deleted file mode 100644 index 5934487..0000000 --- a/provider/cas_provider/admin.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.contrib import admin - -from cas_provider.models import ServiceTicket, LoginTicket - -class ServiceTicketAdmin(admin.ModelAdmin): - pass -admin.site.register(ServiceTicket, ServiceTicketAdmin) - -class LoginTicketAdmin(admin.ModelAdmin): - pass -admin.site.register(LoginTicket, LoginTicketAdmin) \ No newline at end of file diff --git a/provider/cas_provider/etree.py b/provider/cas_provider/etree.py deleted file mode 100644 index 9f992b8..0000000 --- a/provider/cas_provider/etree.py +++ /dev/null @@ -1,16 +0,0 @@ -# lxml http://codespeak.net/lxml/ -from lxml import etree - -# Define register_namespace function and ElementRoot for proper serialization -NSMAP = {} - - -def register_namespace(prefix, uri): - NSMAP[prefix] = uri - - -def ElementRoot(*args, **kwargs): - kwargs['nsmap'] = NSMAP - return etree.Element(*args, **kwargs) - -__all__ = ('etree', 'register_namespace', 'ElementRoot') diff --git a/provider/cas_provider/forms.py b/provider/cas_provider/forms.py deleted file mode 100644 index ba77b62..0000000 --- a/provider/cas_provider/forms.py +++ /dev/null @@ -1,16 +0,0 @@ -from django import forms -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.auth import authenticate - -from cas_provider.utils import create_login_ticket - -class LoginForm(forms.Form): - username = forms.CharField(max_length=30) - password = forms.CharField(widget=forms.PasswordInput) - #warn = forms.BooleanField(required=False) # TODO: Implement - lt = forms.CharField(widget=forms.HiddenInput, initial=create_login_ticket) - def __init__(self, service=None, renew=None, gateway=None, request=None, *args, **kwargs): - super(LoginForm, self).__init__(*args, **kwargs) - self.request = request - if service is not None: - self.fields['service'] = forms.CharField(widget=forms.HiddenInput, initial=service) \ No newline at end of file diff --git a/provider/cas_provider/management/__init__.py b/provider/cas_provider/management/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/provider/cas_provider/management/commands/__init__.py b/provider/cas_provider/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/provider/cas_provider/management/commands/cleanuptickets.py b/provider/cas_provider/management/commands/cleanuptickets.py deleted file mode 100644 index 772fdcb..0000000 --- a/provider/cas_provider/management/commands/cleanuptickets.py +++ /dev/null @@ -1,39 +0,0 @@ -""" -A management command which deletes expired service tickets (e.g., -from the database. - -Calls ``ServiceTickets.objects.delete_expired_users()``, which -contains the actual logic for determining which accounts are deleted. - -""" - -from django.core.management.base import NoArgsCommand -from django.core.management.base import CommandError -from django.conf import settings - -import datetime - -from cas_provider.models import ServiceTicket, LoginTicket - -class Command(NoArgsCommand): - help = "Delete expired service tickets from the database" - - def handle_noargs(self, **options): - print "Service tickets:" - tickets = ServiceTicket.objects.all() - for ticket in tickets: - expiration = datetime.timedelta(minutes=settings.CAS_TICKET_EXPIRATION) - if datetime.datetime.now() > ticket.created + expiration: - print "Deleting %s..." % ticket.ticket - ticket.delete() - else: - print "%s not expired..." % ticket.ticket - tickets = LoginTicket.objects.all() - print "Login tickets:" - for ticket in tickets: - expiration = datetime.timedelta(minutes=settings.CAS_TICKET_EXPIRATION) - if datetime.datetime.now() > ticket.created + expiration: - print "Deleting %s..." % ticket.ticket - ticket.delete() - else: - print "%s not expired..." % ticket.ticket \ No newline at end of file diff --git a/provider/cas_provider/models.py b/provider/cas_provider/models.py deleted file mode 100644 index 6e7ebaf..0000000 --- a/provider/cas_provider/models.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.db import models -from django.contrib.auth.models import User -from django.conf import settings -from django.core.urlresolvers import get_callable - -from cas_provider.etree import etree, register_namespace, ElementRoot - -class ServiceTicket(models.Model): - user = models.ForeignKey(User) - service = models.URLField(verify_exists=False) - ticket = models.CharField(max_length=256) - created = models.DateTimeField(auto_now=True) - - def __unicode__(self): - return "%s (%s) - %s" % (self.user.username, self.service, self.created) - -class LoginTicket(models.Model): - ticket = models.CharField(max_length=32) - created = models.DateTimeField(auto_now=True) - - def __unicode__(self): - return "%s - %s" % (self.ticket, self.created) - -CAS_URI = 'http://www.yale.edu/tp/cas' -register_namespace('cas', CAS_URI) -CAS = '{%s}' % CAS_URI - -def auth_success_response(user): - attrs = {} - if settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK: - callback = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK) - attrs = callback(user) - - response = ElementRoot(CAS + 'serviceResponse') - auth_success = etree.SubElement(response, CAS + 'authenticationSuccess') - username = etree.SubElement(auth_success, CAS + 'user') - username.text = user.username - for name, value in attrs.items(): - element = etree.SubElement(auth_success, name) - element.text = value - return unicode(etree.tostring(response, encoding='utf-8'), 'utf-8') diff --git a/provider/cas_provider/templates/cas/login.html b/provider/cas_provider/templates/cas/login.html deleted file mode 100644 index 42b5708..0000000 --- a/provider/cas_provider/templates/cas/login.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base.html" %} - -{% block title %} -Login -{% endblock %} - -{% block content %} -
-
- Log in to your account - {% if errors %} -
    - {% for error in errors %} -
  • {{ error|escape }}
  • - {% endfor %} -
- {% endif %} - - {{ form.as_table }} -
-

-
-
-{% endblock %} diff --git a/provider/cas_provider/templates/cas/logout.html b/provider/cas_provider/templates/cas/logout.html deleted file mode 100644 index e5e435f..0000000 --- a/provider/cas_provider/templates/cas/logout.html +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "base.html" %} - -{% block title %} -Logged out -{% endblock %} - -{% block content %} -

Logged out

- -

You have successfully logged out. To ensure that you are logged out of all services, please close your browser.

- {% if url %}

Click here to return to {{ url }}

{% endif %} -{% endblock %} diff --git a/provider/cas_provider/urls.py b/provider/cas_provider/urls.py deleted file mode 100644 index 2b53f31..0000000 --- a/provider/cas_provider/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.conf.urls.defaults import * - -from cas_provider.views import * - -urlpatterns = patterns('', - url(r'^login/?$', login, name='cas_login'), - url(r'^validate/?$', validate), - url(r'^serviceValidate/?$', service_validate), - url(r'^logout/?$', logout), -) diff --git a/provider/cas_provider/utils.py b/provider/cas_provider/utils.py deleted file mode 100644 index 68b791c..0000000 --- a/provider/cas_provider/utils.py +++ /dev/null @@ -1,24 +0,0 @@ -from random import Random -import string - -from cas_provider.models import ServiceTicket, LoginTicket - -def _generate_string(length=8, chars=string.ascii_letters + string.digits): - """ Generates a random string of the requested length. Used for creation of tickets. """ - return ''.join(Random().sample(chars, length)) - -def create_service_ticket(user, service): - """ Creates a new service ticket for the specified user and service. - Uses _generate_string. - """ - ticket_string = 'ST-' + _generate_string(29) # Total ticket length = 29 + 3 = 32 - ticket = ServiceTicket(service=service, user=user, ticket=ticket_string) - ticket.save() - return ticket - -def create_login_ticket(): - """ Creates a new login ticket for the login form. Uses _generate_string. """ - ticket_string = 'LT-' + _generate_string(29) - ticket = LoginTicket(ticket=ticket_string) - ticket.save() - return ticket_string \ No newline at end of file diff --git a/provider/cas_provider/views.py b/provider/cas_provider/views.py deleted file mode 100644 index 3a9ab5a..0000000 --- a/provider/cas_provider/views.py +++ /dev/null @@ -1,120 +0,0 @@ -from django.http import HttpResponse, HttpResponseForbidden, HttpResponseRedirect -from django.shortcuts import render_to_response -from django.template import RequestContext -from django.contrib.auth.models import User -from django.contrib.auth import authenticate -from django.contrib.auth import login as auth_login, logout as auth_logout -from django.utils.encoding import smart_str -from django.utils.translation import ugettext_lazy as _ - -from cas_provider.forms import LoginForm -from cas_provider.models import ServiceTicket, LoginTicket, auth_success_response -from cas_provider.utils import create_service_ticket - -import urlparse, urllib - -try: - from urlparse import parse_qs as url_parse_qs -except ImportError: - from cgi import parse_qs as url_parse_qs - -import logging -logger = logging.getLogger("cas.provider") - -__all__ = ['login', 'validate', 'service_validate', 'logout'] - -def _add_query_param(url, param, value): - parsed = urlparse.urlparse(url) - query = url_parse_qs(smart_str(parsed.query)) - query[param] = [unicode(value, 'utf-8')] - query = [ ((k, v) if len(v) != 1 else (k, v[0])) for k, v in query.iteritems() ] - parsed = urlparse.ParseResult(parsed.scheme, parsed.netloc, - parsed.path, parsed.params, - urllib.urlencode(query), parsed.fragment) - return parsed.geturl() - - -def login(request, template_name='cas/login.html', success_redirect='/accounts/'): - service = request.GET.get('service', None) - - if request.user.is_authenticated(): - if service is not None: - ticket = create_service_ticket(request.user, service) - target = _add_query_param(service, 'ticket', ticket.ticket) - logger.info("Redirecting to %s", target) - return HttpResponseRedirect(target) - else: - logger.info("Redirecting to default: %s", success_redirect) - return HttpResponseRedirect(success_redirect) - - errors = [] - if request.method == 'POST': - username = request.POST.get('username', None) - password = request.POST.get('password', None) - service = request.POST.get('service', None) - lt = request.POST.get('lt', None) - - logger.debug("User %s logging in", username) - - try: - login_ticket = LoginTicket.objects.get(ticket=lt) - except: - errors.append(_(u'Login ticket expired. Please try again.')) - else: - login_ticket.delete() - user = authenticate(username=username, password=password) - if user is not None: - if user.is_active: - auth_login(request, user) - if service is not None: - ticket = create_service_ticket(user, service) - target = _add_query_param(service, 'ticket', ticket.ticket) - return HttpResponseRedirect(target) - else: - return HttpResponseRedirect(success_redirect) - else: - errors.append(_(u'This account is disabled.')) - else: - errors.append(_(u'Incorrect username and/or password.')) - - form = LoginForm(service) - return render_to_response(template_name, {'form': form, 'errors': errors}, context_instance=RequestContext(request)) - -def validate(request): - service = request.GET.get('service', None) - ticket_string = request.GET.get('ticket', None) - if service is not None and ticket_string is not None: - try: - ticket = ServiceTicket.objects.get(ticket=ticket_string) - username = ticket.user.username - ticket.delete() - return HttpResponse("yes\n%s\n" % username) - except: - pass - return HttpResponse("no\n\n") - -def service_validate(request): - service = request.GET.get('service', None) - ticket_string = request.GET.get('ticket', None) - if service is None or ticket_string is None: - return HttpResponse(r''' - - Not all required parameters were sent. - - ''', mimetype='application/xml') - - try: - ticket = ServiceTicket.objects.get(ticket=ticket_string) - ticket.delete() - return HttpResponse(auth_success_response(ticket.user), mimetype='text/xml') - except ServiceTicket.DoesNotExist: - return HttpResponse(r''' - - The provided ticket is invalid. - - ''', mimetype='application/xml') - -def logout(request, template_name='cas/logout.html'): - url = request.GET.get('url', None) - auth_logout(request) - return render_to_response(template_name, {'url': url}, context_instance=RequestContext(request)) diff --git a/provider/setup.cfg b/provider/setup.cfg deleted file mode 100644 index debbf50..0000000 --- a/provider/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[egg_info] -tag_build = .dev -tag_date = 1 \ No newline at end of file diff --git a/provider/setup.py b/provider/setup.py deleted file mode 100644 index 8a67235..0000000 --- a/provider/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='django-cas-provider', - version='0.2', - description='A "provider" for the Central Authentication Service (http://jasig.org/cas)', - author='Chris Williams', - author_email='chris@nitron.org', - url='http://nitron.org/', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=['setuptools'], -) diff --git a/requirements.txt b/requirements.txt index bdf2ef8..3101c0e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,6 @@ -Django>=1.1.1,<1.2 -lxml>=2.2 \ No newline at end of file +Django>=1.5,<1.6 +South +lxml>=2.2 +django-gravatar + +-e git+https://github.com/gstrat/django-cas-provider.git@330bf3e9e9b5c3bff6d9258b2fb81a08b7f81e31#egg=django-cas-provider diff --git a/src/accounts/templates/account/profile.html b/src/accounts/templates/account/profile.html index af04370..b80eaac 100644 --- a/src/accounts/templates/account/profile.html +++ b/src/accounts/templates/account/profile.html @@ -3,8 +3,10 @@ {% block content %}
@@ -14,6 +16,7 @@

{% trans "Your profile" %}

+ {% csrf_token %} {{ basic_form.as_table }} @@ -22,6 +25,7 @@

{% trans "Password change" %}

+ {% csrf_token %}
{{ pass_form.as_table }} @@ -30,7 +34,6 @@
-

{% trans "Availble services" %}

diff --git a/src/accounts/templatetags/__init__.py b/src/accounts/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/accounts/templatetags/gravatar.py b/src/accounts/templatetags/gravatar.py deleted file mode 100644 index 789534f..0000000 --- a/src/accounts/templatetags/gravatar.py +++ /dev/null @@ -1,44 +0,0 @@ -from django import template -from django.template.defaultfilters import stringfilter -import hashlib -import urllib - -register = template.Library() - -DEFAULTS = dict(size=80, rating='g', default='monsterid') - -class GravatarNode(template.Node): - - def __init__(self, email, size): - self.email = template.Variable(email) - self.size = size - - def render(self, context): - try: - email = self.email.resolve(context) - except template.VariableDoesNotExist: - return '' - - gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5(email).hexdigest() + "?" - gravatar_url += urllib.urlencode({'default': 'mm', 'size': str(self.size)}) - - return gravatar_url - -@register.tag -def gravatar(parser, token): - try: - _tag_name, email, size = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError, "%r tag requires two args" % token.contents.split()[0] - - return GravatarNode(email, int(size)) - - - - -@register.filter(name='md5') -@stringfilter -def md5_hash(value): - h = hashlib.md5() - h.update(value) - return h.hexdigest() diff --git a/src/accounts/urls.py b/src/accounts/urls.py index 86e81fa..41752f8 100644 --- a/src/accounts/urls.py +++ b/src/accounts/urls.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns('accounts.views', url(r'^$', 'account_profile'), diff --git a/src/accounts/views.py b/src/accounts/views.py index b00dd20..df8365a 100644 --- a/src/accounts/views.py +++ b/src/accounts/views.py @@ -1,14 +1,15 @@ # Create your views here. from django import http +from django.contrib.auth.decorators import login_required +from django.contrib import messages +from django.shortcuts import render from django.utils.translation import ugettext as __ -from django.views.generic.simple import direct_to_template from django.views.decorators.http import require_POST -from django.contrib.auth.decorators import login_required from accounts.forms import UserBasicForm, UserPasswordForm @login_required def account_profile(request, basic_form=None, pass_form=None): - return direct_to_template(request, "account/profile.html", { + return render(request, "account/profile.html", { "basic_form": basic_form or UserBasicForm(instance=request.user), "pass_form": pass_form or UserPasswordForm(), }) @@ -21,7 +22,7 @@ def account_change_basic_profile(request): if form.is_valid(): form.save() - request.user.message_set.create(message=__("Profile has been changed.")) + messages.add_message(request, messages.INFO, __("Profile has been changed.")) return http.HttpResponseRedirect('/accounts/') return account_profile(request, basic_form=form) @@ -35,7 +36,7 @@ def account_change_password(request): request.user.set_password(form.cleaned_data['new_password']) request.user.save() - request.user.message_set.create(message=__("Password has been changed.")) + messages.add_message(request, messages.INFO, __("Password has been changed.")) return http.HttpResponseRedirect('/accounts/') return account_profile(request, pass_form=form) diff --git a/src/cas/manage.py b/src/cas/manage.py index 43896be..28f7ef8 100755 --- a/src/cas/manage.py +++ b/src/cas/manage.py @@ -7,7 +7,6 @@ import sys PROJECT_ROOT = path.realpath(path.dirname(__file__)) sys.path = [ path.abspath(path.join(PROJECT_ROOT, '..')), - path.abspath(path.join(PROJECT_ROOT, '..', '..', "provider")), ] + sys.path try: diff --git a/src/cas/media/static/brackets.png b/src/cas/media/static/brackets.png new file mode 100644 index 0000000..c8567c5 Binary files /dev/null and b/src/cas/media/static/brackets.png differ diff --git a/src/cas/media/static/css/main.css b/src/cas/media/static/css/main.css index e181e41..b1f4c1e 100644 --- a/src/cas/media/static/css/main.css +++ b/src/cas/media/static/css/main.css @@ -1,20 +1,86 @@ +.enclose { + text-align: center; + min-height: 500px; + background: url(/media/static/brackets.png) no-repeat 50% 0; + margin-top: 1em; +} + +.enclosed { + margin-top: 7em; + display: inline-block; + text-align: left; + max-width: 300px; + background-color: rgb(247, 247, 247); + background-color: rgba(247, 247, 247, .5); +} + +a { + text-decoration: none; +} +a:hover { + text-decoration: underline; +} + + +form p { + margin: 0; +} +form label, form input { + display: block; + width: 100%; +} +#login-form input { + font-size: 1.75em; + margin-bottom: .4em; +} + + + + +html, body { + margin: 0; + padding: 0; + height: 100%; +} body { - background-color: #eee; + background-color: #F7F7F7; + color: black; + font-family: Lato; } -#content_wrap { - background-color: #555; - margin: 0px 5%; - padding: 5px; +#header-wrap { + background: #191919; + color: #989898; +} +header { + max-width: 960px; + margin: auto; + padding: 1em 0; +} +header img { + margin: 0 20px; + vertical-align: middle; +} +footer, #content_push { + height: 10em; +} +footer { + +} + +#content-wrap { } #content { - background-color: white; - border-radius: 10px; - margin: 5px; - padding: 0.2em 1em; - overflow: hidden; + max-width: 960px; + margin: auto; } +#content-inner { +} + + + + #details { margin: 1em; @@ -49,20 +115,25 @@ body { } .user_avatar img { - border: 1px solid black; + box-shadow: 0 0 .2em black; } #services-list { - width: 250px; - float: right; - margin: 1em 2em; + clear: both; + border-top: 1px solid red; +} + +#services-list a { + } #services-list img { - width: 250px; - margin: 1em 0em; + width: 90px; + height: 50px; + margin: 10px 10px 0 0; } + img.small_logo { width: 250px; } diff --git a/src/cas/settings.py b/src/cas/settings.py index 3262fcd..21a4a35 100644 --- a/src/cas/settings.py +++ b/src/cas/settings.py @@ -7,24 +7,27 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = [ - "lrekucki@gmail.com", ] MANAGERS = ADMINS -DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = PROJECT_ROOT + '/dev.sqlite' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': path.join(PROJECT_ROOT, 'dev.sqlite'), # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. -TIME_ZONE = 'Europe/Warsaw Poland' +TIME_ZONE = None # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html @@ -50,29 +53,6 @@ MEDIA_URL = '/media/' # Examples: "http://foo.com/media/", "/media/". ADMIN_MEDIA_PREFIX = '/admin-media/' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.core.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - 'django.core.context_processors.media', - "django.core.context_processors.request", -) - - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.middleware.doc.XViewMiddleware', -) - ROOT_URLCONF = 'cas.urls' TEMPLATE_DIRS = ( @@ -88,15 +68,21 @@ INSTALLED_APPS = ( 'django.contrib.admindocs', 'cas_provider', + 'gravatar', + 'south', + 'accounts', ) # django-cas-provider settings LOGIN_URL = '/cas/login/' LOGOUT_URL = '/cas/logout/' +LOGIN_REDIRECT_URL = '/accounts/' CAS_CUSTOM_ATTRIBUTES_CALLBACK = 'cas.utils.custom_attributes_callback' SESSION_COOKIE_NAME = 'fnpcas' +GRAVATAR_DEFAULT_IMAGE = 'mm' + # Import localsettings file, which may override settings defined here try: from localsettings import * diff --git a/src/cas/templates/base.html b/src/cas/templates/base.html index 1872c06..a0dd91e 100644 --- a/src/cas/templates/base.html +++ b/src/cas/templates/base.html @@ -1,14 +1,28 @@ - - + + - - {% block title %}Fundacja Nowoczesna Polska - CAS{% block subtitle %}{% endblock subtitle %}{% endblock title%} - + + {% block title %}Fundacja Nowoczesna Polska - Logowanie{% block subtitle %}{% endblock subtitle %}{% endblock title%} + {% block extrahead %} {% endblock %} -
{% block content %} {% endblock %}
- +
+
+ + + Fundacja Nowoczesna Polska + +
+
+ +
+
+ {% block content %} {% endblock %} +
+
+ diff --git a/src/cas/templates/cas/login.html b/src/cas/templates/cas/login.html index 514c5a3..f3a08cf 100644 --- a/src/cas/templates/cas/login.html +++ b/src/cas/templates/cas/login.html @@ -3,19 +3,19 @@ {% block content %} - +
+ + {% csrf_token %}

{% trans "Login" %}

{% for error in errors %}

{{ error }}

{% endfor %} -
- {{ form.as_table }} - -
+ {{ form.as_p }} +
+
- {% include "horizontal_footer.html" %} {% endblock %} diff --git a/src/cas/templates/cas/logout.html b/src/cas/templates/cas/logout.html index ce3db21..5a38a42 100644 --- a/src/cas/templates/cas/logout.html +++ b/src/cas/templates/cas/logout.html @@ -6,6 +6,9 @@ Logged out {% endblock %} {% block content %} + +
+

{% trans "Logged out" %}

{% blocktrans %}You have successfully logged out. To ensure that you are logged out of all services, please close your browser.{% endblocktrans %}

@@ -14,8 +17,8 @@ Logged out

{% blocktrans %}You can return to service you came from: {{ url }}{% endblocktrans %}

{% endif %} - {% url cas_provider.views.login as login_url %} + {% url 'cas_login' as login_url %}

{% blocktrans %}You can also login again{% endblocktrans %}

- {% include "horizontal_footer.html" %} -{% endblock %} \ No newline at end of file +
+{% endblock %} diff --git a/src/cas/templates/horizontal_footer.html b/src/cas/templates/horizontal_footer.html deleted file mode 100644 index 8880082..0000000 --- a/src/cas/templates/horizontal_footer.html +++ /dev/null @@ -1,6 +0,0 @@ -
-

- - - -

diff --git a/src/cas/urls.py b/src/cas/urls.py index 4a285fd..175d5fb 100644 --- a/src/cas/urls.py +++ b/src/cas/urls.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import * -from django.views.generic.simple import redirect_to +from django.conf.urls import include, patterns, url +from django.views.generic import RedirectView from django.contrib import admin from django.conf import settings admin.autodiscover() urlpatterns = patterns('', - url(r'^$', redirect_to, {'url': '/accounts/'}), + url(r'^$', RedirectView.as_view(url='/accounts/')), # django-cas-provider url(r'^cas/', include('cas_provider.urls')),