Added login
This commit is contained in:
parent
5bca3307cd
commit
ffa5a039d9
|
@ -1,4 +1,5 @@
|
|||
# Django settings for past3d project.
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
|
||||
import os
|
||||
BASE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../')
|
||||
|
@ -127,6 +128,7 @@ INSTALLED_APPS = (
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'pastebin',
|
||||
'users',
|
||||
# Uncomment the next line to enable the admin:
|
||||
'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
|
@ -135,6 +137,8 @@ INSTALLED_APPS = (
|
|||
|
||||
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
|
||||
|
||||
LOGIN_REDIRECT_URL = reverse_lazy('geometry_create')
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
# performed by this configuration is to send an email to
|
||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
||||
|
|
|
@ -12,6 +12,7 @@ urlpatterns = patterns('',
|
|||
# url(r'^$', 'past3d.views.home', name='home'),
|
||||
# url(r'^past3d/', include('past3d.foo.urls')),
|
||||
|
||||
url(r'^users/', include('users.urls')),
|
||||
url(r'^3d/', include('pastebin.urls')),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
|
|
|
@ -7,6 +7,13 @@ from forms import GeometryForm
|
|||
from models import Geometry
|
||||
|
||||
|
||||
class LastesGeometriesMixin(ContextMixin):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(LastesGeometriesMixin, self).get_context_data(**kwargs)
|
||||
context['latest_geometries'] = Geometry.get_latest()
|
||||
return context
|
||||
|
||||
|
||||
class GeometryView(DetailView):
|
||||
model = Geometry
|
||||
pk_url_kwarg = 'id'
|
||||
|
@ -14,7 +21,7 @@ class GeometryView(DetailView):
|
|||
template_name = 'pastebin/geometry.html'
|
||||
|
||||
|
||||
class GeometryCreate(CreateView):
|
||||
class GeometryCreate(CreateView, LastesGeometriesMixin):
|
||||
model = Geometry
|
||||
form_class = GeometryForm
|
||||
template_name = 'pastebin/geometry_create.html'
|
||||
|
@ -22,7 +29,3 @@ class GeometryCreate(CreateView):
|
|||
def get_success_url(self):
|
||||
return reverse('geometry_details', kwargs={'id' :self.object.id})
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateView, self).get_context_data(**kwargs)
|
||||
context['latest_geometries'] = Geometry.get_latest()
|
||||
return context
|
|
@ -20,9 +20,9 @@
|
|||
<a href="#" class="pure-menu-heading">past3d</a>
|
||||
|
||||
<ul>
|
||||
<li class="pure-menu-selected"><a href="#">Home</a></li>
|
||||
<li ><a href="#">Home</a></li>
|
||||
<li><a href="{% url 'geometry_create' %}">New Paste</a></li>
|
||||
<li><a href="#">Login</a></li>
|
||||
<li><a href="{% url 'login' %}">Login</a></li>
|
||||
<li><a href="#">Sign up</a></li>
|
||||
<li><a href="#">Logout</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,56 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
|
||||
{% block title %} Login {% endblock %}
|
||||
|
||||
|
||||
{% block headeraddons %}
|
||||
<script src="{{STATIC_URL}}js/jquery-1.10.2.min.js"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div id="content">
|
||||
<div id="prompt">
|
||||
<!-- if IE without GCF, prompt goes here -->
|
||||
</div>
|
||||
|
||||
<h1>Login</h1>
|
||||
<div class="pure-g-r">
|
||||
<div class="pure-u-2-3">
|
||||
<div class="textcontainer">
|
||||
<form method="post" class="pure-form pure-form-aligned">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
{% for field in form %}
|
||||
<div class="pure-control-group">
|
||||
{{ field.label_tag }}
|
||||
{{ field }}
|
||||
{{ field.errors }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="pure-control-group">
|
||||
<label for="submitbutton" >... and </label>
|
||||
<input class="pure-button button-green" id="submitbutton" type="submit" value="Login" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-1-3">
|
||||
<div class="textcontainer">
|
||||
<h2><i class="icon-upload-alt"></i> Latest uploads</h2>
|
||||
<ul class="uploads-list">
|
||||
{% for geometry in latest_geometries %}
|
||||
<li>
|
||||
<i class="icon-file"></i>
|
||||
<a href="{{geometry.get_absolute_url}}">{{geometry.name}}</a>
|
||||
- {{geometry.date}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
|
@ -0,0 +1,8 @@
|
|||
from django.conf.urls import patterns, include, url
|
||||
|
||||
from pastebin.models import Geometry
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^login/$', 'django.contrib.auth.views.login', {'extra_context' : {'latest_geometries' : Geometry.get_latest()},
|
||||
'template_name' : 'users/login.html'},
|
||||
name='login'))
|
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
Loading…
Reference in New Issue