Commit a9260de3 authored by fred's avatar fred

add django-registration, and required to be logged in for the emissions views

parent 7b76664a
......@@ -176,6 +176,8 @@ HAYSTACK_CONNECTIONS = {
},
}
LOGIN_REDIRECT_URL = '/'
try:
from local_settings import *
except ImportError:
......
{% extends "panikdb/base.html" %}
{% load url from future %}
{% block content %}
<h2>Connexion</h2>
{% if form.errors %}
<p>Mot de passe incorrect. Essayez encore.</p>
{% endif %}
<form method="post" id="login-form" action="{% url 'django.contrib.auth.views.login' %}">
{% csrf_token %}
<p>
<label for="id_username">Identifiant</label>
{{ form.username }}
</p>
<p>
<label for="id_password">Mot de passe</label>
{{ form.password }}
</p>
<input type="submit" value="Se connecter" class="submit login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
{% endblock %}
......@@ -2,6 +2,7 @@ from django.conf.urls import patterns, include, url
from django.conf import settings
from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib import admin
admin.autodiscover()
......@@ -11,6 +12,10 @@ from haystack.forms import FacetedSearchForm
from haystack.query import SearchQuerySet
from emissions.views import FacetedSearchView
from .emissions.urls import urlpatterns as emissions_urlpatterns
from urls_utils import decorated_includes
sqs = SearchQuerySet().facet('categories').facet('tags')
......@@ -19,7 +24,11 @@ urlpatterns = patterns('',
(r'^ckeditor/', include('ckeditor.urls')),
url(r'^search/', search_view_factory(view_class=FacetedSearchView,
form_class=FacetedSearchForm, searchqueryset=sqs), name='haystack_search'),
url(r'^emissions/', include('panikdb.emissions.urls')),
url(r'^emissions/',
decorated_includes(login_required, include(emissions_urlpatterns))),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^admin/', include(admin.site.urls)),
)
......
from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
class DecoratedURLPattern(RegexURLPattern):
def resolve(self, *args, **kwargs):
result = super(DecoratedURLPattern, self).resolve(*args, **kwargs)
if result:
result.func = self._decorate_with(result.func)
return result
class DecoratedRegexURLResolver(RegexURLResolver):
def resolve(self, *args, **kwargs):
result = super(DecoratedRegexURLResolver, self).resolve(*args, **kwargs)
if result:
result.func = self._decorate_with(result.func)
return result
def decorated_includes(func, includes, *args, **kwargs):
urlconf_module, app_name, namespace = includes
for item in urlconf_module:
if isinstance(item, RegexURLPattern):
item.__class__ = DecoratedURLPattern
item._decorate_with = func
elif isinstance(item, RegexURLResolver):
item.__class__ = DecoratedRegexURLResolver
item._decorate_with = func
return urlconf_module, app_name, namespace
......@@ -3,3 +3,4 @@ south>=0.8,<0.9
django-ckeditor
django-taggit
git+https://github.com/toastdriven/django-haystack.git
django-registration
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