mirror of
https://github.com/correl/codereview.git
synced 2024-11-27 11:09:50 +00:00
Created a logout link
This commit is contained in:
parent
3aebdc0cd0
commit
a364b878b2
5 changed files with 31 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
from django.template import RequestContext
|
||||||
from django.contrib.auth.decorators import permission_required
|
from django.contrib.auth.decorators import permission_required
|
||||||
from codereview.dashboard.models import Repository
|
from codereview.dashboard.models import Repository
|
||||||
from codereview.browser import vcs
|
from codereview.browser import vcs
|
||||||
|
@ -41,7 +42,9 @@ def _log_data(request, repo, ref, path=None):
|
||||||
@permission_required('dashboard.browse')
|
@permission_required('dashboard.browse')
|
||||||
def log(request, repository, path=None):
|
def log(request, repository, path=None):
|
||||||
repo, ref = _repo(request, repository)
|
repo, ref = _repo(request, repository)
|
||||||
data = {'repository': repository}
|
data = RequestContext(request, {
|
||||||
|
'repository': repository
|
||||||
|
})
|
||||||
data.update(_log_data(request, repo, ref, path))
|
data.update(_log_data(request, repo, ref, path))
|
||||||
data.update(_nav_data(request, repo, ref, path))
|
data.update(_nav_data(request, repo, ref, path))
|
||||||
return render_to_response('browser/log.html', data)
|
return render_to_response('browser/log.html', data)
|
||||||
|
@ -55,21 +58,21 @@ def commit(request, repository, ref):
|
||||||
commit = repo.commit(ref)
|
commit = repo.commit(ref)
|
||||||
diffs = repo.diff(ref)
|
diffs = repo.diff(ref)
|
||||||
|
|
||||||
return render_to_response('browser/view.html',
|
data = RequestContext(request, {
|
||||||
{
|
'repository': repository,
|
||||||
'repository': repository,
|
'repo': repo,
|
||||||
'repo': repo,
|
'ref': ref,
|
||||||
'ref': ref,
|
'commit': commit,
|
||||||
'commit': commit,
|
'diffs': diffs,
|
||||||
'diffs': diffs,
|
})
|
||||||
})
|
return render_to_response('browser/view.html', data)
|
||||||
@permission_required('dashboard.browse')
|
@permission_required('dashboard.browse')
|
||||||
def blob(request, repository, path):
|
def blob(request, repository, path):
|
||||||
repo, ref = _repo(request, repository)
|
repo, ref = _repo(request, repository)
|
||||||
data = {
|
data = RequestContext(request, {
|
||||||
'repository': repository,
|
'repository': repository,
|
||||||
'blob': repo.blob(ref, path),
|
'blob': repo.blob(ref, path),
|
||||||
}
|
})
|
||||||
data.update(_log_data(request, repo, ref, path))
|
data.update(_log_data(request, repo, ref, path))
|
||||||
data.update(_nav_data(request, repo, ref, os.path.dirname(path)))
|
data.update(_nav_data(request, repo, ref, os.path.dirname(path)))
|
||||||
return render_to_response('browser/blob.html', data)
|
return render_to_response('browser/blob.html', data)
|
||||||
|
|
|
@ -2,4 +2,5 @@ from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^login/$', 'django.contrib.auth.views.login'),
|
(r'^login/$', 'django.contrib.auth.views.login'),
|
||||||
|
(r'^logout/$', 'django.contrib.auth.views.logout'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
from django.template import RequestContext
|
||||||
from codereview.dashboard.models import Repository
|
from codereview.dashboard.models import Repository
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
""" List available repositories
|
""" List available repositories
|
||||||
"""
|
"""
|
||||||
repositories = Repository.objects.all()
|
repositories = Repository.objects.all()
|
||||||
return render_to_response('dashboard/index.html',
|
data = RequestContext(request, {
|
||||||
{'repositories': repositories})
|
'repositories': repositories,
|
||||||
|
})
|
||||||
|
return render_to_response('dashboard/index.html', data)
|
||||||
|
|
|
@ -11,7 +11,13 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1><a href="{% url codereview.dashboard.views.index %}">CodeReview</a></title>
|
<h1><a href="{% url codereview.dashboard.views.index %}">CodeReview</a></title></h1>
|
||||||
|
{% if user and user.is_authenticated %}
|
||||||
|
Currently logged in as
|
||||||
|
{{ user }}
|
||||||
|
|
||||||
|
<a href="{% url django.contrib.auth.views.logout %}">Log Out</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="navigation">
|
<div class="navigation">
|
||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
|
|
4
templates/registration/logged_out.html
Normal file
4
templates/registration/logged_out.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{% extends "layouts/default.html" %}
|
||||||
|
{% block content %}
|
||||||
|
Goodbye!
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue