views.py 1.11 KB
Newer Older
1
from django.shortcuts import render, get_object_or_404
Jason D Yeomans's avatar
Jason D Yeomans committed
2

3
4
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView

5
from accounts.models import Student
Daniel W Bond's avatar
Daniel W Bond committed
6
from accounts.forms import StudentForm
7
8
9

from braces.views import LoginRequiredMixin

Daniel W Bond's avatar
Daniel W Bond committed
10
11
12
13
14
15
16
# create a student
class CreateStudent(LoginRequiredMixin, CreateView):
    model = Student
    form_class = StudentForm
    success_url = '/' #redirect location tba
    login_url = '/'

17
18
19
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
    model = Student
20
    login_url = '/accounts/login/'
21
22
23
24

# changeable student settings
class DetailStudentSettings(LoginRequiredMixin, DetailView):
    model = Student
25
    login_url = '/accounts/login/'
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40


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'])