sdi/views.py
author nishanth
Fri, 16 Jul 2010 19:05:11 +0530
branchanoop
changeset 112 3cf5f668fca5
parent 111 45f844723b7a
child 113 b0c34801022a
permissions -rw-r--r--
implemented the post part to an extent
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
1c2d2e702aee completed the register view
nishanth
parents: 14
diff changeset
     1
from django.shortcuts import render_to_response, redirect
98
e6140a4cac5d forgot to import http404 .. fixed it
nishanth
parents: 97
diff changeset
     2
from django.http import HttpResponse, Http404
65
0ca63c964237 now login is required for accessing stats and send_invi pages
nishanth
parents: 57
diff changeset
     3
from django.contrib.auth.decorators import login_required
97
bf16c82df506 forgot an import .. fixed it
nishanth
parents: 95
diff changeset
     4
from django.utils.datastructures import MultiValueDictKeyError
7
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
     5
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
     6
from django.contrib.auth import authenticate, login, logout
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
     7
7
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
     8
from sage_days.sdi.models import Registrant
90
1a6e1af98624 now selecting users through forms. created a form for that
nishanth
parents: 88
diff changeset
     9
from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm
56
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    10
from sage_days.sdi.events import send_reg_complete_mail, mail_invi
72
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
    11
from sage_days.settings import APACHE_URL_PREFIX as aup
7
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
    12
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
    13
def register(request):
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
    14
    """ The user register page.
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
    15
    """
98f2b5c2abc9 added basic register view in views.py
nishanth
parents: 4
diff changeset
    16
9
47f72774489e added the return statement for register view
nishanth
parents: 7
diff changeset
    17
    if request.method == "POST":
14
ee492a4b9ebd updated register view
nishanth
parents: 9
diff changeset
    18
        form = RegisterForm(request.POST)
ee492a4b9ebd updated register view
nishanth
parents: 9
diff changeset
    19
        if form.is_valid():
15
1c2d2e702aee completed the register view
nishanth
parents: 14
diff changeset
    20
            form.save()
53
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    21
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    22
            data = form.cleaned_data
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    23
            first_name = data['first_name']
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    24
            last_name = data['last_name']
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    25
            email = data['email']
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    26
            send_reg_complete_mail(email, first_name, last_name)
b226923fbf64 added send_mail after registration
nishanth
parents: 48
diff changeset
    27
26
212fcba4459e changed the app to work with apache + added base.html, and did needed changes.
anoop
parents: 25
diff changeset
    28
            return redirect("/sage_days/registration/complete")
14
ee492a4b9ebd updated register view
nishanth
parents: 9
diff changeset
    29
        else:
ee492a4b9ebd updated register view
nishanth
parents: 9
diff changeset
    30
            return render_to_response("register.html", {"form":form})
9
47f72774489e added the return statement for register view
nishanth
parents: 7
diff changeset
    31
    else:
47f72774489e added the return statement for register view
nishanth
parents: 7
diff changeset
    32
        form = RegisterForm()
47f72774489e added the return statement for register view
nishanth
parents: 7
diff changeset
    33
        return render_to_response("register.html", {"form":form})
22
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    34
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    35
def reg_complete(request):
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    36
    """ Tell the registration is successful.
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    37
    """
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    38
1df4b0e0d45c added the registration complete page
nishanth
parents: 15
diff changeset
    39
    return render_to_response("reg_complete.html")
23
2aae8293f3a7 added list statiscs page
nishanth
parents: 22
diff changeset
    40
65
0ca63c964237 now login is required for accessing stats and send_invi pages
nishanth
parents: 57
diff changeset
    41
@login_required
23
2aae8293f3a7 added list statiscs page
nishanth
parents: 22
diff changeset
    42
def list_stats(request):
2aae8293f3a7 added list statiscs page
nishanth
parents: 22
diff changeset
    43
    """ List the statiscs of registered participants.
2aae8293f3a7 added list statiscs page
nishanth
parents: 22
diff changeset
    44
    """
2aae8293f3a7 added list statiscs page
nishanth
parents: 22
diff changeset
    45
24
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    46
    if request.method == "POST":
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    47
        form = SearchForm(request.POST)
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    48
        if form.is_valid():
25
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    49
            data = form.cleaned_data
79
064ff60025d9 removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents: 77
diff changeset
    50
064ff60025d9 removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents: 77
diff changeset
    51
            #need_workshop = data['need_for_python_workshop']
064ff60025d9 removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents: 77
diff changeset
    52
            #acco_required = data['need_accomodation']
064ff60025d9 removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents: 77
diff changeset
    53
            #db_query = "Registrant.objects.filter(need_for_python_workshop=%s, acco_required=%s)"%(need_workshop, acco_required)
064ff60025d9 removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents: 77
diff changeset
    54
            db_query = "Registrant.objects"
25
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    55
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    56
            topics_include, topics_exclude = data['topics_interested']
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    57
            for number in topics_include:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    58
                db_query += '.filter(topics_interested__contains="%s")'%number
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    59
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    60
            for number in topics_exclude:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    61
                db_query += '.exclude(topics_interested__contains="%s")'%number
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    62
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    63
            start_python, stop_python = data['knowledge_of_python']
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    64
            if start_python and stop_python:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    65
                db_query += '.filter(knowledge_of_python__gte="%s")'%start_python
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    66
                db_query += '.filter(knowledge_of_python__lte="%s")'%stop_python
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    67
            elif start_python:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    68
                db_query += '.filter(knowledge_of_python__exact="%s")'%start_python
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    69
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    70
            start_sage, stop_sage = data['knowledge_of_sage']
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    71
            if start_sage and stop_sage:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    72
                db_query += '.filter(knowledge_of_sage__gte="%s")'%start_sage
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    73
                db_query += '.filter(knowledge_of_sage__lte="%s")'%stop_sage
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    74
            elif start_sage:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    75
                db_query += '.filter(knowledge_of_sage__exact="%s")'%start_sage
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    76
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    77
            start_likeliness, stop_likeliness = data['likeliness_of_attending']
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    78
            if start_likeliness and stop_likeliness:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    79
                db_query += '.filter(likeliness_of_attending__gte="%s")'%start_likeliness
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    80
                db_query += '.filter(likeliness_of_attending__lte="%s")'%stop_likeliness
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    81
            elif start_likeliness:
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    82
                db_query += '.filter(likeliness_of_attending__exact="%s")'%start_likeliness
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    83
80
c200156c80a9 fixed a bug that arises when a query does not have any parameters to filter
nishanth
parents: 79
diff changeset
    84
            db_query += ".all()"
c200156c80a9 fixed a bug that arises when a query does not have any parameters to filter
nishanth
parents: 79
diff changeset
    85
25
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    86
            matches = eval(db_query)
30baf3c635c5 added list statiscs page
nishanth
parents: 24
diff changeset
    87
            return render_to_response("list_stats.html", {"form":form, 'matches':matches})
24
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    88
        else:
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    89
            return render_to_response("list_stats.html", {"form":form})
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    90
    else:
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    91
        form = SearchForm()
f79be1dd4a22 added clean methods for each attribute in search form
nishanth
parents: 23
diff changeset
    92
        return render_to_response("list_stats.html", {"form":form})
26
212fcba4459e changed the app to work with apache + added base.html, and did needed changes.
anoop
parents: 25
diff changeset
    93
65
0ca63c964237 now login is required for accessing stats and send_invi pages
nishanth
parents: 57
diff changeset
    94
@login_required
56
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    95
def send_invi(request):
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    96
    """ Take a list of csv email addresses and send mails to them.
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    97
    """
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    98
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
    99
    if request.method == "POST":
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   100
        form = EmailForm(request.POST)
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   101
        if form.is_valid():
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   102
            to_emails = form.cleaned_data['emails']
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   103
            mail_invi(to_emails)
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   104
            return render_to_response("send_invi.html", {"emails":to_emails})
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   105
        else:
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   106
            return render_to_response("send_invi.html", {"form":form})
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   107
    else:
57
03150449a049 fixed a bug
nishanth
parents: 56
diff changeset
   108
        form = EmailForm()
56
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   109
        return render_to_response("send_invi.html", {"form":form})
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   110
86
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   111
@login_required
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   112
def send_workshop_confirm(request):
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   113
    """ Show a list of all the ppl who requested for a workshop and 
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   114
    send a confirmation mail to them if not sent.
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   115
    """
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   116
88
33200c7d163a fixed a typo
nishanth
parents: 87
diff changeset
   117
    matches = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="1")
86
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   118
    if request.method == "POST":
93
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   119
        form = UserSelectForm(matches, request.POST)
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   120
        if form.is_valid():
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   121
            selected_users = form.cleaned_data['selected_users']
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   122
            return render_to_response("sent_wsp_confirm.html", {"selected_users":selected_users})
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   123
        else:
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   124
            return render_to_response("send_workshop_confirm.html", {"matches":matches})
86
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   125
    else:
93
505989755cd8 modified the form and implemented the view to display selected users
nishanth
parents: 92
diff changeset
   126
        return render_to_response("send_workshop_confirm.html", {"matches":matches}) 
86
1f0be76a18fc added a view for sending confirmation for workshop
nishanth
parents: 84
diff changeset
   127
108
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   128
@login_required
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   129
def send_sagedays_confirm(request):
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   130
    """ filter out ppl depending on their status and display accordingly.
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   131
    """
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   132
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   133
    attending_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_sagedays ="3")
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   134
    not_confirmed_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_sagedays ="2")
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   135
    not_selected_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_sagedays ="1")
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   136
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   137
    user_choices = list(attending_ppl) + list(not_confirmed_ppl)
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   138
    form = UserSelectForm(user_choices, request.POST)
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   139
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   140
    if request.method == "POST" and form.is_valid():
112
3cf5f668fca5 implemented the post part to an extent
nishanth
parents: 111
diff changeset
   141
        selected_users = form.cleaned_data['selected_users']
3cf5f668fca5 implemented the post part to an extent
nishanth
parents: 111
diff changeset
   142
        return render_to_response("sent_wsp_confirm.html", {"selected_users":selected_users})
108
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   143
    else:
111
45f844723b7a fixed a bug
nishanth
parents: 110
diff changeset
   144
        return render_to_response("send_sgd_cnf.html", {"attending":attending_ppl, 
108
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   145
                                                "not_confirmed":not_confirmed_ppl,
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   146
                                                "not_selected":not_selected_ppl,
110
01b5184402c8 fixed a bug
nishanth
parents: 108
diff changeset
   147
                                               })
108
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   148
9363e5121f9b added the GET part of view for sending event confirmation emails
nishanth
parents: 107
diff changeset
   149
95
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   150
def confirm_wsp_participation(request, uid):
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   151
    """ match id versus email and take lappy details.
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   152
    """
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   153
99
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   154
    try:
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   155
        email = request.GET['email']
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   156
    except MultiValueDictKeyError:
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   157
        raise Http404
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   158
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   159
    try:
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   160
        user = Registrant.objects.get(id=uid, email=email)
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   161
    except Registrant.DoesNotExist:
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   162
        raise Http404
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   163
100
17e35783c8d6 fixed a bug
nishanth
parents: 99
diff changeset
   164
    user_info = user.registrantinfo_set.all()[0]
17e35783c8d6 fixed a bug
nishanth
parents: 99
diff changeset
   165
    status = user_info.status_of_attending_workshop
99
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   166
    if status == "3":
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   167
        return render_to_response("attending_wsp.html")
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   168
    elif status != "2":
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   169
        raise Http404
fdaed2cf5820 improvised the view
nishanth
parents: 98
diff changeset
   170
95
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   171
    if request.method == "POST":
104
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   172
        try:
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   173
            has_laptop = request.POST['lap_status']
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   174
        except MultiValueDictKeyError:
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   175
            return render_to_response("cnf_wsp_ptc.html", {"user":user})
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   176
106
39b0b9a71778 confirm wsp_participation view is complete now
nishanth
parents: 104
diff changeset
   177
        user_info.status_of_attending_workshop = "3"
107
9fd140628988 fixed a bug
nishanth
parents: 106
diff changeset
   178
        user_info.has_laptop_for_workshop = True if has_laptop == "True" else False
106
39b0b9a71778 confirm wsp_participation view is complete now
nishanth
parents: 104
diff changeset
   179
        user_info.save()
39b0b9a71778 confirm wsp_participation view is complete now
nishanth
parents: 104
diff changeset
   180
104
7630d7f3613a added template for thanking for participation in workshop
nishanth
parents: 102
diff changeset
   181
        return render_to_response("attending_wsp.html")
95
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   182
    else:
102
ef0012eb7695 improvised the template of confirm participation
nishanth
parents: 100
diff changeset
   183
        return render_to_response("cnf_wsp_ptc.html", {"user":user})
95
ab554d46fd34 created basic view for confirmation of wsp participation
nishanth
parents: 93
diff changeset
   184
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   185
def admin_login(request):
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   186
    """ basic login.
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   187
    """
56
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   188
72
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   189
    redirect_url = "/%s/registration/stats"%aup
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   190
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   191
    user = request.user
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   192
    if user.is_authenticated():
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   193
        return redirect(redirect_url)
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   194
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   195
    if request.method == "POST":
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   196
        form = LoginForm(request.POST)
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   197
        if form.is_valid():
72
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   198
            data = form.cleaned_data
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   199
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   200
            username = data['username']
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   201
            password = data['password']
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   202
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   203
            user = authenticate(username=username, password=password)
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   204
            login(request, user)
72
3673ed3ca27c fixed a few bugs
nishanth
parents: 70
diff changeset
   205
            return redirect(redirect_url)
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   206
        else:
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   207
            return render_to_response("login.html", {"form":form})
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   208
    else:
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   209
        form = LoginForm()
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   210
        return render_to_response("login.html", {"form":form})
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   211
70
58cafee2ee89 now only logged in users can logout
nishanth
parents: 67
diff changeset
   212
@login_required
67
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   213
def admin_logout(request):
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   214
    """ simply logout.
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   215
    """
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   216
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   217
    logout(request)
b9690fbf78af created views for login and logout
nishanth
parents: 65
diff changeset
   218
    return render_to_response("logout.html")
56
7dfacad8adee provided an interface for sending out emails
nishanth
parents: 53
diff changeset
   219
26
212fcba4459e changed the app to work with apache + added base.html, and did needed changes.
anoop
parents: 25
diff changeset
   220
def homepage(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   221
    return render_to_response("index.html")
26
212fcba4459e changed the app to work with apache + added base.html, and did needed changes.
anoop
parents: 25
diff changeset
   222
31
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   223
def schedule(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   224
    return render_to_response("schedule.html")
31
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   225
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   226
def organizers(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   227
    return render_to_response("organizers.html")
31
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   228
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   229
def venue(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   230
    return render_to_response("about_venue.html")
31
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   231
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   232
def contact(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   233
    return render_to_response("contact.html")
31
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   234
ec540dfbfe78 added more pages.
anoop
parents: 26
diff changeset
   235
def about(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   236
    return render_to_response("about.html")
48
a3e6f9470549 made some changes to links and added accomodation page.
anoop
parents: 31
diff changeset
   237
	
a3e6f9470549 made some changes to links and added accomodation page.
anoop
parents: 31
diff changeset
   238
def accomodation(request):
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   239
    return render_to_response("accomodation.html")
84
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   240
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   241
def about_mumbai(request):
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   242
    return render_to_response("about_mumbai.html")
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   243
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   244
def reaching_iitb(request):
7007ec492eac added more information about venue.
anoop
parents: 80
diff changeset
   245
    return render_to_response("reaching_iitb.html")
91
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   246
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   247
def talks_proposed(request):
9fab907060a7 added talks proposed page.
anoop
parents: 85
diff changeset
   248
    return render_to_response("talks_proposed.html")