app/soc/views/models/student_proposal.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 08 Mar 2009 17:19:25 +0000
changeset 1752 255117ccd6a0
parent 1741 0da1285f5bc0
child 1758 e035f81d367b
permissions -rw-r--r--
The student proposal public page can now be used to place a public comment. Developers, Hosts, and the student/org_admin/mentor that this proposal is from/directed to can leave a comment. All the comments placed will show up on the review page aswell, and vica versa. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
#
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
#
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    17
"""Views for Student Proposal.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    18
"""
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
  ]
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
import datetime
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    26
import time
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
from django import forms
1498
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
    29
from django import http
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
from soc.logic import cleaning
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
from soc.logic import dicts
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
    33
from soc.logic.models import mentor as mentor_logic
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
from soc.logic.models import organization as org_logic
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
    35
from soc.logic.models import org_admin as org_admin_logic
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
from soc.logic.models import student as student_logic
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
    37
from soc.logic.models import user as user_logic
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
    38
from soc.views import helper
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
    39
from soc.views import out_of_band
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
from soc.views.helper import access
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
from soc.views.helper import decorators
1569
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
    42
from soc.views.helper import dynaform
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
    43
from soc.views.helper import params as params_helper
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
from soc.views.helper import redirects
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
    45
from soc.views.helper import responses
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
from soc.views.helper import widgets
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
from soc.views.models import base
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
from soc.views.models import student as student_view
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    49
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    50
import soc.logic.models.student_proposal
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    51
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    52
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    53
class View(base.View):
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    54
  """View methods for the Student Proposal model.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    55
  """
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    56
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    57
  def __init__(self, params=None):
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    58
    """Defines the fields and methods required for the base View class
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    59
    to provide the user with list, public, create, edit and delete views.
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    60
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    61
    Params:
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    62
      params: a dict with params for this View
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    63
    """
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    64
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    65
    rights = access.Checker(params)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    66
    rights['create'] = ['checkIsDeveloper']
1467
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    67
    rights['edit'] = [('checkCanStudentPropose', 'scope_path'),
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    68
        ('checkRoleAndStatusForStudentProposal',
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    69
            [['proposer'], ['active'], ['new', 'pending']])]
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    70
    rights['delete'] = ['checkIsDeveloper']
