Commit f366fee4 authored by Daniel Bond's avatar Daniel Bond
Browse files

Merge branch 'forms'

parents 024620c3 3cfdb8c8
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Field, HTML
from crispy_forms.bootstrap import PrependedText, AppendedText, FormActions
from accounts.models import Student
# form to create student
class StudentForm( forms.ModelForm ):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
'user',
PrependedText('room', 'Room'),
'class',
AppendedText('major', 'Major'),
)
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', 'Submit'))
super(StudentForm, self).__init__(*args, **kwargs)
class Meta:
model = Student
{% extends 'layouts/base.html' %}
{% block title %} GMU RoomList | New Student Signup {% endblock %}
{% block content %}
{% load crispy_forms_tags %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-10 col-md-offset-2 text-center">
<h1><strong><a href="#">RoomList</a></strong> New Student Signup</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title text-center"><strong>Student</strong></h1>
</div>
<div class="panel-body">
{% crispy form %}
</div>
</div>
</div>
</div>
{% endblock %}
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent from accounts.views import DetailStudent, CreateStudent
from accounts.models import Student from accounts.models import Student
from django.contrib import admin from django.contrib import admin
...@@ -16,4 +16,10 @@ urlpatterns = patterns('', ...@@ -16,4 +16,10 @@ urlpatterns = patterns('',
context_object_name='student', context_object_name='student',
template_name='detailStudent.html'), template_name='detailStudent.html'),
name='detailStudent'), name='detailStudent'),
url(r'^create/$',
CreateStudent.as_view(
model=Student,
template_name="createStudent.html"),
name='createStudent'),
) )
...@@ -3,9 +3,17 @@ from django.shortcuts import render ...@@ -3,9 +3,17 @@ from django.shortcuts import render
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
from accounts.models import Student from accounts.models import Student
from accounts.forms import StudentForm
from braces.views import LoginRequiredMixin from braces.views import LoginRequiredMixin
# create a student
class CreateStudent(LoginRequiredMixin, CreateView):
model = Student
form_class = StudentForm
success_url = '/' #redirect location tba
login_url = '/'
# details about the student # details about the student
class DetailStudent(LoginRequiredMixin, DetailView): class DetailStudent(LoginRequiredMixin, DetailView):
model = Student model = Student
......
...@@ -71,6 +71,8 @@ INSTALLED_APPS = ( ...@@ -71,6 +71,8 @@ INSTALLED_APPS = (
'django_gravatar', 'django_gravatar',
) )
CRISPY_TEMPLATE_PACK = 'bootstrap'
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
......
body { body {
min-height: 2000px;
padding-top: 70px; padding-top: 70px;
} }
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 80px;
}
...@@ -15,6 +15,11 @@ GMU RoomList &bull; Homepage ...@@ -15,6 +15,11 @@ GMU RoomList &bull; Homepage
</div> </div>
</div> </div>
<div class="jumbotron">
<h1 class="text-center"></h1>
<p class="text-center">Lorem ipsum dolor sit amet. Freely licensed pictures from the #photos project?</p>
</div>
<div class="row"> <div class="row">
</div> </div>
......
...@@ -2,33 +2,26 @@ ...@@ -2,33 +2,26 @@
"http://www.w3.org/TR/html4/strict.dtd"> "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
{% load staticfiles %} <meta charset="utf-8">
<link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen"> <meta name="description" content="Find your on campus neighbors">
<link href="/static/css/style.css" rel="stylesheet" media="screen"> {% load staticfiles %}
<script src="/static/js/jquery-2.1.1.min.js"></script> <link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="/static/js/bootstrap.min.js"></script> <link href="/static/css/style.css" rel="stylesheet" media="screen">
<link rel="icon" href="/static/img/favicon.ico"> <script type="text/javascript" src="/static/js/jquery-2.1.1.min.js"></script>
<meta charset="utf-8"> <script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<meta name="description" content="Find your on campus neighbors"> <link rel="icon" href="/static/img/favicon.ico">
<!-- <link rel="icon" href="path/to/favicon/"> --> <title> {% block title %} {% endblock %}</title>
<title>
{% block title %}
{% endblock %}
</title>
</head> </head>
<body> <body>
<div id = "wrap"> <div id = "wrap">
{% include 'layouts/navbar.html' %} {% include 'layouts/navbar.html' %}
{% block pagetitle %}
{% endblock %}
<div class="container"> <div class="container">
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</div> </div>
</div> </div>
<div class="footer">
{% include 'layouts/footer.html' %} {% include 'layouts/footer.html' %}
</div>
</body> </body>
</html> </html>
<div id="footer"> <footer class="footer">
<hr>
</div> <div class="container">
<div class="row">
<div class="col-lg-12">
<div class="col-md-8">
<a href="#">About</a> &middot;
<a href="#">Contact</a> &middot;
<a href="#">Terms of Service</a> &middot;
<a href="#">Privacy</a>
</div>
<div class="col-md-4">
<p class="muted pull-right">A <a href="http://srct.gmu.edu/projects">project</a> of <a href="http://www.gmu.edu/">Mason</a> <a href="http://srct.gmu.edu/"><strong>SRCT</strong></a>. <a href="https://www.gnu.org/licenses/gpl-3.0.html">Contribute</a> to <a href="http://git.gmu.edu/srct/roomlist/">our code</a>.</p>
</div>
</div>
</div>
</div>
</footer>
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