diff --git a/browser/views.py b/browser/views.py index 7c1d55a..307dbfe 100755 --- a/browser/views.py +++ b/browser/views.py @@ -1,6 +1,7 @@ import os from django.http import Http404 from django.shortcuts import render_to_response +from django.contrib.auth.decorators import permission_required from codereview.dashboard.models import Repository from codereview.browser import vcs @@ -37,12 +38,14 @@ def _log_data(request, repo, ref, path=None): 'newer': newer, 'older': older, } +@permission_required('dashboard.browse') def log(request, repository, path=None): repo, ref = _repo(request, repository) data = {'repository': repository} data.update(_log_data(request, repo, ref, path)) data.update(_nav_data(request, repo, ref, path)) return render_to_response('browser/log.html', data) +@permission_required('dashboard.browse') def commit(request, repository, ref): try: repository = Repository.objects.get(name=repository) @@ -60,6 +63,7 @@ def commit(request, repository, ref): 'commit': commit, 'diffs': diffs, }) +@permission_required('dashboard.browse') def blob(request, repository, path): repo, ref = _repo(request, repository) data = { diff --git a/dashboard/models.py b/dashboard/models.py index 0826503..077b366 100755 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -5,5 +5,10 @@ class Repository(models.Model): path = models.CharField(max_length=255) type = models.IntegerField(default=0) + class Meta: + permissions = ( + ("browse", "Browse repositories"), + ) + def __unicode__(self): return self.name diff --git a/dashboard/urls.py b/dashboard/urls.py new file mode 100644 index 0000000..ed2bbb1 --- /dev/null +++ b/dashboard/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('', + (r'^login/$', 'django.contrib.auth.views.login'), +) diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..1d107a2 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,23 @@ +{% extends "layouts/default.html" %} + +{% block content %} + +{% if form.errors %} +
Username or password is incorrect
+{% endif %} + + + +{% endblock %} diff --git a/urls.py b/urls.py index 5411d6f..666995f 100755 --- a/urls.py +++ b/urls.py @@ -10,6 +10,8 @@ urlpatterns = patterns('', (r'^$', 'codereview.dashboard.views.index'), (r'^browser/', include('codereview.browser.urls')), + (r'^dashboard/', include('codereview.dashboard.urls')), + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')),