| author | Lennard de Rijk <ljvderijk@gmail.com> |
| Sat, 24 Jan 2009 10:19:17 +0000 | |
| changeset 944 | 5ea2bd9e3fa6 |
| parent 920 | 39badbfb80be |
| child 959 | b6e8750c9407 |
| permissions | -rw-r--r-- |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
|
404
44223e50e1fc
Added a Host profile and generalized some views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
402
diff
changeset
|
17 |
"""Views for Host profiles. |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
|
429
e50e18936f06
Fixed typo in e-mail address
Sverre Rabbelier <srabbelier@gmail.com>
parents:
413
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
] |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
26 |
from django import forms |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
27 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
28 |
from soc.logic import cleaning |
|
725
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
29 |
from soc.logic import accounts |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
from soc.logic import dicts |
|
725
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
31 |
from soc.logic.models import host as host_logic |
| 575 | 32 |
from soc.logic.models import user as user_logic |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
33 |
from soc.logic.models import sponsor as sponsor_logic |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from soc.views import helper |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
35 |
from soc.views.helper import access |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
36 |
from soc.views.helper import dynaform |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
37 |
from soc.views.helper import widgets |
|
494
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
38 |
from soc.views.models import role |
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
39 |
from soc.views.models import sponsor as sponsor_view |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
|
|
404
44223e50e1fc
Added a Host profile and generalized some views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
402
diff
changeset
|
41 |
import soc.models.host |
|
44223e50e1fc
Added a Host profile and generalized some views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
402
diff
changeset
|
42 |
import soc.logic.models.host |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
import soc.views.helper |
|
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
44 |
import soc.views.models.sponsor |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
|
|
744
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
725
diff
changeset
|
46 |
# TODO(pawel.solyga): Rename all list methods and functions to something else |
|
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
725
diff
changeset
|
47 |
# and remove this tolist assignment |
|
725
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
48 |
tolist = list |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
49 |
|
|
657
c781de4f6d39
Rename role.RoleView to role.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
50 |
class View(role.View): |
|
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
497
diff
changeset
|
51 |
"""View methods for the Host model. |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
""" |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
|
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
54 |
def __init__(self, params=None): |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
"""Defines the fields and methods required for the base View class |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
to provide the user with list, public, create, edit and delete views. |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
|
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
Params: |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
59 |
params: a dict with params for this View |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
""" |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
|
|
617
9cc42981d40a
Now invited users can create a new Host profile
Sverre Rabbelier <srabbelier@gmail.com>
parents:
616
diff
changeset
|
62 |
rights = {}
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
63 |
rights['create'] = [access.checkIsHost] |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
64 |
rights['edit'] = [access.checkIsMyActiveRole(soc.logic.models.host)] |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
65 |
rights['invite'] = [access.checkIsHost] |
|
725
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
66 |
rights['list'] = [access.checkIsHost] |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
67 |
rights['accept_invite'] = [access.checkCanCreateFromRequest('host')]
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
68 |
|
|
617
9cc42981d40a
Now invited users can create a new Host profile
Sverre Rabbelier <srabbelier@gmail.com>
parents:
616
diff
changeset
|
69 |
|
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
70 |
new_params = {}
|
|
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
71 |
new_params['rights'] = rights |
|
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
72 |
new_params['logic'] = soc.logic.models.host.logic |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
73 |
new_params['group_logic'] = sponsor_logic.logic |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
|
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
75 |
new_params['scope_view'] = sponsor_view |
|
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
76 |
|
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
77 |
new_params['group_view'] = soc.views.models.sponsor.view |
|
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
78 |
new_params['invite_filter'] = {'group_ln': 'link_id'}
|
|
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
494
diff
changeset
|
79 |
|
|
716
26dc12dae79f
Changed "Sponsor" to "Program Owner"
Lennard de Rijk <ljvderijk@gmail.com>
parents:
710
diff
changeset
|
80 |
new_params['name'] = "Program Administrator" |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
81 |
new_params['module_name'] = "host" |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
83 |
new_params['extra_dynaexclude'] = ['user', 'state'] |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
84 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
85 |
new_params['create_extra_dynafields'] = {
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
86 |
'scope_path': forms.CharField(widget=forms.HiddenInput, |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
87 |
required=True), |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
88 |
'clean_link_id' : cleaning.clean_existing_user('link_id'),
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
89 |
'clean_home_page' : cleaning.clean_url('home_page'),
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
90 |
'clean_blog' : cleaning.clean_url('blog'),
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
91 |
'clean_photo_url' : cleaning.clean_url('photo_url')}
|
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
|
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
93 |
params = dicts.merge(params, new_params) |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
|
|
657
c781de4f6d39
Rename role.RoleView to role.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
95 |
super(View, self).__init__(params=params) |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
97 |
# create and store the special form for invited users |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
98 |
updated_fields = {
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
99 |
'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
100 |
required=False)} |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
101 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
102 |
invited_create_form = dynaform.extendDynaForm( |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
103 |
dynaform = self._params['create_form'], |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
104 |
dynafields = updated_fields) |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
105 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
106 |
params['invited_create_form'] = invited_create_form |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
107 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
108 |
|
|
744
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
725
diff
changeset
|
109 |
def list(self, request, access_type, page_name=None, |
|
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
725
diff
changeset
|
110 |
params=None, filter=None): |
|
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
725
diff
changeset
|
111 |
"""See base.View.list. |
|
725
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
112 |
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
113 |
Passes a filter to base.View.list so that only hosts from a sponsor |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
114 |
that this user is host for are listed. |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
115 |
""" |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
116 |
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
117 |
user = user_logic.logic.getForCurrentAccount() |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
118 |
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
119 |
# Don't bother looking up everything if there's no user |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
120 |
if user and (not accounts.isDeveloper(user=user)): |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
121 |
hosts = host_logic.logic.getForFields({'user': user})
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
122 |
sponsors = tolist((host.scope for host in hosts)) |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
123 |
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
124 |
new_filter = {'scope': sponsors}
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
125 |
filter = dicts.merge(filter, new_filter) |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
126 |
|
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
127 |
return super(View, self).list(request, access_type, page_name=page_name, |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
128 |
params=params, filter=filter) |
|
6180b32d990f
Filter the "list Hosts" view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
716
diff
changeset
|
129 |
|
| 575 | 130 |
def _editPost(self, request, entity, fields): |
131 |
"""See base.View._editPost(). |
|
132 |
""" |
|
133 |
||
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
134 |
fields['user'] = fields['link_id'] |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
135 |
fields['link_id'] = fields['link_id'].link_id |
| 575 | 136 |
|
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
137 |
super(View, self)._editPost(request, entity, fields) |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
139 |
def _acceptInvitePost(self, fields, request, context, params, **kwargs): |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
140 |
"""Fills in the fields that were missing in the invited_created_form |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
141 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
142 |
For params see base.View._acceptInvitePost() |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
143 |
""" |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
144 |
# fill in the appropriate fields that were missing in the form |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
145 |
fields['user'] = fields['link_id'] |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
146 |
fields['link_id'] = fields['link_id'].link_id |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
147 |
|
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
148 |
|
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
view = View() |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
150 |
|
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
151 |
acceptInvite = view.acceptInvite |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
152 |
create = view.create |
|
404
44223e50e1fc
Added a Host profile and generalized some views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
402
diff
changeset
|
153 |
delete = view.delete |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
154 |
edit = view.edit |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
920
diff
changeset
|
155 |
invite = view.invite |
|
400
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
156 |
list = view.list |
|
8f07048d84ef
Added a generic version of the Document views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
157 |
public = view.public |
|
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
799
diff
changeset
|
158 |
export = view.export |
|
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
799
diff
changeset
|
159 |