1467
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    71
    rights['show'] = [
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    72
        ('checkRoleAndStatusForStudentProposal',
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    73
            [['proposer', 'org_admin', 'mentor', 'host'], 
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
    74
            ['active', 'inactive'], 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
    75
            ['new', 'pending', 'accepted', 'rejected']])]
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    76
    rights['list'] = ['checkIsDeveloper']
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
    77
    rights['list_orgs'] = [
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
    78
        ('checkIsStudent', ['scope_path', ['active']]),
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
    79
        ('checkCanStudentPropose', 'scope_path')]
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
    80
    rights['list_self'] = [
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
    81
        ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
1467
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    82
    rights['apply'] = [
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    83
        ('checkIsStudent', ['scope_path', ['active']]),
c5f99265a680 Changed the access checks in student_proposal view to use the newly created checks.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1430
diff changeset
    84
        ('checkCanStudentPropose', 'scope_path')]
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
    85
    rights['review'] = [('checkRoleAndStatusForStudentProposal',
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
    86
            [['org_admin', 'mentor', 'host'], 
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
    87
            ['active'], ['new', 'pending']])]
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    88
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    89
    new_params = {}
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    90
    new_params['logic'] = soc.logic.models.student_proposal.logic
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    91
    new_params['rights'] = rights
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    92
    new_params['name'] = "Student Proposal"
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    93
    new_params['url_name'] = "student_proposal"
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    94
    new_params['sidebar_grouping'] = 'Student Proposal'
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    95
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    96
    new_params['scope_view'] = student_view
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    97
    new_params['scope_redirect'] = redirects.getCreateRedirect
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    98
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    99
    new_params['no_create_with_key_fields'] = True
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   100
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   101
    patterns = [
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   102
        (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
1569
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   103
        'soc.views.models.%(module_name)s.apply',
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   104
        'Create a new %(name)s'),
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   105
        (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   106
        'soc.views.models.%(module_name)s.list_self',
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   107
        'List my %(name_plural)s'),
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   108
        (r'^%(url_name)s/(?P<access_type>list_orgs)/%(scope)s$',
1484
6b00a2a43eaf Changed the method and variable name in student_proposal to match the access type.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1482
diff changeset
   109
        'soc.views.models.%(module_name)s.list_orgs',
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   110
        'List my %(name_plural)s'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   111
        (r'^%(url_name)s/(?P<access_type>review)/%(key_fields)s$',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   112
        'soc.views.models.%(module_name)s.review',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   113
        'Review %(name)s'),
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   114
    ]
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   115
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   116
    new_params['extra_django_patterns'] = patterns
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   117
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   118
    new_params['extra_dynaexclude'] = ['org', 'program', 'score',
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   119
                                       'status', 'mentor', 'link_id',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   120
                                       'possible_mentors']
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   121
1430
ff8cc6b15e6a Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1426
diff changeset
   122
    new_params['create_extra_dynaproperties'] = {
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   123
        'content': forms.fields.CharField(required=True,
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   124
            widget=widgets.FullTinyMCE(attrs={'rows': 25, 'cols': 100})),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   125
        'scope_path': forms.CharField(widget=forms.HiddenInput,
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   126
            required=True),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   127
        'organization': forms.CharField(label='Organization Link ID',
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   128
            required=True),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   129
        'clean_organization': cleaning.clean_link_id('organization'),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   130
        'clean_additional_info': cleaning.clean_url('additional_info'),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   131
        'clean': cleaning.validate_student_proposal('organization',
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   132
            'scope_path', student_logic, org_logic),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   133
        }
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   134
1430
ff8cc6b15e6a Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1426
diff changeset
   135
    new_params['edit_extra_dynaproperties'] = {
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   136
        'organization': forms.CharField(label='Organization Link ID',
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   137
            widget=widgets.ReadOnlyInput),
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   138
        'link_id': forms.CharField(widget=forms.HiddenInput)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   139
        }
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   140
1498
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   141
    new_params['edit_template'] = 'soc/student_proposal/edit.html'
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   142
    new_params['review_template'] = 'soc/student_proposal/review.html'
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   143
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   144
    params = dicts.merge(params, new_params)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   145
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   146
    super(View, self).__init__(params=params)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   147
1569
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   148
    # create the special form for students
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   149
    dynafields = [
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   150
        {'name': 'organization',
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   151
         'base': forms.CharField,
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   152
         'label': 'Organization Link ID',
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   153
         'widget': widgets.ReadOnlyInput(),
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   154
         'required': False,
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   155
         },
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   156
        ]
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   157
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   158
    dynaproperties = params_helper.getDynaFields(dynafields)
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   159
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   160
    student_create_form = dynaform.extendDynaForm(
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   161
        dynaform=self._params['create_form'],
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   162
        dynaproperties=dynaproperties)
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   163
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   164
    params['student_create_form'] = student_create_form
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   165
1752
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   166
    # create the special form for public review
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   167
    dynafields = [
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   168
        {'name': 'comment',
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   169
         'base': forms.CharField,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   170
         'widget': widgets.FullTinyMCE(attrs={'rows': 10, 'cols': 40}),
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   171
         'label': 'Comment',
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   172
         'required': False,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   173
         },
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   174
         ]
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   175
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   176
    dynaproperties = params_helper.getDynaFields(dynafields)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   177
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   178
    public_review_form = dynaform.newDynaForm(dynamodel=None, 
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   179
        dynabase=helper.forms.BaseForm, dynainclude=None, 
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   180
        dynaexclude=None, dynaproperties=dynaproperties)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   181
    params['public_review_form'] = public_review_form
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   182
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   183
    # create the special form for mentors
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   184
    dynafields = [
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   185
        {'name': 'score',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   186
         'base': forms.ChoiceField,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   187
         'label': 'Score',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   188
         'initial': 0,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   189
         'required': False,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   190
         'passthrough': ['initial', 'required', 'choices'],
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   191
         'choices': [(-4,'-4: Wow. This. Sucks.'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   192
                     (-3,'-3: Needs a lot of work'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   193
                     (-2,'-2: This is bad'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   194
                     (-1,'-1: I dont like this'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   195
                     (0,'0: No score'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   196
                     (1,'1: Might have potential'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   197
                     (2,'2: Good'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   198
                     (3,'3: Almost there'),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   199
                     (4,'4: Made. Of. Awesome.')]
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   200
        },
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   201
        {'name': 'comment',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   202
         'base': forms.CharField,
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   203
         'widget': widgets.FullTinyMCE(attrs={'rows': 10, 'cols': 40}),
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   204
         'label': 'Comment',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   205
         'required': False,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   206
         },
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   207
        {'name': 'public',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   208
         'base': forms.BooleanField,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   209
         'label': 'Public comment',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   210
         'initial': False,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   211
         'required': False,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   212
         },
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   213
         ]
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   214
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   215
    dynaproperties = params_helper.getDynaFields(dynafields)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   216
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   217
    mentor_review_form = dynaform.newDynaForm(dynamodel=None, 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   218
        dynabase=helper.forms.BaseForm, dynainclude=None, 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   219
        dynaexclude=None, dynaproperties=dynaproperties)
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   220
    params['mentor_review_form'] = mentor_review_form
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   221
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   222
    # TODO see if autocomplete can be used for this field
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   223
    dynafields = [
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   224
      {'name': 'mentor',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   225
       'base': forms.CharField,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   226
       'label': 'Assign Mentor (Link ID)',
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   227
       'required': False
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   228
      },
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   229
      ]
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   230
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   231
    dynaproperties = params_helper.getDynaFields(dynafields)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   232
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   233
    admin_review_form = dynaform.extendDynaForm(dynaform=mentor_review_form, 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   234
        dynaproperties=dynaproperties)
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   235
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   236
    params['admin_review_form'] = admin_review_form
1569
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   237
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   238
  def _editGet(self, request, entity, form):
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   239
    """See base.View._editGet().
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   240
    """
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   241
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   242
    form.fields['link_id'].initial = entity.link_id
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   243
    form.fields['organization'].initial = entity.org.link_id
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   244
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   245
    return super(View, self)._editGet(request, entity, form)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   246
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   247
  def _editPost(self, request, entity, fields):
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   248
    """See base.View._editPost().
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   249
    """
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   250
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   251
    if not entity:
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   252
      fields['link_id'] = 't%i' % (time.time())
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   253
    else:
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   254
      fields['link_id'] = entity.link_id
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   255
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   256
    # fill in the scope via call to super
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   257
    super(View, self)._editPost(request, entity, fields)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   258
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   259
    if not entity:
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   260
      # creating a new application so set the program and org field
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   261
      fields['program'] = fields['scope'].scope
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   262
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   263
      filter = {'scope': fields['program'],
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   264
                'link_id': fields['organization']}
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   265
      fields['org'] = org_logic.logic.getForFields(filter, unique=True)
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   266
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   267
    # explicitly change the last_modified_on since the content has been edited
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   268
    fields['last_modified_on'] = datetime.datetime.now()
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   269
1752
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   270
  @decorators.merge_params
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   271
  @decorators.check_access
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   272
  def public(self, request, access_type,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   273
             page_name=None, params=None, **kwargs):
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   274
    """View in which the student can see and reply to the comments on the
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   275
       Student Proposal.
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   276
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   277
    For params see base.view.Public().
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   278
    """
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   279
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   280
    context = helper.responses.getUniversalContext(request)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   281
    helper.responses.useJavaScript(context, params['js_uses_all'])
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   282
    context['page_name'] = page_name
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   283
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   284
    try:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   285
      entity = self._logic.getFromKeyFieldsOr404(kwargs)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   286
    except out_of_band.Error, error:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   287
      return helper.responses.errorResponse(
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   288
          error, request, template=params['error_public'], context=context)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   289
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   290
    context['entity'] = entity
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   291
    context['entity_type'] = params['name']
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   292
    context['entity_type_url'] = params['url_name']
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   293
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   294
    if request.method == 'POST':
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   295
      return self.publicPost(request, context, params, entity, **kwargs)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   296
    else: # request.method == 'GET'
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   297
      return self.publicGet(request, context, params, entity, **kwargs)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   298
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   299
  def publicPost(self, request, context, params, entity, **kwargs):
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   300
    """Handles the POST request for the entity's public page.
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   301
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   302
    Args:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   303
        entity: the student proposal entity
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   304
        rest: see base.View.public()
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   305
    """
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   306
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   307
    # populate the form using the POST data
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   308
    form = params['public_review_form'](request.POST)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   309
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   310
    if not form.is_valid():
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   311
      # get some entity specific context
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   312
      self.updatePublicContext(context, entity, params)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   313
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   314
      # return the invalid form response
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   315
      return self._constructResponse(request, entity=entity, context=context,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   316
          form=form, params=params, template=params['public_template'])
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   317
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   318
    # get the commentary
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   319
    fields = form.cleaned_data
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   320
    comment = fields['comment']
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   321
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   322
    if comment:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   323
      # create a new public review containing the comment
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   324
      user_entity = user_logic.logic.getForCurrentAccount()
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   325
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   326
      if user_entity.key() == entity.scope.user.key():
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   327
        # student is posting
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   328
        reviewer = entity.scope
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   329
      else:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   330
        # check if the person commenting is an org_admin
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   331
        # or a mentor for the given proposal
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   332
        fields = {'user': user_entity,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   333
                  'scope': entity.org,
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   334
                  'status': 'active',
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   335
                  }
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   336
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   337
        reviewer = org_admin_logic.logic.getForFields(fields, unique=True)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   338
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   339
        if not reviewer:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   340
          # no org_admin found, maybe it's a mentor?
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   341
          reviewer = mentor_logic.logic.getForFields(filter, unique=True)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   342
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   343
      # create the review (reviewer might be None if a Host or Developer is posting)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   344
      self._createReviewFor(entity, reviewer, comment, is_public=True)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   345
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   346
    # redirect to the same page
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   347
    return http.HttpResponseRedirect('')
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   348
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   349
  def publicGet(self, request, context, params, entity, **kwargs):
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   350
    """Handles the GET request for the entity's public page.
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   351
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   352
    Args:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   353
        entity: the student proposal entity
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   354
        rest see base.View.public()
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   355
    """
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   356
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   357
    # get some entity specific context
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   358
    self.updatePublicContext(context, entity, params)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   359
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   360
    context['form'] = params['public_review_form']()
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   361
    template = params['public_template']
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   362
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   363
    return responses.respond(request, template, context=context)
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   364
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   365
  def updatePublicContext(self, context, entity, params):
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   366
    """Updates the context for the public page with information from the entity
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   367
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   368
    Args:
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   369
      context: the context that should be updated
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   370
      entity: a student proposal_entity used to set context
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   371
      params: dict with params for the view using this context
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   372
    """
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   373
1741
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   374
    from soc.logic.models.review import logic as review_logic
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   375
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   376
    context['student_name'] = entity.scope.name()
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   377
1741
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   378
    context['public_reviews'] = review_logic.getReviewsForEntity(entity,
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   379
        is_public=True, order=['created'])
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   380
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   381
  @decorators.merge_params
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   382
  @decorators.check_access
1569
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   383
  def apply(self, request, access_type,
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   384
             page_name=None, params=None, **kwargs):
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   385
    """Special view used to prepopulate the form with the organization
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   386
       contributors template.
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   387
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   388
       For params see base.View.public()
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   389
    """
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   390
    get_dict = request.GET
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   391
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   392
    if get_dict.get('organization'):
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   393
      # organization chosen, prepopulate with template
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   394
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   395
      # get the organization
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   396
      student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path'])
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   397
      program_entity = student_entity.scope
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   398
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   399
      filter = {'link_id': get_dict['organization'],
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   400
                'scope': program_entity}
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   401
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   402
      org_entity = org_logic.logic.getForFields(filter, unique=True)
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   403
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   404
      if org_entity:
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   405
        # organization found use special form
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   406
        params['create_form'] = params['student_create_form']
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   407
        kwargs['content'] = org_entity.contrib_template
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   408
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   409
    # Create page is an edit page with no key fields
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   410
    empty_kwargs = {}
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   411
    fields = self._logic.getKeyFieldNames()
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   412
    for field in fields:
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   413
      empty_kwargs[field] = None
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   414
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   415
    return super(View, self).edit(request, access_type, page_name=page_name,
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   416
                     params=params, seed=kwargs, **empty_kwargs)
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   417
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   418
  @decorators.merge_params
6347d0a4fa7b Students who follow the submit your student proposal link will now see their org's proposal template when creating their own proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1498
diff changeset
   419
  @decorators.check_access
1498
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   420
  def edit(self, request, access_type,
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   421
           page_name=None, params=None, seed=None, **kwargs):
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   422
    """If the POST contains (action, Withdraw) the proposal in kwargs
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   423
       will be marked as invalid.
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   424
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   425
    For params see base.View.edit()
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   426
    """
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   427
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   428
    # check if request.POST contains action
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   429
    post_dict = request.POST
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   430
    if 'action' in post_dict and post_dict['action'] == 'Withdraw':
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   431
      # withdraw this proposal
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   432
      filter = {'scope_path': kwargs['scope_path'],
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   433
                'link_id': kwargs['link_id']}
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   434
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   435
      proposal_logic = params['logic']
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   436
      student_proposal_entity = proposal_logic.getForFields(filter, unique=True)
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   437
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   438
      # update the entity mark it as invalid
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   439
      proposal_logic.updateEntityProperties(student_proposal_entity,
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   440
          {'status': 'invalid'})
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   441
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   442
      # redirect to the program's homepage
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   443
      redirect_url = redirects.getHomeRedirect(student_proposal_entity.program,
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   444
          {'url_name': 'program'})
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   445
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   446
      return http.HttpResponseRedirect(redirect_url)
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   447
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   448
    return super(View, self).edit(request=request, access_type=access_type,
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   449
           page_name=page_name, params=params, seed=seed, **kwargs)
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   450
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   451
  @decorators.merge_params
00293057b009 Added proposal withdrawal for students.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1491
diff changeset
   452
  @decorators.check_access
1484
6b00a2a43eaf Changed the method and variable name in student_proposal to match the access type.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1482
diff changeset
   453
  def listOrgs(self, request, access_type,
1491
acf7e32de8ca Style fixes in student_proposal and organization view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1484
diff changeset
   454
               page_name=None, params=None, **kwargs):
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   455
    """Lists all organization which the given student can propose to.
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   456
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   457
    For params see base.View.public().
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   458
    """
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   459
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   460
    from soc.views.models import organization as org_view
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   461
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   462
    student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path'])
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   463
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   464
    filter = {'scope' : student_entity.scope,
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   465
              'status': 'active'}
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   466
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   467
    list_params = org_view.view.getParams().copy()
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   468
    list_params['list_description'] = ('List of %(name_plural)s you can send '
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   469
        'your proposal to.') % list_params
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   470
    list_params['list_action'] = (redirects.getStudentProposalRedirect,
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   471
        {'student_key': student_entity.key().name(),
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   472
            'url_name': params['url_name']})
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   473
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   474
    return self.list(request, access_type=access_type, page_name=page_name,
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   475
                     params=list_params, filter=filter, **kwargs)
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   476
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   477
  @decorators.merge_params
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   478
  @decorators.check_access
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   479
  def listSelf(self, request, access_type,
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   480
             page_name=None, params=None, **kwargs):
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   481
    """Lists all proposals from the current logged-in user 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   482
       for the given student.
1482
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   483
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   484
    For params see base.View.public().
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   485
    """
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   486
5229a40d4792 Added view which lists all orgs a student can propose to.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1469
diff changeset
   487
    student_entity = student_logic.logic.getFromKeyName(kwargs['scope_path'])
1469
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   488
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   489
    filter = {'scope' : student_entity,
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   490
              'status': ['new', 'pending', 'accepted', 'rejected']}
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   491
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   492
    list_params = params.copy()
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   493
    list_params['list_description'] = 'List of my %(name_plural)s' % list_params
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   494
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   495
    return self.list(request, access_type=access_type, page_name=page_name,
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   496
                     params=list_params, filter=filter, **kwargs)
d69b00439d59 Added listing of your own student proposals.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1467
diff changeset
   497
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   498
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   499
  @decorators.merge_params
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   500
  @decorators.check_access
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   501
  def review(self, request, access_type,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   502
             page_name=None, params=None, **kwargs):
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   503
    """View that allows Organization Admins and Mentors to review the proposal.
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   504
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   505
       For Args see base.View.public().
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   506
    """
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   507
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   508
    try:
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   509
      entity = self._logic.getFromKeyFieldsOr404(kwargs)
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   510
    except out_of_band.Error, error:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   511
      return helper.responses.errorResponse(
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   512
          error, request, template=params['error_public'])
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   513
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   514
    # get the context for this webpage
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   515
    context = responses.getUniversalContext(request)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   516
    responses.useJavaScript(context, params['js_uses_all'])
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   517
    context['page_name'] = page_name
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   518
    context['entity'] = entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   519
    context['entity_type'] = params['name']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   520
    context['entity_type_url'] = params['url_name']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   521
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   522
    # get the roles important for reviewing an application
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   523
    filter = {'user': user_logic.logic.getForCurrentAccount(),
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   524
        'scope': entity.org,
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   525
        'status': 'active'}
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   526
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   527
    org_admin_entity = org_admin_logic.logic.getForFields(filter, unique=True)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   528
    mentor_entity = mentor_logic.logic.getForFields(filter, unique=True)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   529
1639
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   530
    # check if the current user is a mentor and wants 
170ac4ca078d Fix too long lines in soc.views.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1620
diff changeset
   531
    # to change his role for this app
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   532
    choice = request.GET.get('mentor')
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   533
    if mentor_entity and choice:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   534
      self._adjustPossibleMentors(entity, mentor_entity, choice)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   535
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   536
    # decide which form to use
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   537
    if org_admin_entity:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   538
      form = params['admin_review_form']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   539
    else:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   540
      form = params['mentor_review_form']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   541
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   542
    if request.method == 'POST':
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   543
      return self.reviewPost(request, context, params, entity,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   544
                             form, org_admin_entity, mentor_entity, **kwargs)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   545
    else:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   546
      # request.method == 'GET'
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   547
      return self.reviewGet(request, context, params, entity,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   548
                            form, org_admin_entity, mentor_entity, **kwargs)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   549
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   550
  def reviewPost(self, request, context, params, entity, form,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   551
                 org_admin, mentor, **kwargs):
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   552
    """Handles the POST request for the proposal review view.
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   553
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   554
    Args:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   555
        entity: the student proposal entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   556
        form: the form to use in this view
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   557
        org_admin: org admin entity for the current user/proposal (iff available)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   558
        mentor: mentor entity for the current user/proposal (iff available)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   559
        rest: see base.View.public()
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   560
    """
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   561
    # populate the form using the POST data
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   562
    form = form(request.POST)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   563
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   564
    if not form.is_valid():
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   565
      # return the invalid form response
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   566
      # get all the extra information that should be in the context
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   567
      review_context = self._getDefaultReviewContext(entity, org_admin, mentor)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   568
      context = dicts.merge(context, review_context)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   569
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   570
      return self._constructResponse(request, entity=entity, context=context,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   571
          form=form, params=params, template=params['review_template'])
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   572
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   573
    fields = form.cleaned_data
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   574
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   575
    if org_admin:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   576
      # org admin found, try to adjust the assigned mentor
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   577
      self._adjustMentor(entity, fields['mentor'])
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   578
      reviewer = org_admin
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   579
    else:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   580
      # might be None (if Host or Developer is commenting)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   581
      reviewer = mentor
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   582
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   583
    is_public = fields['public']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   584
    comment = fields['comment']
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   585
    given_score = int(fields['score'])
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   586
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   587
    if reviewer and (not is_public) and (given_score is not 0):
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   588
      # if it is not a public comment and it's made by a member of the
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   589
      # organization we update the score of the proposal
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   590
      new_score = given_score + entity.score
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   591
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   592
      properties = {'score': new_score}
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   593
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   594
      # if the proposal is new we change it status to pending
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   595
      if entity.status == 'new':
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   596
        properties['status'] = 'pending'
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   597
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   598
      # update the proposal with the new score
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   599
      self._logic.updateEntityProperties(entity, properties)
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   600
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   601
    # create the review entity
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   602
    if comment or (given_score is not 0):
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   603
      self._createReviewFor(entity, reviewer, comment, given_score, is_public)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   604
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   605
    # redirect to the same page
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   606
    return http.HttpResponseRedirect('')
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   607
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   608
  def reviewGet(self, request, context, params, entity, form,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   609
                 org_admin, mentor, **kwargs):
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   610
    """Handles the GET request for the proposal review view.
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   611
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   612
    Args:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   613
        entity: the student proposal entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   614
        form: the form to use in this view
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   615
        org_admin: org admin entity for the current user/proposal (iff available)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   616
        mentor: mentor entity for the current user/proposal (iff available)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   617
        rest: see base.View.public()
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   618
    """
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   619
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   620
    # set the initial score since the default is ignored
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   621
    initial = {'score': 0}
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   622
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   623
    if org_admin and entity.mentor:
1620
45f4e9cd9100 Added access check to student_proposal review.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1613
diff changeset
   624
      # set the mentor field to the current mentor
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   625
      initial['mentor'] = entity.mentor.link_id
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   626
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   627
    context['form'] = form(initial)
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   628
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   629
    # get all the extra information that should be in the context
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   630
    review_context = self._getDefaultReviewContext(entity, org_admin, mentor)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   631
    context = dicts.merge(context, review_context)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   632
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   633
    template = params['review_template']
1666
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   634
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   635
    return responses.respond(request, template, context=context)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   636
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   637
  def _getDefaultReviewContext(self, entity, org_admin,
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   638
                               mentor):
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   639
    """Returns the default context for the review page
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   640
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   641
    Args:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   642
      entity: Student Proposal entity
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   643
      org_admin: org admin entity for the current user/proposal (iff available)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   644
      mentor: mentor entity for the current user/proposal (iff available)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   645
    """
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   646
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   647
    from soc.logic.models.review import logic as review_logic
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   648
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   649
    context = {}
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   650
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   651
    context['student_name'] = entity.scope.name()
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   652
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   653
    if entity.mentor:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   654
      context['mentor_name'] = entity.mentor.name()
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   655
    else:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   656
      context['mentor_name'] = "No mentor assigned"
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   657
1666
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   658
    # set the possible mentors in the context
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   659
    possible_mentors = entity.possible_mentors
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   660
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   661
    if not possible_mentors:
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   662
      context['possible_mentors'] = "None"
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   663
    else:
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   664
      mentor_names = []
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   665
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   666
      for mentor_key in possible_mentors:
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   667
        possible_mentor = mentor_logic.logic.getFromKeyName(mentor_key.name())
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   668
        mentor_names.append(possible_mentor.name())
1666
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   669
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   670
      context['possible_mentors'] = ', '.join(mentor_names)
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   671
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   672
    # TODO(ljvderijk) listing of total given scores per mentor
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   673
    # a dict with key as role.user ?
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   674
1741
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   675
    # order the reviews by ascending creation date
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   676
    order = ['created']
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   677
1741
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   678
    # get the public reviews
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   679
    context['public_reviews'] = review_logic.getReviewsForEntity(entity,
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   680
        is_public=True, order=order)
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   681
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   682
    # get the private reviews
1741
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   683
    context['private_reviews'] = review_logic.getReviewsForEntity(entity,
0da1285f5bc0 Public reviews are now shown on the public page for the student proposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1715
diff changeset
   684
        is_public=False, order=order)
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   685
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   686
    # which button should we show to the mentor?
1666
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   687
    if mentor:
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   688
      if mentor.key() in possible_mentors:
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   689
        # show "No longer willing to mentor"
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   690
        context['remove_me_as_mentor'] = True
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   691
      else:
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   692
        # show "I am willing to mentor"
cdb7e5581694 Mentor buttons only show up depending on if you are already on the possible mentors list.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1639
diff changeset
   693
        context['add_me_as_mentor'] = True
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   694
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   695
    return context
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   696
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   697
  def _adjustPossibleMentors(self, entity, mentor, choice):
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   698
    """Adjusts the possible mentors list for a proposal.
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   699
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   700
    Args:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   701
      entity: Student Proposal entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   702
      mentor: Mentor entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   703
      choice: 1 means want to mentor, 0 do not want to mentor
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   704
    """
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   705
    possible_mentors = entity.possible_mentors
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   706
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   707
    if choice == '1':
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   708
      # add the mentor to possible mentors list if not already in
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   709
      if mentor.key() not in possible_mentors:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   710
        possible_mentors.append(mentor.key())
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   711
        fields = {'possible_mentors': possible_mentors}
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   712
        self._logic.updateEntityProperties(entity, fields)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   713
    elif choice == '0':
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   714
      # remove the mentor from the possible mentors list
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   715
      if mentor.key() in possible_mentors:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   716
        possible_mentors.remove(mentor.key())
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   717
        fields = {'possible_mentors': possible_mentors}
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   718
        self._logic.updateEntityProperties(entity, fields)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   719
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   720
  def _adjustMentor(self, entity, mentor_id):
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   721
    """Changes the mentor to the given link_id.
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   722
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   723
    Args:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   724
      entity: Student Proposal entity
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   725
      mentor_id: Link ID of the mentor that needs to be assigned
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   726
                 Iff not given then removes the assigned mentor
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   727
    """
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   728
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   729
    if entity.mentor and entity.mentor.link_id == mentor_id:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   730
      # no need to change
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   731
      return
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   732
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   733
    if mentor_id:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   734
      # try to locate the mentor
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   735
      fields = {'link_id': mentor_id,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   736
                'scope': entity.org,
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   737
                'status': 'active'}
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   738
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   739
      mentor_entity = mentor_logic.logic.getForFields(fields, unique=True)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   740
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   741
      if not mentor_entity:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   742
        # no mentor found, do not update
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   743
        return
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   744
    else:
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   745
      # reset to None
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   746
      mentor_entity = None
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   747
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   748
    # update the proposal
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   749
    properties = {'mentor': mentor_entity}
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   750
    self._logic.updateEntityProperties(entity, properties)
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   751
1752
255117ccd6a0 The student proposal public page can now be used to place a public comment.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1741
diff changeset
   752
  def _createReviewFor(self, entity, reviewer, comment, score=0, is_public=True):
1715
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   753
    """Creates a review for the given proposal.
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   754
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   755
    Args:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   756
      entity: Student Proposal entity for which the review should be created
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   757
      reviewer: A role entity of the reviewer (if possible, else None)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   758
      comment: The textual contents of the review
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   759
      score: The score of the review (only used if the review is not public)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   760
      is_public: Determines if the review is a public review
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   761
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   762
    Returns:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   763
      - The newly created review
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   764
    """
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   765
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   766
    import time
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   767
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   768
    from soc.logic.models.review import logic as review_logic
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   769
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   770
    # create the fields for the review entity
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   771
    fields = {'link_id': 't%i' %(time.time()),
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   772
        'scope': entity,
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   773
        'scope_path': entity.key().name(),
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   774
        'author': user_logic.logic.getForCurrentAccount(),
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   775
        'content': comment,
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   776
        'is_public': is_public,
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   777
        'reviewer': reviewer
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   778
        }
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   779
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   780
    # add the given score if the review is not public
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   781
    if not is_public:
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   782
      fields['score'] = score
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   783
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   784
    key_name = review_logic.getKeyNameFromFields(fields)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   785
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   786
    return review_logic.updateOrCreateFromKeyName(fields, key_name)
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   787
3ec1a9518452 Added the review capability to the student_proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1666
diff changeset
   788
1426
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   789
view = View()
dc3a7f618b68 Added student_proposal view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   790
1584
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   791
admin = decorators.view(view.admin)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   792
apply = decorators.view(view.apply)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   793
create = decorators.view(view.create)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   794
delete = decorators.view(view.delete)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   795
edit = decorators.view(view.edit)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   796
list = decorators.view(view.list)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   797
list_orgs = decorators.view(view.listOrgs)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   798
list_self = decorators.view(view.listSelf)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   799
public = decorators.view(view.public)
1613
59e5cc89e509 Added student proposal review page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1584
diff changeset
   800
review = decorators.view(view.review)
1584
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   801
export = decorators.view(view.export)
d8ba8c917f37 Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1569
diff changeset
   802
pick = decorators.view(view.pick)