Merge lp:~mhall119/ubuntu-api-website/content-editing into lp:ubuntu-api-website
- content-editing
- Merge into trunk
Proposed by
Michael Hall
Status: | Merged |
---|---|
Approved by: | Michael Hall |
Approved revision: | no longer in the source branch. |
Merged at revision: | 42 |
Proposed branch: | lp:~mhall119/ubuntu-api-website/content-editing |
Merge into: | lp:ubuntu-api-website |
Diff against target: |
1089 lines (+761/-26) 24 files modified
developer_network/common/fixtures/auth_group.json (+1/-0) developer_network/common/management/commands/initdb.py (+62/-0) developer_network/common/templates/500.html (+10/-0) developer_network/common/templates/login_failure.html (+37/-0) developer_network/common/views.py (+27/-1) developer_network/settings.py (+19/-0) developer_network/urls.py (+30/-1) developer_network/web/static/css/site.css (+60/-22) developer_network/web/templates/web/article.html (+17/-0) developer_network/web/templates/web/distro.html (+20/-0) developer_network/web/templates/web/element.html (+9/-0) developer_network/web/templates/web/element_edit.html (+48/-0) developer_network/web/templates/web/namespace.html (+12/-0) developer_network/web/templates/web/namespace_edit.html (+48/-0) developer_network/web/templates/web/overview.html (+17/-0) developer_network/web/templates/web/page.html (+9/-0) developer_network/web/templates/web/page_edit.html (+25/-0) developer_network/web/templates/web/release.html (+17/-2) developer_network/web/templates/web/search.html (+2/-0) developer_network/web/templates/web/section_edit.html (+25/-0) developer_network/web/templates/web/topic_edit.html (+18/-0) developer_network/web/templates/web/version_edit.html (+23/-0) developer_network/web/views.py (+223/-0) requirements.txt (+2/-0) |
To merge this branch: | bzr merge lp:~mhall119/ubuntu-api-website/content-editing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hall (community) | Approve | ||
Review via email: mp+193481@code.launchpad.net |
Commit message
Adds the ability to edit content on various pages, adds SSO support and gives members of ~api-website-devs edit permissions.
Description of the change
Adds the ability to edit content on various pages, adds SSO support and gives members of ~api-website-devs edit permissions.
To post a comment you must log in.
- 42. By Michael Hall
-
[r=Michael Hall] Adds the ability to edit content on various pages, adds SSO support and gives members of ~api-website-devs edit permissions.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'developer_network/common/fixtures/auth_group.json' | |||
2 | --- developer_network/common/fixtures/auth_group.json 1970-01-01 00:00:00 +0000 | |||
3 | +++ developer_network/common/fixtures/auth_group.json 2013-10-31 19:44:44 +0000 | |||
4 | @@ -0,0 +1,1 @@ | |||
5 | 1 | [{"pk": 1, "model": "auth.permission", "fields": {"codename": "add_permission", "name": "Can add permission", "content_type": 1}}, {"pk": 2, "model": "auth.permission", "fields": {"codename": "change_permission", "name": "Can change permission", "content_type": 1}}, {"pk": 3, "model": "auth.permission", "fields": {"codename": "delete_permission", "name": "Can delete permission", "content_type": 1}}, {"pk": 4, "model": "auth.permission", "fields": {"codename": "add_group", "name": "Can add group", "content_type": 2}}, {"pk": 5, "model": "auth.permission", "fields": {"codename": "change_group", "name": "Can change group", "content_type": 2}}, {"pk": 6, "model": "auth.permission", "fields": {"codename": "delete_group", "name": "Can delete group", "content_type": 2}}, {"pk": 7, "model": "auth.permission", "fields": {"codename": "add_user", "name": "Can add user", "content_type": 3}}, {"pk": 8, "model": "auth.permission", "fields": {"codename": "change_user", "name": "Can change user", "content_type": 3}}, {"pk": 9, "model": "auth.permission", "fields": {"codename": "delete_user", "name": "Can delete user", "content_type": 3}}, {"pk": 10, "model": "auth.permission", "fields": {"codename": "add_message", "name": "Can add message", "content_type": 4}}, {"pk": 11, "model": "auth.permission", "fields": {"codename": "change_message", "name": "Can change message", "content_type": 4}}, {"pk": 12, "model": "auth.permission", "fields": {"codename": "delete_message", "name": "Can delete message", "content_type": 4}}, {"pk": 13, "model": "auth.permission", "fields": {"codename": "add_contenttype", "name": "Can add content type", "content_type": 5}}, {"pk": 14, "model": "auth.permission", "fields": {"codename": "change_contenttype", "name": "Can change content type", "content_type": 5}}, {"pk": 15, "model": "auth.permission", "fields": {"codename": "delete_contenttype", "name": "Can delete content type", "content_type": 5}}, {"pk": 16, "model": "auth.permission", "fields": {"codename": "add_session", "name": "Can add session", "content_type": 6}}, {"pk": 17, "model": "auth.permission", "fields": {"codename": "change_session", "name": "Can change session", "content_type": 6}}, {"pk": 18, "model": "auth.permission", "fields": {"codename": "delete_session", "name": "Can delete session", "content_type": 6}}, {"pk": 19, "model": "auth.permission", "fields": {"codename": "add_site", "name": "Can add site", "content_type": 7}}, {"pk": 20, "model": "auth.permission", "fields": {"codename": "change_site", "name": "Can change site", "content_type": 7}}, {"pk": 21, "model": "auth.permission", "fields": {"codename": "delete_site", "name": "Can delete site", "content_type": 7}}, {"pk": 22, "model": "auth.permission", "fields": {"codename": "add_logentry", "name": "Can add log entry", "content_type": 8}}, {"pk": 23, "model": "auth.permission", "fields": {"codename": "change_logentry", "name": "Can change log entry", "content_type": 8}}, {"pk": 24, "model": "auth.permission", "fields": {"codename": "delete_logentry", "name": "Can delete log entry", "content_type": 8}}, {"pk": 25, "model": "auth.permission", "fields": {"codename": "add_migrationhistory", "name": "Can add migration history", "content_type": 9}}, {"pk": 26, "model": "auth.permission", "fields": {"codename": "change_migrationhistory", "name": "Can change migration history", "content_type": 9}}, {"pk": 27, "model": "auth.permission", "fields": {"codename": "delete_migrationhistory", "name": "Can delete migration history", "content_type": 9}}, {"pk": 28, "model": "auth.permission", "fields": {"codename": "add_topic", "name": "Can add topic", "content_type": 10}}, {"pk": 29, "model": "auth.permission", "fields": {"codename": "change_topic", "name": "Can change topic", "content_type": 10}}, {"pk": 30, "model": "auth.permission", "fields": {"codename": "delete_topic", "name": "Can delete topic", "content_type": 10}}, {"pk": 31, "model": "auth.permission", "fields": {"codename": "add_version", "name": "Can add version", "content_type": 11}}, {"pk": 32, "model": "auth.permission", "fields": {"codename": "change_version", "name": "Can change version", "content_type": 11}}, {"pk": 33, "model": "auth.permission", "fields": {"codename": "delete_version", "name": "Can delete version", "content_type": 11}}, {"pk": 34, "model": "auth.permission", "fields": {"codename": "add_section", "name": "Can add section", "content_type": 12}}, {"pk": 35, "model": "auth.permission", "fields": {"codename": "change_section", "name": "Can change section", "content_type": 12}}, {"pk": 36, "model": "auth.permission", "fields": {"codename": "delete_section", "name": "Can delete section", "content_type": 12}}, {"pk": 37, "model": "auth.permission", "fields": {"codename": "add_namespace", "name": "Can add namespace", "content_type": 13}}, {"pk": 38, "model": "auth.permission", "fields": {"codename": "change_namespace", "name": "Can change namespace", "content_type": 13}}, {"pk": 39, "model": "auth.permission", "fields": {"codename": "delete_namespace", "name": "Can delete namespace", "content_type": 13}}, {"pk": 40, "model": "auth.permission", "fields": {"codename": "add_element", "name": "Can add Rendered Element", "content_type": 14}}, {"pk": 41, "model": "auth.permission", "fields": {"codename": "change_element", "name": "Can change Rendered Element", "content_type": 14}}, {"pk": 42, "model": "auth.permission", "fields": {"codename": "delete_element", "name": "Can delete Rendered Element", "content_type": 14}}, {"pk": 43, "model": "auth.permission", "fields": {"codename": "add_class", "name": "Can add class", "content_type": 15}}, {"pk": 44, "model": "auth.permission", "fields": {"codename": "change_class", "name": "Can change class", "content_type": 15}}, {"pk": 45, "model": "auth.permission", "fields": {"codename": "delete_class", "name": "Can delete class", "content_type": 15}}, {"pk": 46, "model": "auth.permission", "fields": {"codename": "add_bitfield", "name": "Can add bit field", "content_type": 16}}, {"pk": 47, "model": "auth.permission", "fields": {"codename": "change_bitfield", "name": "Can change bit field", "content_type": 16}}, {"pk": 48, "model": "auth.permission", "fields": {"codename": "delete_bitfield", "name": "Can delete bit field", "content_type": 16}}, {"pk": 49, "model": "auth.permission", "fields": {"codename": "add_enum", "name": "Can add enum", "content_type": 17}}, {"pk": 50, "model": "auth.permission", "fields": {"codename": "change_enum", "name": "Can change enum", "content_type": 17}}, {"pk": 51, "model": "auth.permission", "fields": {"codename": "delete_enum", "name": "Can delete enum", "content_type": 17}}, {"pk": 52, "model": "auth.permission", "fields": {"codename": "add_snippet", "name": "Can add snippet", "content_type": 18}}, {"pk": 53, "model": "auth.permission", "fields": {"codename": "change_snippet", "name": "Can change snippet", "content_type": 18}}, {"pk": 54, "model": "auth.permission", "fields": {"codename": "delete_snippet", "name": "Can delete snippet", "content_type": 18}}, {"pk": 55, "model": "auth.permission", "fields": {"codename": "add_image", "name": "Can add image", "content_type": 19}}, {"pk": 56, "model": "auth.permission", "fields": {"codename": "change_image", "name": "Can change image", "content_type": 19}}, {"pk": 57, "model": "auth.permission", "fields": {"codename": "delete_image", "name": "Can delete image", "content_type": 19}}, {"pk": 58, "model": "auth.permission", "fields": {"codename": "add_link", "name": "Can add link", "content_type": 20}}, {"pk": 59, "model": "auth.permission", "fields": {"codename": "change_link", "name": "Can change link", "content_type": 20}}, {"pk": 60, "model": "auth.permission", "fields": {"codename": "delete_link", "name": "Can delete link", "content_type": 20}}, {"pk": 61, "model": "auth.permission", "fields": {"codename": "add_page", "name": "Can add Rendered Page", "content_type": 21}}, {"pk": 62, "model": "auth.permission", "fields": {"codename": "change_page", "name": "Can change Rendered Page", "content_type": 21}}, {"pk": 63, "model": "auth.permission", "fields": {"codename": "delete_page", "name": "Can delete Rendered Page", "content_type": 21}}, {"pk": 64, "model": "auth.permission", "fields": {"codename": "add_nonce", "name": "Can add nonce", "content_type": 22}}, {"pk": 65, "model": "auth.permission", "fields": {"codename": "change_nonce", "name": "Can change nonce", "content_type": 22}}, {"pk": 66, "model": "auth.permission", "fields": {"codename": "delete_nonce", "name": "Can delete nonce", "content_type": 22}}, {"pk": 67, "model": "auth.permission", "fields": {"codename": "add_association", "name": "Can add association", "content_type": 23}}, {"pk": 68, "model": "auth.permission", "fields": {"codename": "change_association", "name": "Can change association", "content_type": 23}}, {"pk": 69, "model": "auth.permission", "fields": {"codename": "delete_association", "name": "Can delete association", "content_type": 23}}, {"pk": 70, "model": "auth.permission", "fields": {"codename": "add_useropenid", "name": "Can add user open id", "content_type": 24}}, {"pk": 71, "model": "auth.permission", "fields": {"codename": "change_useropenid", "name": "Can change user open id", "content_type": 24}}, {"pk": 72, "model": "auth.permission", "fields": {"codename": "delete_useropenid", "name": "Can delete user open id", "content_type": 24}}, {"pk": 1, "model": "auth.group", "fields": {"name": "api-website-devs", "permissions": [40, 41, 42, 37, 38, 39, 61, 62, 63, 34, 35, 36, 28, 29, 30, 31, 32, 33, 55, 56, 57, 58, 59, 60, 52, 53, 54, 46, 47, 48, 43, 44, 45, 49, 50, 51]}}] | ||
6 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
7 | 1 | 3 | ||
8 | === added directory 'developer_network/common/management' | |||
9 | === added file 'developer_network/common/management/__init__.py' | |||
10 | === added directory 'developer_network/common/management/commands' | |||
11 | === added file 'developer_network/common/management/commands/__init__.py' | |||
12 | === added file 'developer_network/common/management/commands/initdb.py' | |||
13 | --- developer_network/common/management/commands/initdb.py 1970-01-01 00:00:00 +0000 | |||
14 | +++ developer_network/common/management/commands/initdb.py 2013-10-31 19:44:44 +0000 | |||
15 | @@ -0,0 +1,62 @@ | |||
16 | 1 | #!/usr/bin/python | ||
17 | 2 | |||
18 | 3 | from django.core.management.base import BaseCommand | ||
19 | 4 | from optparse import make_option | ||
20 | 5 | |||
21 | 6 | import settings | ||
22 | 7 | |||
23 | 8 | import subprocess | ||
24 | 9 | import os | ||
25 | 10 | import sys | ||
26 | 11 | |||
27 | 12 | from common.models import Topic | ||
28 | 13 | from apidocs.models import Element | ||
29 | 14 | from django.contrib.auth.models import Group, Permission | ||
30 | 15 | from django.contrib.contenttypes.models import ContentType | ||
31 | 16 | |||
32 | 17 | PYTHON_BIN = sys.executable | ||
33 | 18 | PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../../')) | ||
34 | 19 | MANAGE_PY = os.path.join(PROJECT_ROOT, 'manage.py') | ||
35 | 20 | COMMON_DATA = os.path.join(PROJECT_ROOT, 'common/fixtures/sample_data.json') | ||
36 | 21 | APIDOCS_DATA = os.path.join(PROJECT_ROOT, 'apidocs/fixtures/sample_data.json') | ||
37 | 22 | |||
38 | 23 | |||
39 | 24 | class Command(BaseCommand): | ||
40 | 25 | help = "Make sure The API Website database is set up properly." | ||
41 | 26 | option_list = BaseCommand.option_list + ( | ||
42 | 27 | make_option( | ||
43 | 28 | "-f", | ||
44 | 29 | "--force", | ||
45 | 30 | dest="force", | ||
46 | 31 | help="Force initialization, even if data already exists", | ||
47 | 32 | action="store_true", | ||
48 | 33 | default=False | ||
49 | 34 | ), | ||
50 | 35 | ) | ||
51 | 36 | |||
52 | 37 | def handle(self, summit='', *args, **options): | ||
53 | 38 | |||
54 | 39 | force = options.get('force', False) | ||
55 | 40 | |||
56 | 41 | if force or Topic.objects.all().count() == 0: | ||
57 | 42 | print "Loading Common data." | ||
58 | 43 | subprocess.call([PYTHON_BIN, MANAGE_PY, "loaddata", COMMON_DATA, | ||
59 | 44 | "--settings", "local_settings"]) | ||
60 | 45 | |||
61 | 46 | if force or Element.objects.all().count() == 0: | ||
62 | 47 | print "Loading API data." | ||
63 | 48 | subprocess.call([PYTHON_BIN, MANAGE_PY, "loaddata", APIDOCS_DATA, | ||
64 | 49 | "--settings", "local_settings"]) | ||
65 | 50 | |||
66 | 51 | if force or not Group.objects.filter(name='api-website-devs').exists(): | ||
67 | 52 | print "Creating api-website-devs group." | ||
68 | 53 | devs, created = Group.objects.get_or_create(name='api-website-devs') | ||
69 | 54 | common_perms = Permission.objects.filter(content_type__app_label='common') | ||
70 | 55 | apidocs_perms = Permission.objects.filter(content_type__app_label='apidocs') | ||
71 | 56 | related_perms = Permission.objects.filter(content_type__app_label='related') | ||
72 | 57 | search_perms = Permission.objects.filter(content_type__app_label='search') | ||
73 | 58 | devs.permissions.add(*list(common_perms)) | ||
74 | 59 | devs.permissions.add(*list(apidocs_perms)) | ||
75 | 60 | devs.permissions.add(*list(related_perms)) | ||
76 | 61 | devs.permissions.add(*list(search_perms)) | ||
77 | 62 | |||
78 | 0 | 63 | ||
79 | === added directory 'developer_network/common/templates' | |||
80 | === added file 'developer_network/common/templates/500.html' | |||
81 | --- developer_network/common/templates/500.html 1970-01-01 00:00:00 +0000 | |||
82 | +++ developer_network/common/templates/500.html 2013-10-31 19:44:44 +0000 | |||
83 | @@ -0,0 +1,10 @@ | |||
84 | 1 | {% extends "base.html" %} | ||
85 | 2 | |||
86 | 3 | {% block page_name %}Oops{%endblock %} | ||
87 | 4 | |||
88 | 5 | {% block sub_nav %}{% endblock %} | ||
89 | 6 | |||
90 | 7 | {% block content %} | ||
91 | 8 | <p>This page encountered an error, don't worry - we have been notified. Please accept our apologies.</p> | ||
92 | 9 | {% endblock %} | ||
93 | 10 | |||
94 | 0 | 11 | ||
95 | === added file 'developer_network/common/templates/login_failure.html' | |||
96 | --- developer_network/common/templates/login_failure.html 1970-01-01 00:00:00 +0000 | |||
97 | +++ developer_network/common/templates/login_failure.html 2013-10-31 19:44:44 +0000 | |||
98 | @@ -0,0 +1,37 @@ | |||
99 | 1 | {% extends "base.html" %} | ||
100 | 2 | |||
101 | 3 | {% block page_name %}Login Failure{%endblock %} | ||
102 | 4 | |||
103 | 5 | {% block defaulthead %} | ||
104 | 6 | {% with '/static/ubuntu-website/' as ubuntu_website_media %} | ||
105 | 7 | {{ block.super }} | ||
106 | 8 | {% endwith %} | ||
107 | 9 | {% endblock %} | ||
108 | 10 | |||
109 | 11 | {% block extrahead %} | ||
110 | 12 | {% with '/static/' as MEDIA_URL %} | ||
111 | 13 | {{ block.super }} | ||
112 | 14 | {% endwith %} | ||
113 | 15 | {% endblock %} | ||
114 | 16 | {% block main_nav_links %}{% endblock %} | ||
115 | 17 | |||
116 | 18 | {% block sub_nav %}{% endblock %} | ||
117 | 19 | |||
118 | 20 | {% block content %} | ||
119 | 21 | |||
120 | 22 | <article class="main-content"> | ||
121 | 23 | <h2>{{message|safe}}</h2> | ||
122 | 24 | |||
123 | 25 | {% if exception %} | ||
124 | 26 | <p>{{exception.message|safe}}</p> | ||
125 | 27 | {% endif %} | ||
126 | 28 | |||
127 | 29 | {% if solution %} | ||
128 | 30 | <p>{{solution|safe}}</p> | ||
129 | 31 | {% endif %} | ||
130 | 32 | |||
131 | 33 | <p>If you continue to experience problems with Summit, please <a href='https://bugs.launchpad.net/summit'>Report it!</a> | ||
132 | 34 | </p> | ||
133 | 35 | </article> | ||
134 | 36 | |||
135 | 37 | {% endblock %} | ||
136 | 0 | 38 | ||
137 | === modified file 'developer_network/common/views.py' | |||
138 | --- developer_network/common/views.py 2013-02-08 22:36:08 +0000 | |||
139 | +++ developer_network/common/views.py 2013-10-31 19:44:44 +0000 | |||
140 | @@ -1,1 +1,27 @@ | |||
142 | 1 | # Create your views here. | 1 | from django.shortcuts import render_to_response, redirect |
143 | 2 | from django.template.loader import render_to_string | ||
144 | 3 | from django.template import RequestContext | ||
145 | 4 | from django.http import HttpResponse, HttpResponseRedirect | ||
146 | 5 | from django.core.urlresolvers import reverse | ||
147 | 6 | from django.contrib.auth import logout | ||
148 | 7 | |||
149 | 8 | def login_failure(request, message, status=403, | ||
150 | 9 | template_name='login_failure.html', | ||
151 | 10 | exception=None): | ||
152 | 11 | """Render an error page to the user.""" | ||
153 | 12 | context = { | ||
154 | 13 | 'message': message, | ||
155 | 14 | 'exception': exception, | ||
156 | 15 | } | ||
157 | 16 | if isinstance(exception, MissingPhysicalMultiFactor): | ||
158 | 17 | context['solution'] = 'Try logging in again using your Yubikey' | ||
159 | 18 | elif isinstance(exception, MissingUsernameViolation): | ||
160 | 19 | context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use The API Website' | ||
161 | 20 | |||
162 | 21 | data = render_to_string(template_name, context, | ||
163 | 22 | context_instance=RequestContext(request)) | ||
164 | 23 | return HttpResponse(data, status=status) | ||
165 | 24 | |||
166 | 25 | def logout_view(request): | ||
167 | 26 | logout(request) | ||
168 | 27 | return HttpResponseRedirect('/') | ||
169 | 2 | 28 | ||
170 | === modified file 'developer_network/settings.py' | |||
171 | --- developer_network/settings.py 2013-09-13 18:35:01 +0000 | |||
172 | +++ developer_network/settings.py 2013-10-31 19:44:44 +0000 | |||
173 | @@ -128,6 +128,7 @@ | |||
174 | 128 | 'related', | 128 | 'related', |
175 | 129 | 'web', | 129 | 'web', |
176 | 130 | 'ubuntu_website', | 130 | 'ubuntu_website', |
177 | 131 | 'django_openid_auth', | ||
178 | 131 | ) | 132 | ) |
179 | 132 | 133 | ||
180 | 133 | # A sample logging configuration. The only tangible logging | 134 | # A sample logging configuration. The only tangible logging |
181 | @@ -152,3 +153,21 @@ | |||
182 | 152 | }, | 153 | }, |
183 | 153 | } | 154 | } |
184 | 154 | } | 155 | } |
185 | 156 | |||
186 | 157 | AUTHENTICATION_BACKENDS = ( | ||
187 | 158 | 'django_openid_auth.auth.OpenIDBackend', | ||
188 | 159 | 'django.contrib.auth.backends.ModelBackend', | ||
189 | 160 | ) | ||
190 | 161 | # OPENID Related settings | ||
191 | 162 | OPENID_STRICT_USERNAMES = True | ||
192 | 163 | OPENID_FOLLOW_RENAMES = True | ||
193 | 164 | OPENID_SREG_REQUIRED_FIELDS = ['email'] | ||
194 | 165 | OPENID_CREATE_USERS = True | ||
195 | 166 | OPENID_REUSE_USERS = True | ||
196 | 167 | OPENID_UPDATE_DETAILS_FROM_SREG = True | ||
197 | 168 | OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/' | ||
198 | 169 | OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True | ||
199 | 170 | |||
200 | 171 | # Tell django.contrib.auth to use the OpenID signin URLs. | ||
201 | 172 | LOGIN_URL = '/api/login' | ||
202 | 173 | LOGIN_REDIRECT_URL = '/' | ||
203 | 155 | 174 | ||
204 | === modified file 'developer_network/urls.py' | |||
205 | --- developer_network/urls.py 2013-10-04 19:56:27 +0000 | |||
206 | +++ developer_network/urls.py 2013-10-31 19:44:44 +0000 | |||
207 | @@ -8,6 +8,16 @@ | |||
208 | 8 | from django.contrib.staticfiles.urls import staticfiles_urlpatterns | 8 | from django.contrib.staticfiles.urls import staticfiles_urlpatterns |
209 | 9 | urlpatterns = staticfiles_urlpatterns() | 9 | urlpatterns = staticfiles_urlpatterns() |
210 | 10 | 10 | ||
211 | 11 | from common.views import login_failure | ||
212 | 12 | urlpatterns += patterns( | ||
213 | 13 | 'django_openid_auth.views', | ||
214 | 14 | url(r'^api/login/$', 'login_begin', name='openid-login', | ||
215 | 15 | kwargs={'render_failure': login_failure}), | ||
216 | 16 | url(r'^api/openid/complete/$', 'login_complete', name='openid-complete', | ||
217 | 17 | kwargs={'render_failure': login_failure}), | ||
218 | 18 | url(r'^api/openid/logo.gif$', 'logo', name='openid-logo'), | ||
219 | 19 | ) | ||
220 | 20 | |||
221 | 11 | urlpatterns += patterns('', | 21 | urlpatterns += patterns('', |
222 | 12 | # Examples: | 22 | # Examples: |
223 | 13 | # url(r'^developer_network/', include('developer_network.foo.urls')), | 23 | # url(r'^developer_network/', include('developer_network.foo.urls')), |
224 | @@ -17,14 +27,33 @@ | |||
225 | 17 | 27 | ||
226 | 18 | # Uncomment the next line to enable the admin: | 28 | # Uncomment the next line to enable the admin: |
227 | 19 | url(r'^api/admin/', include(admin.site.urls)), | 29 | url(r'^api/admin/', include(admin.site.urls)), |
228 | 30 | url(r'^api/logout/$', 'common.views.logout_view', name='logout'), | ||
229 | 20 | 31 | ||
230 | 21 | url(r'^$', 'web.views.overview', name='overview'), | 32 | url(r'^$', 'web.views.overview', name='overview'), |
231 | 22 | url(r'^api/$', 'web.views.overview', name='overview'), | 33 | url(r'^api/$', 'web.views.overview', name='overview'), |
232 | 34 | |||
233 | 23 | url(r'^api/(?P<topic_name>[\w\.-]+)/$', 'web.views.topic_view', name='topic'), | 35 | url(r'^api/(?P<topic_name>[\w\.-]+)/$', 'web.views.topic_view', name='topic'), |
234 | 36 | url(r'^api/\+topic/$', 'web.views.topic_edit', name='topic_edit'), | ||
235 | 37 | url(r'^api/\+topic/(?P<topic_id>[\d]+)/$', 'web.views.topic_edit', name='topic_edit'), | ||
236 | 38 | |||
237 | 24 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/$', 'web.views.version_view', name='version'), | 39 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/$', 'web.views.version_view', name='version'), |
238 | 40 | url(r'^api/(?P<topic_name>[\w\.-]+)/\+version/$', 'web.views.version_edit', name='version_edit'), | ||
239 | 41 | url(r'^api/(?P<topic_name>[\w\.-]+)/\+version/(?P<version_id>[\d]+)/$', 'web.views.version_edit', name='version_edit'), | ||
240 | 42 | |||
241 | 43 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+section/(?P<section_id>[\d]+)/$', 'web.views.section_edit', name='section_edit'), | ||
242 | 44 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+section/$', 'web.views.section_edit', name='section_edit'), | ||
243 | 45 | |||
244 | 46 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+namespace/(?P<namespace_id>[\d]+)/$', 'web.views.namespace_edit', name='namespace_edit'), | ||
245 | 47 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+namespace/$', 'web.views.namespace_edit', name='namespace_edit'), | ||
246 | 48 | |||
247 | 25 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/search/$', 'web.views.search', name='search'), | 49 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/search/$', 'web.views.search', name='search'), |
248 | 26 | 50 | ||
249 | 27 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/(?P<element_fullname>[\w\.\-\:]+).html$', 'web.views.element_view', name='element'), | ||
250 | 28 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/(?P<element_fullname>[\w\.\-\:]+)/$', 'web.views.element_view', name='element'), | 51 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/(?P<element_fullname>[\w\.\-\:]+)/$', 'web.views.element_view', name='element'), |
251 | 52 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+element/(?P<element_id>[\d]+)/$', 'web.views.element_edit', name='element_edit'), | ||
252 | 53 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+element/$', 'web.views.element_edit', name='element_edit'), | ||
253 | 54 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+page/(?P<page_id>[\d]+)/$', 'web.views.page_edit', name='page_edit'), | ||
254 | 55 | url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+page/$', 'web.views.page_edit', name='page_edit'), | ||
255 | 29 | 56 | ||
256 | 30 | ) | 57 | ) |
257 | 58 | |||
258 | 59 | |||
259 | 31 | 60 | ||
260 | === modified file 'developer_network/web/static/css/site.css' | |||
261 | --- developer_network/web/static/css/site.css 2013-10-22 20:54:40 +0000 | |||
262 | +++ developer_network/web/static/css/site.css 2013-10-31 19:44:44 +0000 | |||
263 | @@ -21,6 +21,25 @@ | |||
264 | 21 | display: inline; | 21 | display: inline; |
265 | 22 | } | 22 | } |
266 | 23 | 23 | ||
267 | 24 | #editor_actions { | ||
268 | 25 | background-color: #F1F1F1; | ||
269 | 26 | padding: 5px; | ||
270 | 27 | margin-bottom: 10px; | ||
271 | 28 | /* border-bottom: 1px dotted; */ | ||
272 | 29 | } | ||
273 | 30 | |||
274 | 31 | #editor_actions ul { | ||
275 | 32 | margin: 0px; | ||
276 | 33 | } | ||
277 | 34 | |||
278 | 35 | #editor_actions li { | ||
279 | 36 | margin-right: 10px; | ||
280 | 37 | margin-bottom: 0; | ||
281 | 38 | line-height: 33px; | ||
282 | 39 | float: left; | ||
283 | 40 | list-style: none; | ||
284 | 41 | list-style-image: none; | ||
285 | 42 | } | ||
286 | 24 | /* | 43 | /* |
287 | 25 | * release.html | 44 | * release.html |
288 | 26 | */ | 45 | */ |
289 | @@ -47,6 +66,16 @@ | |||
290 | 47 | border-top: 1px dotted; | 66 | border-top: 1px dotted; |
291 | 48 | } | 67 | } |
292 | 49 | 68 | ||
293 | 69 | .section_title A.section_editor_action { | ||
294 | 70 | float: right; | ||
295 | 71 | font-size: .7em; | ||
296 | 72 | display: none; | ||
297 | 73 | } | ||
298 | 74 | |||
299 | 75 | .section_title:hover A.section_editor_action { | ||
300 | 76 | display: inherit; | ||
301 | 77 | } | ||
302 | 78 | |||
303 | 50 | /* | 79 | /* |
304 | 51 | * element.html | 80 | * element.html |
305 | 52 | */ | 81 | */ |
306 | @@ -75,54 +104,63 @@ | |||
307 | 75 | padding: 3px; | 104 | padding: 3px; |
308 | 76 | } | 105 | } |
309 | 77 | 106 | ||
310 | 107 | /* | ||
311 | 108 | * element.html | ||
312 | 109 | */ | ||
313 | 110 | #element_content TEXTAREA { | ||
314 | 111 | height: inherit; | ||
315 | 112 | width: inherit; | ||
316 | 113 | max-width: none; | ||
317 | 114 | max-height: none; | ||
318 | 115 | } | ||
319 | 78 | /* | 116 | /* |
320 | 79 | * sidenav.html | 117 | * sidenav.html |
321 | 80 | */ | 118 | */ |
322 | 81 | 119 | ||
323 | 82 | .ui-state-focus { | 120 | .ui-state-focus { |
325 | 83 | outline: none; | 121 | outline: none; |
326 | 84 | } | 122 | } |
327 | 85 | .ui-accordion { | 123 | .ui-accordion { |
329 | 86 | border-bottom: 1px dotted #aea79f; | 124 | border-bottom: 1px dotted #aea79f; |
330 | 87 | } | 125 | } |
331 | 88 | .ui-accordion a { | 126 | .ui-accordion a { |
333 | 89 | display: block; | 127 | display: block; |
334 | 90 | } | 128 | } |
335 | 91 | .ui-accordion h3 { | 129 | .ui-accordion h3 { |
341 | 92 | margin-bottom: 0; | 130 | margin-bottom: 0; |
342 | 93 | border-top: 1px dotted #aea79f; | 131 | border-top: 1px dotted #aea79f; |
343 | 94 | position: relative; | 132 | position: relative; |
344 | 95 | font-size: 13px; | 133 | font-size: 13px; |
345 | 96 | font-weight: bold; | 134 | font-weight: bold; |
346 | 97 | } | 135 | } |
347 | 98 | .ui-accordion h3 a { | 136 | .ui-accordion h3 a { |
350 | 99 | padding: 10px 0; | 137 | padding: 10px 0; |
351 | 100 | color: #333; | 138 | color: #333; |
352 | 101 | } | 139 | } |
353 | 102 | .ui-accordion h4 { | 140 | .ui-accordion h4 { |
355 | 103 | margin-bottom: 5px; | 141 | margin-bottom: 5px; |
356 | 104 | } | 142 | } |
357 | 105 | .ui-accordion div fieldset { | 143 | .ui-accordion div fieldset { |
359 | 106 | padding-bottom: 5px; | 144 | padding-bottom: 5px; |
360 | 107 | } | 145 | } |
361 | 108 | .ui-accordion div li, | 146 | .ui-accordion div li, |
362 | 109 | .ui-accordion div input { | 147 | .ui-accordion div input { |
364 | 110 | margin-bottom: 10px; | 148 | margin-bottom: 10px; |
365 | 111 | } | 149 | } |
366 | 112 | .ui-accordion .ui-icon { | 150 | .ui-accordion .ui-icon { |
374 | 113 | position: absolute; | 151 | position: absolute; |
375 | 114 | top: 15px; | 152 | top: 15px; |
376 | 115 | right: 0; | 153 | right: 0; |
377 | 116 | display: block; | 154 | display: block; |
378 | 117 | width: 8px; | 155 | width: 8px; |
379 | 118 | height: 8px; | 156 | height: 8px; |
380 | 119 | background: url("../img/icon-accordion-inactive.png") 0 0 no-repeat transparent; | 157 | background: url("../img/icon-accordion-inactive.png") 0 0 no-repeat transparent; |
381 | 120 | } | 158 | } |
382 | 121 | .ui-accordion .ui-state-active .ui-icon { | 159 | .ui-accordion .ui-state-active .ui-icon { |
384 | 122 | background-image: url("../img/icon-accordion-active.png"); | 160 | background-image: url("../img/icon-accordion-active.png"); |
385 | 123 | } | 161 | } |
386 | 124 | .ui-accordion .current_page_item a { | 162 | .ui-accordion .current_page_item a { |
388 | 125 | color: #333; | 163 | color: #333; |
389 | 126 | } | 164 | } |
390 | 127 | 165 | ||
391 | 128 | /* | 166 | /* |
392 | 129 | 167 | ||
393 | === modified file 'developer_network/web/templates/web/article.html' | |||
394 | --- developer_network/web/templates/web/article.html 2013-09-23 21:27:54 +0000 | |||
395 | +++ developer_network/web/templates/web/article.html 2013-10-31 19:44:44 +0000 | |||
396 | @@ -26,6 +26,23 @@ | |||
397 | 26 | {% endblock %} | 26 | {% endblock %} |
398 | 27 | </span> | 27 | </span> |
399 | 28 | </section> | 28 | </section> |
400 | 29 | {% block editor_actions %} | ||
401 | 30 | {% if perms.common or perms.apidocs %} | ||
402 | 31 | <section id="editor_actions"> | ||
403 | 32 | <span style="float: right;"> | ||
404 | 33 | <ul class="clearfix"> | ||
405 | 34 | <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li> | ||
406 | 35 | </ul> | ||
407 | 36 | </span> | ||
408 | 37 | <span id="editor_links"> | ||
409 | 38 | <ul class="clearfix"> | ||
410 | 39 | {% block editor_links %} | ||
411 | 40 | {% endblock %} | ||
412 | 41 | </ul> | ||
413 | 42 | </span> | ||
414 | 43 | </section> | ||
415 | 44 | {% endif %} | ||
416 | 45 | {% endblock %} | ||
417 | 29 | <article> | 46 | <article> |
418 | 30 | {% block article_content %} | 47 | {% block article_content %} |
419 | 31 | {% endblock %} | 48 | {% endblock %} |
420 | 32 | 49 | ||
421 | === modified file 'developer_network/web/templates/web/distro.html' | |||
422 | --- developer_network/web/templates/web/distro.html 2013-09-13 14:01:30 +0000 | |||
423 | +++ developer_network/web/templates/web/distro.html 2013-10-31 19:44:44 +0000 | |||
424 | @@ -3,6 +3,26 @@ | |||
425 | 3 | {% block sub_nav %}{% endblock %} | 3 | {% block sub_nav %}{% endblock %} |
426 | 4 | 4 | ||
427 | 5 | {% block content %} | 5 | {% block content %} |
428 | 6 | {% if perms.common %} | ||
429 | 7 | <section id="editor_actions"> | ||
430 | 8 | <span style="float: right;"> | ||
431 | 9 | <ul class="clearfix"> | ||
432 | 10 | <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li> | ||
433 | 11 | </ul> | ||
434 | 12 | </span> | ||
435 | 13 | <span id="editor_links"> | ||
436 | 14 | <ul class="clearfix"> | ||
437 | 15 | {% if perms.common.change_topic %} | ||
438 | 16 | <li><a href="{% url topic_edit topic.id %}">Edit</a></li> | ||
439 | 17 | {% endif %} | ||
440 | 18 | {% if perms.common.add_version %} | ||
441 | 19 | <li><a href="{% url version_edit topic.slug %}">+ Version</a></li> | ||
442 | 20 | {% endif %} | ||
443 | 21 | </ul> | ||
444 | 22 | </span> | ||
445 | 23 | </section> | ||
446 | 24 | {% endif %} | ||
447 | 25 | |||
448 | 6 | <h2>{{topic.name}} Versions</h2> | 26 | <h2>{{topic.name}} Versions</h2> |
449 | 7 | <ul> | 27 | <ul> |
450 | 8 | {% for version in topic.version_set.all %} | 28 | {% for version in topic.version_set.all %} |
451 | 9 | 29 | ||
452 | === modified file 'developer_network/web/templates/web/element.html' | |||
453 | --- developer_network/web/templates/web/element.html 2013-09-19 17:48:26 +0000 | |||
454 | +++ developer_network/web/templates/web/element.html 2013-10-31 19:44:44 +0000 | |||
455 | @@ -1,5 +1,14 @@ | |||
456 | 1 | {% extends "web/article.html" %} | 1 | {% extends "web/article.html" %} |
457 | 2 | 2 | ||
458 | 3 | {% block editor_links %} | ||
459 | 4 | {% if perms.apidocs.change_element %} | ||
460 | 5 | <li><a href="{% url element_edit topic.slug, version.slug, element.id %}">Edit</a></li> | ||
461 | 6 | {% endif %} | ||
462 | 7 | {% if perms.apidocs.delete_element %} | ||
463 | 8 | <li><a href="{% url element_edit topic.slug, version.slug, element.id %}?action=delete">Delete</a></li> | ||
464 | 9 | {% endif %} | ||
465 | 10 | {% endblock %} | ||
466 | 11 | |||
467 | 3 | {% block breadcrumbs %} | 12 | {% block breadcrumbs %} |
468 | 4 | <li><a class="sub-nav-item" href="{% url topic element.platform_section.topic_version.topic.slug %}">{{element.platform_section.topic_version.topic.name}}</a></li> | 13 | <li><a class="sub-nav-item" href="{% url topic element.platform_section.topic_version.topic.slug %}">{{element.platform_section.topic_version.topic.name}}</a></li> |
469 | 5 | <li> › <a class="sub-nav-item" href="{% url version element.platform_section.topic_version.topic.slug element.platform_section.topic_version.slug %}">{{element.platform_section.topic_version.name}}</a></li> | 14 | <li> › <a class="sub-nav-item" href="{% url version element.platform_section.topic_version.topic.slug element.platform_section.topic_version.slug %}">{{element.platform_section.topic_version.name}}</a></li> |
470 | 6 | 15 | ||
471 | === added file 'developer_network/web/templates/web/element_edit.html' | |||
472 | --- developer_network/web/templates/web/element_edit.html 1970-01-01 00:00:00 +0000 | |||
473 | +++ developer_network/web/templates/web/element_edit.html 2013-10-31 19:44:44 +0000 | |||
474 | @@ -0,0 +1,48 @@ | |||
475 | 1 | {% extends "web/article.html" %} | ||
476 | 2 | |||
477 | 3 | {% block editor_links %} | ||
478 | 4 | {% if element.id and perms.apidocs.delete_element %} | ||
479 | 5 | <li><a href="{% url element_edit topic.slug version.slug element.id %}?action=delete">Delete</a></li> | ||
480 | 6 | {% endif %} | ||
481 | 7 | {% endblock %} | ||
482 | 8 | |||
483 | 9 | {% block breadcrumbs %} | ||
484 | 10 | {% endblock %} | ||
485 | 11 | |||
486 | 12 | {% block article_content %} | ||
487 | 13 | {% if element.id %} | ||
488 | 14 | <h1>Edit: {{element.name}}</h1> | ||
489 | 15 | {% else %} | ||
490 | 16 | <h1>New Element</h1> | ||
491 | 17 | {% endif %} | ||
492 | 18 | |||
493 | 19 | <form action="" method="POST" id="element_form"> | ||
494 | 20 | {% csrf_token %} | ||
495 | 21 | <div id="element_content"> | ||
496 | 22 | {{ form.as_p }} | ||
497 | 23 | </div> | ||
498 | 24 | <input type="submit" value="Save"> | ||
499 | 25 | </form> | ||
500 | 26 | |||
501 | 27 | {% comment %} | ||
502 | 28 | <h3>Snippets</h3> | ||
503 | 29 | {% for snippet in snippets %} | ||
504 | 30 | <div> | ||
505 | 31 | <li>{{ snippet.name }}</li> | ||
506 | 32 | </div> | ||
507 | 33 | {% endfor %} | ||
508 | 34 | |||
509 | 35 | <h3>Questions & Answers</h3> | ||
510 | 36 | {% for question in questions %} | ||
511 | 37 | <div> | ||
512 | 38 | <li><a href="{{ question.url }}">{{ question.name }}</a></li> | ||
513 | 39 | </div> | ||
514 | 40 | {% endfor %} | ||
515 | 41 | <h3>Tutorials</h3> | ||
516 | 42 | {% for tutorial in tutorials %} | ||
517 | 43 | <div> | ||
518 | 44 | <li><a href="{{ tutorial.url }}">{{ tutorial.name }}</a></li> | ||
519 | 45 | </div> | ||
520 | 46 | {% endfor %} | ||
521 | 47 | {% endcomment %} | ||
522 | 48 | {% endblock %} | ||
523 | 0 | 49 | ||
524 | === modified file 'developer_network/web/templates/web/namespace.html' | |||
525 | --- developer_network/web/templates/web/namespace.html 2013-10-04 19:56:27 +0000 | |||
526 | +++ developer_network/web/templates/web/namespace.html 2013-10-31 19:44:44 +0000 | |||
527 | @@ -1,5 +1,17 @@ | |||
528 | 1 | {% extends "web/article.html" %} | 1 | {% extends "web/article.html" %} |
529 | 2 | 2 | ||
530 | 3 | {% block editor_links %} | ||
531 | 4 | {% if perms.apidocs.change_namespace %} | ||
532 | 5 | <li><a href="{% url namespace_edit version.topic.slug version.slug namespace.id%}">Edit</a></li> | ||
533 | 6 | {% endif %} | ||
534 | 7 | {% if perms.apidocs.add_element %} | ||
535 | 8 | <li><a href="{% url element_edit version.topic.slug version.slug %}">+ Element</a></li> | ||
536 | 9 | {% endif %} | ||
537 | 10 | {% if perms.apidocs.add_page %} | ||
538 | 11 | <li><a href="{% url page_edit version.topic.slug version.slug %}">+ Page</a></li> | ||
539 | 12 | {% endif %} | ||
540 | 13 | {% endblock %} | ||
541 | 14 | |||
542 | 3 | {% block breadcrumbs %} | 15 | {% block breadcrumbs %} |
543 | 4 | <li><a class="sub-nav-item" href="{% url topic namespace.platform_section.topic_version.topic.slug %}">{{namespace.platform_section.topic_version.topic.name}}</a></li> | 16 | <li><a class="sub-nav-item" href="{% url topic namespace.platform_section.topic_version.topic.slug %}">{{namespace.platform_section.topic_version.topic.name}}</a></li> |
544 | 5 | <li> › <a class="sub-nav-item" href="{% url version namespace.platform_section.topic_version.topic.slug namespace.platform_section.topic_version.slug %}">{{namespace.platform_section.topic_version.name}}</a></li> | 17 | <li> › <a class="sub-nav-item" href="{% url version namespace.platform_section.topic_version.topic.slug namespace.platform_section.topic_version.slug %}">{{namespace.platform_section.topic_version.name}}</a></li> |
545 | 6 | 18 | ||
546 | === added file 'developer_network/web/templates/web/namespace_edit.html' | |||
547 | --- developer_network/web/templates/web/namespace_edit.html 1970-01-01 00:00:00 +0000 | |||
548 | +++ developer_network/web/templates/web/namespace_edit.html 2013-10-31 19:44:44 +0000 | |||
549 | @@ -0,0 +1,48 @@ | |||
550 | 1 | {% extends "web/article.html" %} | ||
551 | 2 | |||
552 | 3 | {% block editor_links %} | ||
553 | 4 | {% if namespace.id and perms.apidocs.delete_namespace %} | ||
554 | 5 | <li><a href="{% url namespace_edit topic.slug version.slug namespace.id %}?action=delete">Delete</a></li> | ||
555 | 6 | {% endif %} | ||
556 | 7 | {% endblock %} | ||
557 | 8 | |||
558 | 9 | {% block breadcrumbs %} | ||
559 | 10 | {% endblock %} | ||
560 | 11 | |||
561 | 12 | {% block article_content %} | ||
562 | 13 | {% if namespace.id %} | ||
563 | 14 | <h1>Edit: {{namespace.name}}</h1> | ||
564 | 15 | {% else %} | ||
565 | 16 | <h1>New Namespace</h1> | ||
566 | 17 | {% endif %} | ||
567 | 18 | |||
568 | 19 | <form action="" method="POST" id="namespace_form"> | ||
569 | 20 | {% csrf_token %} | ||
570 | 21 | <div id="namespace_content"> | ||
571 | 22 | {{ form.as_p }} | ||
572 | 23 | </div> | ||
573 | 24 | <input type="submit" value="Save"> | ||
574 | 25 | </form> | ||
575 | 26 | |||
576 | 27 | {% comment %} | ||
577 | 28 | <h3>Snippets</h3> | ||
578 | 29 | {% for snippet in snippets %} | ||
579 | 30 | <div> | ||
580 | 31 | <li>{{ snippet.name }}</li> | ||
581 | 32 | </div> | ||
582 | 33 | {% endfor %} | ||
583 | 34 | |||
584 | 35 | <h3>Questions & Answers</h3> | ||
585 | 36 | {% for question in questions %} | ||
586 | 37 | <div> | ||
587 | 38 | <li><a href="{{ question.url }}">{{ question.name }}</a></li> | ||
588 | 39 | </div> | ||
589 | 40 | {% endfor %} | ||
590 | 41 | <h3>Tutorials</h3> | ||
591 | 42 | {% for tutorial in tutorials %} | ||
592 | 43 | <div> | ||
593 | 44 | <li><a href="{{ tutorial.url }}">{{ tutorial.name }}</a></li> | ||
594 | 45 | </div> | ||
595 | 46 | {% endfor %} | ||
596 | 47 | {% endcomment %} | ||
597 | 48 | {% endblock %} | ||
598 | 0 | 49 | ||
599 | === modified file 'developer_network/web/templates/web/overview.html' | |||
600 | --- developer_network/web/templates/web/overview.html 2013-09-13 14:01:30 +0000 | |||
601 | +++ developer_network/web/templates/web/overview.html 2013-10-31 19:44:44 +0000 | |||
602 | @@ -3,6 +3,23 @@ | |||
603 | 3 | {% block sub_nav %}{% endblock %} | 3 | {% block sub_nav %}{% endblock %} |
604 | 4 | 4 | ||
605 | 5 | {% block content %} | 5 | {% block content %} |
606 | 6 | {% if perms.common %} | ||
607 | 7 | <section id="editor_actions"> | ||
608 | 8 | <span style="float: right;"> | ||
609 | 9 | <ul class="clearfix"> | ||
610 | 10 | <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li> | ||
611 | 11 | </ul> | ||
612 | 12 | </span> | ||
613 | 13 | <span id="editor_links"> | ||
614 | 14 | <ul class="clearfix"> | ||
615 | 15 | {% if perms.common.add_topic %} | ||
616 | 16 | <li><a href="{% url topic_edit %}">+ Topic</a></li> | ||
617 | 17 | {% endif %} | ||
618 | 18 | </ul> | ||
619 | 19 | </span> | ||
620 | 20 | </section> | ||
621 | 21 | {% endif %} | ||
622 | 22 | |||
623 | 6 | <h2>Topics</h2> | 23 | <h2>Topics</h2> |
624 | 7 | <ul> | 24 | <ul> |
625 | 8 | {% for topic in topics %} | 25 | {% for topic in topics %} |
626 | 9 | 26 | ||
627 | === modified file 'developer_network/web/templates/web/page.html' | |||
628 | --- developer_network/web/templates/web/page.html 2013-10-04 19:56:27 +0000 | |||
629 | +++ developer_network/web/templates/web/page.html 2013-10-31 19:44:44 +0000 | |||
630 | @@ -1,5 +1,14 @@ | |||
631 | 1 | {% extends "web/article.html" %} | 1 | {% extends "web/article.html" %} |
632 | 2 | 2 | ||
633 | 3 | {% block editor_links %} | ||
634 | 4 | {% if perms.apidocs.change_page %} | ||
635 | 5 | <li><a href="{% url page_edit topic.slug version.slug page.id %}">Edit</a></li> | ||
636 | 6 | {% endif %} | ||
637 | 7 | {% if perms.apidocs.delete_page %} | ||
638 | 8 | <li><a href="{% url page_edit topic.slug version.slug page.id %}?action=delete">Delete</a></li> | ||
639 | 9 | {% endif %} | ||
640 | 10 | {% endblock %} | ||
641 | 11 | |||
642 | 3 | {% block breadcrumbs %} | 12 | {% block breadcrumbs %} |
643 | 4 | <li><a class="sub-nav-item" href="{% url topic page.section.topic_version.topic.slug %}">{{page.section.topic_version.topic.name}}</a></li> | 13 | <li><a class="sub-nav-item" href="{% url topic page.section.topic_version.topic.slug %}">{{page.section.topic_version.topic.name}}</a></li> |
644 | 5 | <li> › <a class="sub-nav-item" href="{% url version page.section.topic_version.topic.slug page.section.topic_version.slug %}">{{page.section.topic_version.name}}</a></li> | 14 | <li> › <a class="sub-nav-item" href="{% url version page.section.topic_version.topic.slug page.section.topic_version.slug %}">{{page.section.topic_version.name}}</a></li> |
645 | 6 | 15 | ||
646 | === added file 'developer_network/web/templates/web/page_edit.html' | |||
647 | --- developer_network/web/templates/web/page_edit.html 1970-01-01 00:00:00 +0000 | |||
648 | +++ developer_network/web/templates/web/page_edit.html 2013-10-31 19:44:44 +0000 | |||
649 | @@ -0,0 +1,25 @@ | |||
650 | 1 | {% extends "web/article.html" %} | ||
651 | 2 | |||
652 | 3 | {% block editor_links %} | ||
653 | 4 | {% if page.id and perms.apidocs.delete_page %} | ||
654 | 5 | <li><a href="{% url page_edit topic.slug version.slug page.id %}?action=delete">Delete</a></li> | ||
655 | 6 | {% endif %} | ||
656 | 7 | {% endblock %} | ||
657 | 8 | |||
658 | 9 | {% block breadcrumbs %} | ||
659 | 10 | {% endblock %} | ||
660 | 11 | |||
661 | 12 | {% block article_content %} | ||
662 | 13 | {% if page.id %} | ||
663 | 14 | <h2>Edit {{page.name}}</h2> | ||
664 | 15 | {% else %} | ||
665 | 16 | <h2>New Page</h2> | ||
666 | 17 | {% endif %} | ||
667 | 18 | |||
668 | 19 | <form action="" method="POST" id="page_form"> | ||
669 | 20 | {% csrf_token %} | ||
670 | 21 | {{ form.as_p }} | ||
671 | 22 | <input type="submit" value="Save"> | ||
672 | 23 | </form> | ||
673 | 24 | |||
674 | 25 | {% endblock %} | ||
675 | 0 | 26 | ||
676 | === modified file 'developer_network/web/templates/web/release.html' | |||
677 | --- developer_network/web/templates/web/release.html 2013-09-19 17:48:26 +0000 | |||
678 | +++ developer_network/web/templates/web/release.html 2013-10-31 19:44:44 +0000 | |||
679 | @@ -1,5 +1,20 @@ | |||
680 | 1 | {% extends "web/article.html" %} | 1 | {% extends "web/article.html" %} |
681 | 2 | 2 | ||
682 | 3 | {% block editor_links %} | ||
683 | 4 | {% if perms.common.change_version %} | ||
684 | 5 | <li><a href="{% url version_edit version.topic.slug version.id %}">Edit</a></li> | ||
685 | 6 | {% endif %} | ||
686 | 7 | {% if perms.common.add_section %} | ||
687 | 8 | <li><a href="{% url section_edit version.topic.slug version.slug %}">+ Section</a></li> | ||
688 | 9 | {% endif %} | ||
689 | 10 | {% if perms.apidocs.add_namespace %} | ||
690 | 11 | <li><a href="{% url namespace_edit version.topic.slug version.slug %}">+ Namespace</a></li> | ||
691 | 12 | {% endif %} | ||
692 | 13 | {% if perms.apidocs.add_element %} | ||
693 | 14 | <li><a href="{% url element_edit version.topic.slug version.slug %}">+ Element</a></li> | ||
694 | 15 | {% endif %} | ||
695 | 16 | {% endblock %} | ||
696 | 17 | |||
697 | 3 | {% block breadcrumbs %} | 18 | {% block breadcrumbs %} |
698 | 4 | <li><a class="sub-nav-item" href="{% url topic version.topic.slug %}">{{version.topic.name}}</a></li> | 19 | <li><a class="sub-nav-item" href="{% url topic version.topic.slug %}">{{version.topic.name}}</a></li> |
699 | 5 | <li> › {{version.name}}</li> | 20 | <li> › {{version.name}}</li> |
700 | @@ -10,7 +25,7 @@ | |||
701 | 10 | <table class="section_list"><tr> | 25 | <table class="section_list"><tr> |
702 | 11 | <td id="first_column"> | 26 | <td id="first_column"> |
703 | 12 | {% for section in first_column %} | 27 | {% for section in first_column %} |
705 | 13 | <h3>{{section.name}}</h3> | 28 | <h3 class="section_title">{{section.name}}{% if perms.common.change_section %}<a class="section_editor_action" href="{% url section_edit version.topic.slug version.slug section.id %}">Edit</a>{% endif %}</h3> |
706 | 14 | <ul> | 29 | <ul> |
707 | 15 | {% for namespace in section.namespace_set.all %} | 30 | {% for namespace in section.namespace_set.all %} |
708 | 16 | <li><a href="{% url element version.topic.slug version.slug namespace.name %}">{{namespace.name}}</a></li> | 31 | <li><a href="{% url element version.topic.slug version.slug namespace.name %}">{{namespace.name}}</a></li> |
709 | @@ -33,7 +48,7 @@ | |||
710 | 33 | {% if second_column %} | 48 | {% if second_column %} |
711 | 34 | <td id="second_column"> | 49 | <td id="second_column"> |
712 | 35 | {% for section in second_column %} | 50 | {% for section in second_column %} |
714 | 36 | <h3>{{section.name}}</h3> | 51 | <h3 class="section_title">{{section.name}}{% if perms.common.change_section %}<a class="section_editor_action" href="{% url section_edit version.topic.slug version.slug section.id %}">Edit</a>{% endif %}</h3> |
715 | 37 | <ul> | 52 | <ul> |
716 | 38 | {% for namespace in section.namespace_set.all %} | 53 | {% for namespace in section.namespace_set.all %} |
717 | 39 | <li><a href="{% url element version.topic.slug version.slug namespace.name %}">{{namespace.name}}</a></li> | 54 | <li><a href="{% url element version.topic.slug version.slug namespace.name %}">{{namespace.name}}</a></li> |
718 | 40 | 55 | ||
719 | === modified file 'developer_network/web/templates/web/search.html' | |||
720 | --- developer_network/web/templates/web/search.html 2013-09-23 21:27:54 +0000 | |||
721 | +++ developer_network/web/templates/web/search.html 2013-10-31 19:44:44 +0000 | |||
722 | @@ -1,5 +1,7 @@ | |||
723 | 1 | {% extends "web/article.html" %} | 1 | {% extends "web/article.html" %} |
724 | 2 | 2 | ||
725 | 3 | {% block editor_actions %}{% endblock %} | ||
726 | 4 | |||
727 | 3 | {% block breadcrumbs %} | 5 | {% block breadcrumbs %} |
728 | 4 | <li><a class="sub-nav-item" href="{% url topic version.topic.slug %}">{{version.topic.name}}</a></li> | 6 | <li><a class="sub-nav-item" href="{% url topic version.topic.slug %}">{{version.topic.name}}</a></li> |
729 | 5 | <li> › <a class="sub-nav-item" href="{% url version version.topic.slug version.slug %}">{{version.name}}</a></li> | 7 | <li> › <a class="sub-nav-item" href="{% url version version.topic.slug version.slug %}">{{version.name}}</a></li> |
730 | 6 | 8 | ||
731 | === added file 'developer_network/web/templates/web/section_edit.html' | |||
732 | --- developer_network/web/templates/web/section_edit.html 1970-01-01 00:00:00 +0000 | |||
733 | +++ developer_network/web/templates/web/section_edit.html 2013-10-31 19:44:44 +0000 | |||
734 | @@ -0,0 +1,25 @@ | |||
735 | 1 | {% extends "web/article.html" %} | ||
736 | 2 | |||
737 | 3 | {% block editor_links %} | ||
738 | 4 | {% if section.id and perms.common.delete_section %} | ||
739 | 5 | <li><a href="{% url section_edit topic.slug version.slug section.id %}?action=delete">Delete</a></li> | ||
740 | 6 | {% endif %} | ||
741 | 7 | {% endblock %} | ||
742 | 8 | |||
743 | 9 | {% block breadcrumbs %} | ||
744 | 10 | {% endblock %} | ||
745 | 11 | |||
746 | 12 | {% block article_content %} | ||
747 | 13 | {% if section.id %} | ||
748 | 14 | <h2>Edit {{section.name}}</h2> | ||
749 | 15 | {% else %} | ||
750 | 16 | <h2>New Section</h2> | ||
751 | 17 | {% endif %} | ||
752 | 18 | |||
753 | 19 | <form action="" method="POST" id="section_form"> | ||
754 | 20 | {% csrf_token %} | ||
755 | 21 | {{ form.as_p }} | ||
756 | 22 | <input type="submit" value="Save"> | ||
757 | 23 | </form> | ||
758 | 24 | |||
759 | 25 | {% endblock %} | ||
760 | 0 | 26 | ||
761 | === added file 'developer_network/web/templates/web/topic_edit.html' | |||
762 | --- developer_network/web/templates/web/topic_edit.html 1970-01-01 00:00:00 +0000 | |||
763 | +++ developer_network/web/templates/web/topic_edit.html 2013-10-31 19:44:44 +0000 | |||
764 | @@ -0,0 +1,18 @@ | |||
765 | 1 | {% extends "web/base.html" %} | ||
766 | 2 | |||
767 | 3 | {% block sub_nav %}{% endblock %} | ||
768 | 4 | |||
769 | 5 | {% block content %} | ||
770 | 6 | |||
771 | 7 | {% if topic.id %} | ||
772 | 8 | <h2>Edit: {{topic.name}}</h2> | ||
773 | 9 | {% else %} | ||
774 | 10 | <h2>New Topic</h2> | ||
775 | 11 | {% endif %} | ||
776 | 12 | |||
777 | 13 | <form action="" method="POST" id="topic_form"> | ||
778 | 14 | {% csrf_token %} | ||
779 | 15 | {{ form.as_p }} | ||
780 | 16 | <input type="submit" value="Save"> | ||
781 | 17 | </form> | ||
782 | 18 | {% endblock %} | ||
783 | 0 | 19 | ||
784 | === added file 'developer_network/web/templates/web/version_edit.html' | |||
785 | --- developer_network/web/templates/web/version_edit.html 1970-01-01 00:00:00 +0000 | |||
786 | +++ developer_network/web/templates/web/version_edit.html 2013-10-31 19:44:44 +0000 | |||
787 | @@ -0,0 +1,23 @@ | |||
788 | 1 | {% extends "web/base.html" %} | ||
789 | 2 | |||
790 | 3 | {% block editor_links %} | ||
791 | 4 | <li><a href="{% url version_edit version.id %}?action=delete">Delete</a></li> | ||
792 | 5 | {% endblock %} | ||
793 | 6 | |||
794 | 7 | {% block breadcrumbs %} | ||
795 | 8 | {% endblock %} | ||
796 | 9 | |||
797 | 10 | {% block content %} | ||
798 | 11 | {% if version.id %} | ||
799 | 12 | <h2>Edit {{version.name}}</h2> | ||
800 | 13 | {% else %} | ||
801 | 14 | <h2>New Version</h2> | ||
802 | 15 | {% endif %} | ||
803 | 16 | |||
804 | 17 | <form action="" method="POST" id="element_form"> | ||
805 | 18 | {% csrf_token %} | ||
806 | 19 | {{ form.as_p }} | ||
807 | 20 | <input type="submit" value="Save"> | ||
808 | 21 | </form> | ||
809 | 22 | |||
810 | 23 | {% endblock %} | ||
811 | 0 | 24 | ||
812 | === modified file 'developer_network/web/views.py' | |||
813 | --- developer_network/web/views.py 2013-10-04 19:56:27 +0000 | |||
814 | +++ developer_network/web/views.py 2013-10-31 19:44:44 +0000 | |||
815 | @@ -2,6 +2,7 @@ | |||
816 | 2 | from django.http import HttpResponse, HttpResponseRedirect | 2 | from django.http import HttpResponse, HttpResponseRedirect |
817 | 3 | from django.core.urlresolvers import reverse | 3 | from django.core.urlresolvers import reverse |
818 | 4 | from django.template import loader, RequestContext | 4 | from django.template import loader, RequestContext |
819 | 5 | from django.forms import ModelForm | ||
820 | 5 | 6 | ||
821 | 6 | from common.models import Topic, Version, Section | 7 | from common.models import Topic, Version, Section |
822 | 7 | from apidocs.models import Namespace, Element, Page | 8 | from apidocs.models import Namespace, Element, Page |
823 | @@ -24,6 +25,32 @@ | |||
824 | 24 | } | 25 | } |
825 | 25 | return render_to_response('web/distro.html', context, RequestContext(request)) | 26 | return render_to_response('web/distro.html', context, RequestContext(request)) |
826 | 26 | 27 | ||
827 | 28 | class TopicForm(ModelForm): | ||
828 | 29 | class Meta: | ||
829 | 30 | model = Topic | ||
830 | 31 | |||
831 | 32 | def topic_edit(request, topic_id=0): | ||
832 | 33 | if topic_id: | ||
833 | 34 | topic = get_object_or_404(Topic, id=topic_id) | ||
834 | 35 | else: | ||
835 | 36 | topic = Topic() | ||
836 | 37 | |||
837 | 38 | if not request.user.has_perm('common.change_topic'): | ||
838 | 39 | return HttpResponseRedirect(reverse(topic_view, args=[topic.slug])) | ||
839 | 40 | |||
840 | 41 | if request.method == 'POST': | ||
841 | 42 | form = TopicForm(request.POST, instance=topic) | ||
842 | 43 | if form.is_valid(): | ||
843 | 44 | form.save() | ||
844 | 45 | return HttpResponseRedirect(reverse(topic_view, args=[topic.slug])) | ||
845 | 46 | else: | ||
846 | 47 | form = TopicForm(instance=topic) | ||
847 | 48 | context = { | ||
848 | 49 | 'form': form, | ||
849 | 50 | 'topic': topic, | ||
850 | 51 | } | ||
851 | 52 | return render_to_response('web/topic_edit.html', context, RequestContext(request)) | ||
852 | 53 | |||
853 | 27 | def version_view(request, topic_name, release_version): | 54 | def version_view(request, topic_name, release_version): |
854 | 28 | version = get_object_or_404(Version, topic__slug=topic_name, slug=release_version) | 55 | version = get_object_or_404(Version, topic__slug=topic_name, slug=release_version) |
855 | 29 | 56 | ||
856 | @@ -63,6 +90,68 @@ | |||
857 | 63 | } | 90 | } |
858 | 64 | return render_to_response('web/release.html', context, RequestContext(request)) | 91 | return render_to_response('web/release.html', context, RequestContext(request)) |
859 | 65 | 92 | ||
860 | 93 | class VersionForm(ModelForm): | ||
861 | 94 | class Meta: | ||
862 | 95 | model = Version | ||
863 | 96 | |||
864 | 97 | def version_edit(request, topic_name, version_id=0): | ||
865 | 98 | if version_id: | ||
866 | 99 | version = get_object_or_404(Version, topic__slug=topic_name, id=version_id) | ||
867 | 100 | topic = version.topic | ||
868 | 101 | else: | ||
869 | 102 | topic = get_object_or_404(Topic, slug=topic_name) | ||
870 | 103 | version = Version(topic=topic) | ||
871 | 104 | |||
872 | 105 | if not request.user.has_perm('common.change_version'): | ||
873 | 106 | return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug])) | ||
874 | 107 | |||
875 | 108 | if request.method == 'POST': | ||
876 | 109 | form = VersionForm(request.POST, instance=version) | ||
877 | 110 | if form.is_valid(): | ||
878 | 111 | form.save() | ||
879 | 112 | return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug])) | ||
880 | 113 | else: | ||
881 | 114 | form = VersionForm(instance=version) | ||
882 | 115 | context = { | ||
883 | 116 | 'form': form, | ||
884 | 117 | 'topic': topic, | ||
885 | 118 | 'version': version, | ||
886 | 119 | } | ||
887 | 120 | return render_to_response('web/version_edit.html', context, RequestContext(request)) | ||
888 | 121 | |||
889 | 122 | class SectionForm(ModelForm): | ||
890 | 123 | class Meta: | ||
891 | 124 | model = Section | ||
892 | 125 | |||
893 | 126 | def section_edit(request, topic_name, version_name, section_id=0): | ||
894 | 127 | if section_id: | ||
895 | 128 | section = get_object_or_404(Section, topic_version__topic__slug=topic_name, topic_version__slug=version_name, id=section_id) | ||
896 | 129 | version = section.topic_version | ||
897 | 130 | topic = version.topic | ||
898 | 131 | else: | ||
899 | 132 | topic = get_object_or_404(Topic, slug=topic_name) | ||
900 | 133 | version = get_object_or_404(Version, topic=topic, slug=version_name) | ||
901 | 134 | section = Section(topic_version=version) | ||
902 | 135 | |||
903 | 136 | if not request.user.has_perm('common.change_section'): | ||
904 | 137 | return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug])) | ||
905 | 138 | |||
906 | 139 | if request.method == 'POST': | ||
907 | 140 | form = SectionForm(request.POST, instance=section) | ||
908 | 141 | if form.is_valid(): | ||
909 | 142 | form.save() | ||
910 | 143 | return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug])) | ||
911 | 144 | else: | ||
912 | 145 | form = SectionForm(instance=section) | ||
913 | 146 | context = { | ||
914 | 147 | 'sidenav': topic_name, | ||
915 | 148 | 'form': form, | ||
916 | 149 | 'topic': topic, | ||
917 | 150 | 'version': version, | ||
918 | 151 | 'section': section, | ||
919 | 152 | } | ||
920 | 153 | return render_to_response('web/section_edit.html', context, RequestContext(request)) | ||
921 | 154 | |||
922 | 66 | def namespace_view(request, topic_name, release_version, namespace_name): | 155 | def namespace_view(request, topic_name, release_version, namespace_name): |
923 | 67 | try: | 156 | try: |
924 | 68 | namespace = Namespace.objects.get(platform_section__topic_version__slug=release_version, platform_section__topic_version__topic__slug=topic_name, name=namespace_name) | 157 | namespace = Namespace.objects.get(platform_section__topic_version__slug=release_version, platform_section__topic_version__topic__slug=topic_name, name=namespace_name) |
925 | @@ -82,6 +171,50 @@ | |||
926 | 82 | } | 171 | } |
927 | 83 | return render_to_response('web/namespace.html', context, RequestContext(request)) | 172 | return render_to_response('web/namespace.html', context, RequestContext(request)) |
928 | 84 | 173 | ||
929 | 174 | class NamespaceForm(ModelForm): | ||
930 | 175 | class Meta: | ||
931 | 176 | model = Namespace | ||
932 | 177 | |||
933 | 178 | def __init__(self, *args, **kargs): | ||
934 | 179 | if 'version' in kargs: | ||
935 | 180 | version = kargs['version'] | ||
936 | 181 | del kargs['version'] | ||
937 | 182 | elif hasattr(self, 'instance') and self.instance.section: | ||
938 | 183 | version = self.instance.section.topic_version | ||
939 | 184 | else: | ||
940 | 185 | version=None | ||
941 | 186 | super(NamespaceForm, self).__init__(*args, **kargs) | ||
942 | 187 | self.fields['platform_section'].queryset = Section.objects.filter(topic_version=version) | ||
943 | 188 | |||
944 | 189 | def namespace_edit(request, topic_name, version_name, namespace_id=0): | ||
945 | 190 | if namespace_id: | ||
946 | 191 | namespace = get_object_or_404(Namespace, platform_section__topic_version__slug=version_name, platform_section__topic_version__topic__slug=topic_name, id=namespace_id) | ||
947 | 192 | version = namespace.platform_section.topic_version | ||
948 | 193 | topic = version.topic | ||
949 | 194 | else: | ||
950 | 195 | topic = get_object_or_404(Topic, slug=topic_name) | ||
951 | 196 | version = get_object_or_404(Version, slug=version_name, topic=topic) | ||
952 | 197 | namespace = Namespace() | ||
953 | 198 | |||
954 | 199 | if not request.user.has_perm('apidocs.change_namespace'): | ||
955 | 200 | return HttpResponseRedirect(reverse(element_view, args=[topic_name, version_name, namespace.name])) | ||
956 | 201 | |||
957 | 202 | if request.method == 'POST': | ||
958 | 203 | form = NamespaceForm(request.POST, instance=namespace, version=version) | ||
959 | 204 | if form.is_valid(): | ||
960 | 205 | form.save() | ||
961 | 206 | return HttpResponseRedirect(reverse(element_view, args=[topic_name, version_name, namespace.name])) | ||
962 | 207 | else: | ||
963 | 208 | form = NamespaceForm(instance=namespace, version=version) | ||
964 | 209 | context = { | ||
965 | 210 | 'form': form, | ||
966 | 211 | 'sidenav': topic_name, | ||
967 | 212 | 'topic': topic, | ||
968 | 213 | 'version': version, | ||
969 | 214 | 'namespace': namespace, | ||
970 | 215 | } | ||
971 | 216 | return render_to_response('web/namespace_edit.html', context, RequestContext(request)) | ||
972 | 217 | |||
973 | 85 | def page_view(request, topic_name, release_version, page_fullname): | 218 | def page_view(request, topic_name, release_version, page_fullname): |
974 | 86 | page = get_object_or_404(Page, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, fullname=page_fullname) | 219 | page = get_object_or_404(Page, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, fullname=page_fullname) |
975 | 87 | 220 | ||
976 | @@ -99,6 +232,51 @@ | |||
977 | 99 | } | 232 | } |
978 | 100 | return render_to_response('web/page.html', context, RequestContext(request)) | 233 | return render_to_response('web/page.html', context, RequestContext(request)) |
979 | 101 | 234 | ||
980 | 235 | class PageForm(ModelForm): | ||
981 | 236 | class Meta: | ||
982 | 237 | model = Page | ||
983 | 238 | |||
984 | 239 | def __init__(self, *args, **kargs): | ||
985 | 240 | if 'version' in kargs: | ||
986 | 241 | version = kargs['version'] | ||
987 | 242 | del kargs['version'] | ||
988 | 243 | elif hasattr(self, 'instance') and self.instance.section: | ||
989 | 244 | version = self.instance.section.topic_version | ||
990 | 245 | else: | ||
991 | 246 | version=None | ||
992 | 247 | super(PageForm, self).__init__(*args, **kargs) | ||
993 | 248 | self.fields['section'].queryset = Section.objects.filter(topic_version=version) | ||
994 | 249 | self.fields['namespace'].queryset = Namespace.objects.filter(platform_section__topic_version=version) | ||
995 | 250 | |||
996 | 251 | def page_edit(request, topic_name, release_version, page_id=0): | ||
997 | 252 | if page_id: | ||
998 | 253 | page = get_object_or_404(Page, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, id=page_id) | ||
999 | 254 | version = page.section.topic_version | ||
1000 | 255 | topic = version.topic | ||
1001 | 256 | else: | ||
1002 | 257 | topic = get_object_or_404(Topic, slug=topic_name) | ||
1003 | 258 | version = get_object_or_404(Version, slug=release_version, topic=topic) | ||
1004 | 259 | page = Page() | ||
1005 | 260 | |||
1006 | 261 | if not request.user.has_perm('apidocs.change_page'): | ||
1007 | 262 | return HttpResponseRedirect(reverse(version_view, args=[topic_name, release_version])) | ||
1008 | 263 | |||
1009 | 264 | if request.method == 'POST': | ||
1010 | 265 | form = PageForm(request.POST, instance=page, version=version) | ||
1011 | 266 | if form.is_valid(): | ||
1012 | 267 | form.save() | ||
1013 | 268 | return HttpResponseRedirect(reverse(version_view, args=[topic_name, release_version])) | ||
1014 | 269 | else: | ||
1015 | 270 | form = PageForm(instance=page, version=version) | ||
1016 | 271 | context = { | ||
1017 | 272 | 'form': form, | ||
1018 | 273 | 'sidenav': topic_name, | ||
1019 | 274 | 'topic': topic, | ||
1020 | 275 | 'version': version, | ||
1021 | 276 | 'page': page, | ||
1022 | 277 | } | ||
1023 | 278 | return render_to_response('web/page_edit.html', context, RequestContext(request)) | ||
1024 | 279 | |||
1025 | 102 | def element_view(request, topic_name, release_version, element_fullname): | 280 | def element_view(request, topic_name, release_version, element_fullname): |
1026 | 103 | try: | 281 | try: |
1027 | 104 | element = Element.objects.get(section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, fullname=element_fullname) | 282 | element = Element.objects.get(section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, fullname=element_fullname) |
1028 | @@ -120,6 +298,51 @@ | |||
1029 | 120 | 'tutorials': tutorials | 298 | 'tutorials': tutorials |
1030 | 121 | } | 299 | } |
1031 | 122 | return render_to_response('web/element.html', context, RequestContext(request)) | 300 | return render_to_response('web/element.html', context, RequestContext(request)) |
1032 | 301 | |||
1033 | 302 | class ElementForm(ModelForm): | ||
1034 | 303 | class Meta: | ||
1035 | 304 | model = Element | ||
1036 | 305 | |||
1037 | 306 | def __init__(self, *args, **kargs): | ||
1038 | 307 | if 'version' in kargs: | ||
1039 | 308 | version = kargs['version'] | ||
1040 | 309 | del kargs['version'] | ||
1041 | 310 | elif hasattr(self, 'instance') and self.instance.section: | ||
1042 | 311 | version = self.instance.section.topic_version | ||
1043 | 312 | else: | ||
1044 | 313 | version=None | ||
1045 | 314 | super(ElementForm, self).__init__(*args, **kargs) | ||
1046 | 315 | self.fields['section'].queryset = Section.objects.filter(topic_version=version) | ||
1047 | 316 | self.fields['namespace'].queryset = Namespace.objects.filter(platform_section__topic_version=version) | ||
1048 | 317 | |||
1049 | 318 | def element_edit(request, topic_name, release_version, element_id=0): | ||
1050 | 319 | if element_id: | ||
1051 | 320 | element = get_object_or_404(Element, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, id=element_id) | ||
1052 | 321 | version = element.section.topic_version | ||
1053 | 322 | topic = version.topic | ||
1054 | 323 | else: | ||
1055 | 324 | topic = get_object_or_404(Topic, slug=topic_name) | ||
1056 | 325 | version = get_object_or_404(Version, slug=release_version, topic=topic) | ||
1057 | 326 | element = Element() | ||
1058 | 327 | |||
1059 | 328 | if not request.user.has_perm('apidocs.change_element'): | ||
1060 | 329 | return HttpResponseRedirect(reverse(element_view, args=[topic_name, release_version, element.fullname])) | ||
1061 | 330 | |||
1062 | 331 | if request.method == 'POST': | ||
1063 | 332 | form = ElementForm(request.POST, instance=element, version=version) | ||
1064 | 333 | if form.is_valid(): | ||
1065 | 334 | form.save() | ||
1066 | 335 | return HttpResponseRedirect(reverse(element_view, args=[topic_name, release_version, element.fullname])) | ||
1067 | 336 | else: | ||
1068 | 337 | form = ElementForm(instance=element, version=version) | ||
1069 | 338 | context = { | ||
1070 | 339 | 'form': form, | ||
1071 | 340 | 'sidenav': topic_name, | ||
1072 | 341 | 'topic': topic, | ||
1073 | 342 | 'version': version, | ||
1074 | 343 | 'element': element, | ||
1075 | 344 | } | ||
1076 | 345 | return render_to_response('web/element_edit.html', context, RequestContext(request)) | ||
1077 | 123 | 346 | ||
1078 | 124 | def search(request, topic_name, release_version): | 347 | def search(request, topic_name, release_version): |
1079 | 125 | version = get_object_or_404(Version, topic__slug=topic_name, slug=release_version) | 348 | version = get_object_or_404(Version, topic__slug=topic_name, slug=release_version) |
1080 | 126 | 349 | ||
1081 | === modified file 'requirements.txt' | |||
1082 | --- requirements.txt 2013-09-11 16:48:02 +0000 | |||
1083 | +++ requirements.txt 2013-10-31 19:44:44 +0000 | |||
1084 | @@ -3,3 +3,5 @@ | |||
1085 | 3 | distribute==0.6.31 | 3 | distribute==0.6.31 |
1086 | 4 | wsgiref==0.1.2 | 4 | wsgiref==0.1.2 |
1087 | 5 | South==0.8.2 | 5 | South==0.8.2 |
1088 | 6 | django-openid-auth==0.5 | ||
1089 | 7 | python-openid==2.2.4 |
Confirmed locally and in LXC deployment