mirror of
https://github.com/correl/codereview.git
synced 2024-11-27 11:09:50 +00:00
Initial authentication work
This commit is contained in:
parent
8183b0c928
commit
44bab4989a
5 changed files with 39 additions and 0 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
5
dashboard/urls.py
Normal file
5
dashboard/urls.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^login/$', 'django.contrib.auth.views.login'),
|
||||
)
|
23
templates/registration/login.html
Normal file
23
templates/registration/login.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% extends "layouts/default.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if form.errors %}
|
||||
<p>Username or password is incorrect</p>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="{% url django.contrib.auth.views.login %}">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
<dl>
|
||||
<dt>{{ form.username.label_tag }}</dt>
|
||||
<dd>{{ form.username }}</dd>
|
||||
<dt>{{ form.password.label_tag }}</dt>
|
||||
<dd>{{ form.password }}</dd>
|
||||
</dl>
|
||||
<input type="submit" value="Login" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
2
urls.py
2
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')),
|
||||
|
|
Loading…
Reference in a new issue