author | Todd Larsen <tlarsen@google.com> |
Wed, 15 Oct 2008 19:33:50 +0000 | |
changeset 342 | 72482d8e5b34 |
parent 338 | 0d78f41dde9b |
child 347 | 52676c696cd4 |
permissions | -rw-r--r-- |
79
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
88
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
17 |
"""Site-wide Melange home page views. |
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
18 |
|
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
19 |
public: how the general public sees the site home page of a Melange |
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
20 |
site |
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
21 |
|
164
afdf502c6cc4
Documentation updates and one typo fix.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
142
diff
changeset
|
22 |
edit: site settings view for logged-in Developers |
79
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
""" |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
__authors__ = [ |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
26 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
27 |
] |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
|
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
29 |
|
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
30 |
from google.appengine.api import users |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
31 |
from google.appengine.ext import db |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
32 |
|
324
05e21c089be6
Add missing import in soc/views/site/sponsor/list.py which caused exception when app was deployed and first site you visited was "List Site Sponsors". Update files according to recent django update and django backwards incompatibility (for example newforms is changed to forms).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
321
diff
changeset
|
33 |
from django import forms |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
34 |
from django import http |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
35 |
from django import shortcuts |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
36 |
|
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
305
diff
changeset
|
37 |
from soc.logic import models |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
38 |
from soc.logic import out_of_band |
249
325fb70c61a9
Replace common module with validate module. Move validation function from feed module to validate module and remove feed.py. Correct any usage of validation functions from common and feed modules into validate module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
225
diff
changeset
|
39 |
from soc.logic import validate |
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
305
diff
changeset
|
40 |
from soc.logic.models import document |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
41 |
from soc.logic.site import id_user |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
42 |
from soc.views import simple |
270
7dd6d8347b56
Move helpers/template_helpers.py to helper/templates.py.
Todd Larsen <tlarsen@google.com>
parents:
249
diff
changeset
|
43 |
from soc.views import helper |
303
4f1bb54ddae5
Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
299
diff
changeset
|
44 |
from soc.views.helper import access |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
45 |
|
319
4e336befdf86
Rename soc/logic/models/settings.py to model site_settings.py and apply import name change to soc/views/site/home.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
317
diff
changeset
|
46 |
import soc.logic.models.site_settings |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
47 |
import soc.models.document |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
48 |
import soc.models.site_settings |
274
56e1c1721299
Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents:
272
diff
changeset
|
49 |
import soc.views.helper.forms |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
50 |
import soc.views.helper.responses |
270
7dd6d8347b56
Move helpers/template_helpers.py to helper/templates.py.
Todd Larsen <tlarsen@google.com>
parents:
249
diff
changeset
|
51 |
import soc.views.helper.templates |
271
01e90bb21b7e
Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents:
270
diff
changeset
|
52 |
import soc.views.helper.widgets |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
53 |
import soc.views.out_of_band |
79
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
|
88
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
55 |
|
274
56e1c1721299
Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents:
272
diff
changeset
|
56 |
class DocumentForm(helper.forms.DbModelForm): |
338
0d78f41dde9b
Show "Created by" read-only field in Document Edit view. Update size of TinyMCE widget in Document Edit/Create views. Change user property name to founder in Document model and update files according to this change (now founder is used in Group and Document models). Remove not used variables and imports in views/site/docs/edit.py. Refactor EditForm and CreateForm in views/site/docs/edit.py so that EditForm inherits from CreateForm and just extends it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
57 |
content = forms.fields.CharField(widget=helper.widgets.TinyMCE( |
0d78f41dde9b
Show "Created by" read-only field in Document Edit view. Update size of TinyMCE widget in Document Edit/Create views. Change user property name to founder in Document model and update files according to this change (now founder is used in Group and Document models). Remove not used variables and imports in views/site/docs/edit.py. Refactor EditForm and CreateForm in views/site/docs/edit.py so that EditForm inherits from CreateForm and just extends it.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
58 |
attrs={'rows':10, 'cols':40})) |
271
01e90bb21b7e
Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents:
270
diff
changeset
|
59 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
60 |
class Meta: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
61 |
"""Inner Meta class that defines some behavior for the form. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
62 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
63 |
#: db.Model subclass for which the form will gather information |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
64 |
model = soc.models.document.Document |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
65 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
66 |
#: list of model fields which will *not* be gathered by the form |
225
2590d6b83568
Add functions to soc/logic/document.py for dealing with partial_paths combined
Todd Larsen <tlarsen@google.com>
parents:
206
diff
changeset
|
67 |
exclude = ['partial_path', 'link_name', |
342
72482d8e5b34
Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents:
338
diff
changeset
|
68 |
'author', 'modified', 'created', 'inheritance_line'] |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
69 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
70 |
|
274
56e1c1721299
Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents:
272
diff
changeset
|
71 |
class SiteSettingsForm(helper.forms.DbModelForm): |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
72 |
"""Django form displayed when creating or editing Site Settings. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
73 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
74 |
class Meta: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
75 |
"""Inner Meta class that defines some behavior for the form. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
76 |
""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
77 |
#: db.Model subclass for which the form will gather information |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
78 |
model = soc.models.site_settings.SiteSettings |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
79 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
80 |
#: list of model fields which will *not* be gathered by the form |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
81 |
exclude = ['inheritance_line', 'home'] |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
82 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
83 |
def clean_feed_url(self): |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
84 |
feed_url = self.cleaned_data.get('feed_url') |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
85 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
86 |
if feed_url == '': |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
87 |
# feed url not supplied (which is OK), so do not try to validate it |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
88 |
return None |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
89 |
|
249
325fb70c61a9
Replace common module with validate module. Move validation function from feed module to validate module and remove feed.py. Correct any usage of validation functions from common and feed modules into validate module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
225
diff
changeset
|
90 |
if not validate.isFeedURLValid(feed_url): |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
91 |
raise forms.ValidationError('This URL is not a valid ATOM or RSS feed.') |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
92 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
93 |
return feed_url |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
94 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
95 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
96 |
DEF_SITE_SETTINGS_PATH = 'site' |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
97 |
DEF_SITE_HOME_DOC_LINK_NAME = 'home' |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
98 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
99 |
DEF_SITE_HOME_PUBLIC_TMPL = 'soc/site/home/public.html' |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
100 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
101 |
def public(request, template=DEF_SITE_HOME_PUBLIC_TMPL): |
88
9a8180f0941a
Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents:
81
diff
changeset
|
102 |
"""How the "general public" sees the Melange site home page. |
79
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
103 |
|
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
104 |
Args: |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
105 |
request: the standard django request object. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
106 |
template: the template path to use for rendering the template. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
107 |
|
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
108 |
Returns: |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
109 |
A subclass of django.http.HttpResponse with generated template. |
58001ec7720c
Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
110 |
""" |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
111 |
# create default template context for use with any templates |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
112 |
context = helper.responses.getUniversalContext(request) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
113 |
|
319
4e336befdf86
Rename soc/logic/models/settings.py to model site_settings.py and apply import name change to soc/views/site/home.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
317
diff
changeset
|
114 |
site_settings = soc.logic.models.site_settings.logic.getFromFields( |
321
f17ecd21ca33
Some indentations fixes. Changed all the email=id function arguments to email=id.email().
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
319
diff
changeset
|
115 |
path=DEF_SITE_SETTINGS_PATH) |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
116 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
117 |
if site_settings: |
285
52e206a6a417
Style fix, as requested by Todd to dict usage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
274
diff
changeset
|
118 |
context['site_settings'] = site_settings |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
119 |
|
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
120 |
# check if ReferenceProperty to home Document is valid |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
121 |
try: |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
122 |
site_doc = site_settings.home |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
123 |
except db.Error: |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
124 |
site_doc = None |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
125 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
126 |
if site_doc: |
270
7dd6d8347b56
Move helpers/template_helpers.py to helper/templates.py.
Todd Larsen <tlarsen@google.com>
parents:
249
diff
changeset
|
127 |
site_doc.content = helper.templates.unescape(site_doc.content) |
285
52e206a6a417
Style fix, as requested by Todd to dict usage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
274
diff
changeset
|
128 |
context['site_document'] = site_doc |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
129 |
|
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
130 |
return helper.responses.respond(request, template, context=context) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
131 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
132 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
133 |
DEF_SITE_HOME_EDIT_TMPL = 'soc/site/home/edit.html' |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
134 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
135 |
def edit(request, template=DEF_SITE_HOME_EDIT_TMPL): |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
136 |
"""View for Developer to edit content of Melange site home page. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
137 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
138 |
Args: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
139 |
request: the standard django request object. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
140 |
template: the template path to use for rendering the template. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
141 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
142 |
Returns: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
143 |
A subclass of django.http.HttpResponse with generated template. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
144 |
""" |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
145 |
|
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
146 |
try: |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
147 |
access.checkIsDeveloper(request) |
303
4f1bb54ddae5
Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
299
diff
changeset
|
148 |
except soc.views.out_of_band.AccessViolationResponse, alt_response: |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
149 |
return alt_response.response() |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
150 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
151 |
# create default template context for use with any templates |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
152 |
context = helper.responses.getUniversalContext(request) |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
153 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
154 |
settings_form = None |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
155 |
document_form = None |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
156 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
157 |
if request.method == 'POST': |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
158 |
document_form = DocumentForm(request.POST) |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
159 |
settings_form = SiteSettingsForm(request.POST) |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
160 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
161 |
if document_form.is_valid() and settings_form.is_valid(): |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
162 |
link_name = DEF_SITE_HOME_DOC_LINK_NAME |
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
163 |
partial_path=DEF_SITE_SETTINGS_PATH |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
164 |
logged_in_id = users.get_current_user() |
342
72482d8e5b34
Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents:
338
diff
changeset
|
165 |
author = models.user.logic.getFromFields(email=logged_in_id.email()) |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
290
diff
changeset
|
166 |
|
305
972d28056d9d
Minor style and import fixes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
167 |
properties = { |
317
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
168 |
'title': document_form.cleaned_data.get('title'), |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
169 |
'short_name': document_form.cleaned_data.get('short_name'), |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
170 |
'abstract': document_form.cleaned_data.get('abstract'), |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
171 |
'content': document_form.cleaned_data.get('content'), |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
172 |
'link_name': link_name, |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
173 |
'partial_path': partial_path, |
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
174 |
'id': logged_in_id, |
342
72482d8e5b34
Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents:
338
diff
changeset
|
175 |
'author': author, |
305
972d28056d9d
Minor style and import fixes
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
176 |
} |
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
177 |
|
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
305
diff
changeset
|
178 |
site_doc = document.logic.updateOrCreateFromFields( |
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
179 |
properties, partial_path=partial_path, link_name=link_name) |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
180 |
|
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
181 |
feed_url = settings_form.cleaned_data.get('feed_url') |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
182 |
|
319
4e336befdf86
Rename soc/logic/models/settings.py to model site_settings.py and apply import name change to soc/views/site/home.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
317
diff
changeset
|
183 |
site_settings = models.site_settings.logic.updateOrCreateFromFields( |
317
87215136c268
Remove spaces between dict key name and colon. Fix some typos based on comments http://code.google.com/p/soc/source/detail?r=739.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
314
diff
changeset
|
184 |
{'feed_url': feed_url, 'home': site_doc}, path=DEF_SITE_SETTINGS_PATH) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
185 |
|
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
285
diff
changeset
|
186 |
context['notice'] = 'Site Settings saved.' |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
187 |
else: # request.method == 'GET' |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
188 |
# try to fetch SiteSettings entity by unique key_name |
319
4e336befdf86
Rename soc/logic/models/settings.py to model site_settings.py and apply import name change to soc/views/site/home.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
317
diff
changeset
|
189 |
site_settings = models.site_settings.logic.getFromFields( |
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
190 |
path=DEF_SITE_SETTINGS_PATH) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
191 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
192 |
if site_settings: |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
193 |
# populate form with the existing SiteSettings entity |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
194 |
settings_form = SiteSettingsForm(instance=site_settings) |
314
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
195 |
|
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
196 |
# check if ReferenceProperty to home Document is valid |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
197 |
try: |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
198 |
site_doc = site_settings.home |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
199 |
except db.Error: |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
200 |
site_doc = None |
dfaf249c12b2
Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
311
diff
changeset
|
201 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
202 |
else: |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
203 |
# no SiteSettings entity exists for this key_name, so show a blank form |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
204 |
settings_form = SiteSettingsForm() |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
205 |
site_doc = None |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
206 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
207 |
if site_doc: |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
208 |
# populate form with the existing Document entity |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
164
diff
changeset
|
209 |
document_form = DocumentForm(instance=site_doc) |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
210 |
else: |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
211 |
# no Document entity exists for this key_name, so show a blank form |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
212 |
document_form = DocumentForm() |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
213 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
214 |
context.update({'document_form': document_form, |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
215 |
'settings_form': settings_form }) |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
88
diff
changeset
|
216 |
|
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
217 |
return helper.responses.respond(request, template, context) |