Commit 2454cb19 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

Merge branch 'master' of git.gmu.edu:srct/roomlist

parents 4bee9dc3 b0b19bd5
......@@ -24,5 +24,24 @@ class StudentForm( forms.ModelForm ):
super(StudentForm, self).__init__(*args, **kwargs)
class Meta:
model = Student
model = Student
class UserSettingsForm( 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 | {{ student.user.first_name }} {{ student.user.last_name }} {% endblock %} {% block content %} {% load gravatar %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 175 %}" alt="{{ student.user.first_name }} Gravatar picture">
<h1>{{ student.user.first_name }} {{ student.user.last_name }}, {{ student.user.username }}</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-body">
<table class="table table-hover text-center">
<tbody>
<tr>
<td><i class="fa fa-facebook fa-lg"></i>
</td>
<td>
{% load socialaccount %} {% providers_media_js %}
<a href="{% provider_login_url 'facebook' method='js_sdk' process='connect' next='/accounts/student/' %}">Facebook Connect</a>
</td>
</tr>
<tr>
<td><i class="fa fa-google fa-lg"></i>
</td>
<td>
<a href="{% provider_login_url 'google' process='connect' next='/accounts/student/' %}">Connect to Google</a>
</td>
</tr>
<tr>
<td><i class="fa fa-twitter fa-lg"></i>
</td>
<td>
<a href="{% provider_login_url 'twitter' process='connect' next='/accounts/student/' %}">Connect to Twitter</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent, CreateStudent
from accounts.views import DetailStudent, CreateStudent, DetailStudentSettings, DetailCurrentStudent, DetailCurrentStudentSettings
from accounts.models import Student
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'', include('allauth.urls')),
# login and logout
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'index.html'}, name='logout'),
......@@ -17,9 +20,30 @@ urlpatterns = patterns('',
template_name='detailStudent.html'),
name='detailStudent'),
url(r'^student/$',
DetailCurrentStudent.as_view(
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detailCurrentStudent'),
url(r'^create/$',
CreateStudent.as_view(
model=Student,
template_name="createStudent.html"),
name='createStudent'),
url(r'^settings/(?P<slug>[\w-]+)/$',
DetailStudentSettings.as_view(
model=Student,
context_object_name='student',
template_name="studentSettings.html"),
name='studentSettings'),
url(r'^settings/$',
DetailCurrentStudentSettings.as_view(
model=Student,
context_object_name='student',
template_name="studentSettings.html"),
name='currentStudentSettings'),
)
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
......@@ -18,3 +18,23 @@ class CreateStudent(LoginRequiredMixin, CreateView):
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
# changeable student settings
class DetailStudentSettings(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
class DetailCurrentStudent(LoginRequiredMixin, DetailView):
#model = Student
def get_object(self):
return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
class DetailCurrentStudentSettings(LoginRequiredMixin, DetailView):
#model = Student
def get_object(self):
return get_object_or_404(Student, pk=self.request.session['_auth_user_id'])
......@@ -39,6 +39,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
)
# Quick-start development settings - unsuitable for production
......@@ -64,11 +66,18 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'api',
'housing',
'accounts',
'crispy_forms',
'django_gravatar',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
)
CRISPY_TEMPLATE_PACK = 'bootstrap'
......@@ -114,6 +123,14 @@ USE_L10N = True
USE_TZ = True
SITE_ID = 2
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
......
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