app/soc/views/models/request.py
author Todd Larsen <tlarsen@google.com>
Thu, 20 Nov 2008 18:50:30 +0000
changeset 512 aae25d2b4464
parent 507 3603fdafabf7
child 514 55bd39dab49c
permissions -rw-r--r--
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME becomes LINK_ID, "link name" becomes "link id", etc.). Also, rename LINKNAME to LINK_ID. Patch by: Todd Larsen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Requests.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
    '"Pawel Solyga" <pawel.solyga@gmail.com>',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
  ]
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from google.appengine.api import users
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from django import forms
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
from django.utils.translation import ugettext_lazy
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.logic import dicts
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
from soc.logic import validate
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
from soc.logic.models import sponsor as sponsor_logic
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
from soc.logic.models import user as user_logic
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
from soc.views import helper
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
from soc.views.helper import widgets
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
from soc.views.models import base
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
import soc.models.request
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
import soc.logic.models.request
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
import soc.logic.dicts
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
import soc.views.helper
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
import soc.views.helper.widgets
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 495
diff changeset
    46
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
class CreateForm(helper.forms.BaseForm):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
  """Django form displayed when Developer creates a Request.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
  """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
  class Meta:
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    model = soc.models.request.Request
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    #: list of model fields which will *not* be gathered by the form 
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
    exclude = ['inheritance_line', 'requester', 'to', 'role', 'declined']
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
  role = forms.CharField(widget=helper.widgets.ReadOnlyInput())
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
  user = forms.CharField(
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
      label=soc.models.request.Request.requester.verbose_name,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
      help_text=soc.models.request.Request.requester.help_text,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
      widget=helper.widgets.ReadOnlyInput())  
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
  group = forms.CharField(
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
      label=soc.models.request.Request.to.verbose_name,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
      help_text=soc.models.request.Request.to.help_text,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
      widget=helper.widgets.ReadOnlyInput())
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
  def clean_user(self):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
    self.cleaned_data['requester'] =  user_logic.logic.getForFields(
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
    71
        {'link_id': self.cleaned_data['user']}, unique=True)
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
    return self.cleaned_data['user']
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
  def clean_group(self):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
    self.cleaned_data['to'] = sponsor_logic.logic.getFromFields(
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
    76
        link_id=self.cleaned_data['group'])
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
    return self.cleaned_data['group']
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 495
diff changeset
    79
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
class EditForm(CreateForm):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    81
  """Django form displayed when Developer edits a Request.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
  """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
  pass
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
class View(base.View):
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 495
diff changeset
    88
  """View methods for the Docs model.
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
  """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
507
3603fdafabf7 Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents: 504
diff changeset
    91
  def __init__(self, original_params=None):
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    92
    """Defines the fields and methods required for the base View class
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
    to provide the user with list, public, create, edit and delete views.
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    95
    Params:
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    96
      original_params: a dict with params for this View
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
    """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
    self._logic = soc.logic.models.request.logic
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
    params = {}
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
    params['name'] = "Request"
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
    params['name_short'] = "Request"
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   105
    params['name_plural'] = "Requests"
502
e1e24c0a4e82 Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 499
diff changeset
   106
    params['url_name'] = "request"
e1e24c0a4e82 Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 499
diff changeset
   107
    params['module_name'] = "request"
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
    params['edit_form'] = EditForm
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
    params['create_form'] = CreateForm
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   111
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   112
    # TODO(tlarsen) Add support for Django style template lookup
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
    params['edit_template'] = 'soc/models/edit.html'
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
    params['public_template'] = 'soc/request/public.html'
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
    params['list_template'] = 'soc/models/list.html'
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   116
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   117
    params['lists_template'] = {
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   118
      'list_main': 'soc/list/list_main.html',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
      'list_pagination': 'soc/list/list_pagination.html',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
      'list_row': 'soc/request/list/request_row.html',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   121
      'list_heading': 'soc/request/list/request_heading.html',
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
    }
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
    params['sidebar_defaults'] = [('/%s/list', 'List %(plural)s')]
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
502
e1e24c0a4e82 Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 499
diff changeset
   126
    params['delete_redirect'] = '/' + params['url_name'] + '/list'
504
25156c768e7f Fix not working request creation.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 502
diff changeset
   127
    params['create_redirect'] = '/' + params['url_name']
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
    params['save_message'] = [ugettext_lazy('Request saved.')]
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
    params['edit_params'] = {
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
        self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
        }
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
507
3603fdafabf7 Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents: 504
diff changeset
   135
    params = dicts.merge(original_params, params)
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
507
3603fdafabf7 Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents: 504
diff changeset
   137
    base.View.__init__(self, params=params)
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   138
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   139
  def _editSeed(self, request, seed):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
    """See base.View._editGet().
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   141
    """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
    # fill in the email field with the data from the entity
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
    seed['user'] = seed['user_ln']
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   145
    seed['group'] = seed['group_ln']
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   146
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
  def _editGet(self, request, entity, form):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   148
    """See base.View._editGet().
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   149
    """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   150
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   151
    # fill in the email field with the data from the entity
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
   152
    form.fields['user'].initial = entity.requester.link_id
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
   153
    form.fields['group'].initial = entity.to.link_id 
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
  def _editPost(self, request, entity, fields):
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   156
    """See base.View._editPost().
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   157
    """
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   159
    # fill in the account field with the user created from email
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
   160
    fields['user_ln'] = fields['requester'].link_id
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 507
diff changeset
   161
    fields['group_ln'] = fields['to'].link_id
495
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   162
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   163
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   164
view = View()
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   165
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   166
create = view.create
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   167
edit = view.edit
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   168
delete = view.delete
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   169
list = view.list
87afae6e4c51 Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   170
public = view.public