Merge lp:~mhall119/ubuntu-api-website/content-editing into lp:ubuntu-api-website

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
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.
Revision history for this message
Michael Hall (mhall119) wrote :

Confirmed locally and in LXC deployment

review: Approve
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
=== added file 'developer_network/common/fixtures/auth_group.json'
--- developer_network/common/fixtures/auth_group.json 1970-01-01 00:00:00 +0000
+++ developer_network/common/fixtures/auth_group.json 2013-10-31 19:44:44 +0000
@@ -0,0 +1,1 @@
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]}}]
0\ No newline at end of file2\ No newline at end of file
13
=== added directory 'developer_network/common/management'
=== added file 'developer_network/common/management/__init__.py'
=== added directory 'developer_network/common/management/commands'
=== added file 'developer_network/common/management/commands/__init__.py'
=== added file 'developer_network/common/management/commands/initdb.py'
--- developer_network/common/management/commands/initdb.py 1970-01-01 00:00:00 +0000
+++ developer_network/common/management/commands/initdb.py 2013-10-31 19:44:44 +0000
@@ -0,0 +1,62 @@
1#!/usr/bin/python
2
3from django.core.management.base import BaseCommand
4from optparse import make_option
5
6import settings
7
8import subprocess
9import os
10import sys
11
12from common.models import Topic
13from apidocs.models import Element
14from django.contrib.auth.models import Group, Permission
15from django.contrib.contenttypes.models import ContentType
16
17PYTHON_BIN = sys.executable
18PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../../'))
19MANAGE_PY = os.path.join(PROJECT_ROOT, 'manage.py')
20COMMON_DATA = os.path.join(PROJECT_ROOT, 'common/fixtures/sample_data.json')
21APIDOCS_DATA = os.path.join(PROJECT_ROOT, 'apidocs/fixtures/sample_data.json')
22
23
24class Command(BaseCommand):
25 help = "Make sure The API Website database is set up properly."
26 option_list = BaseCommand.option_list + (
27 make_option(
28 "-f",
29 "--force",
30 dest="force",
31 help="Force initialization, even if data already exists",
32 action="store_true",
33 default=False
34 ),
35 )
36
37 def handle(self, summit='', *args, **options):
38
39 force = options.get('force', False)
40
41 if force or Topic.objects.all().count() == 0:
42 print "Loading Common data."
43 subprocess.call([PYTHON_BIN, MANAGE_PY, "loaddata", COMMON_DATA,
44 "--settings", "local_settings"])
45
46 if force or Element.objects.all().count() == 0:
47 print "Loading API data."
48 subprocess.call([PYTHON_BIN, MANAGE_PY, "loaddata", APIDOCS_DATA,
49 "--settings", "local_settings"])
50
51 if force or not Group.objects.filter(name='api-website-devs').exists():
52 print "Creating api-website-devs group."
53 devs, created = Group.objects.get_or_create(name='api-website-devs')
54 common_perms = Permission.objects.filter(content_type__app_label='common')
55 apidocs_perms = Permission.objects.filter(content_type__app_label='apidocs')
56 related_perms = Permission.objects.filter(content_type__app_label='related')
57 search_perms = Permission.objects.filter(content_type__app_label='search')
58 devs.permissions.add(*list(common_perms))
59 devs.permissions.add(*list(apidocs_perms))
60 devs.permissions.add(*list(related_perms))
61 devs.permissions.add(*list(search_perms))
62
063
=== added directory 'developer_network/common/templates'
=== added file 'developer_network/common/templates/500.html'
--- developer_network/common/templates/500.html 1970-01-01 00:00:00 +0000
+++ developer_network/common/templates/500.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,10 @@
1{% extends "base.html" %}
2
3{% block page_name %}Oops{%endblock %}
4
5{% block sub_nav %}{% endblock %}
6
7{% block content %}
8<p>This page encountered an error, don't worry - we have been notified. Please accept our apologies.</p>
9{% endblock %}
10
011
=== added file 'developer_network/common/templates/login_failure.html'
--- developer_network/common/templates/login_failure.html 1970-01-01 00:00:00 +0000
+++ developer_network/common/templates/login_failure.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,37 @@
1{% extends "base.html" %}
2
3{% block page_name %}Login Failure{%endblock %}
4
5{% block defaulthead %}
6{% with '/static/ubuntu-website/' as ubuntu_website_media %}
7{{ block.super }}
8{% endwith %}
9{% endblock %}
10
11{% block extrahead %}
12{% with '/static/' as MEDIA_URL %}
13{{ block.super }}
14{% endwith %}
15{% endblock %}
16{% block main_nav_links %}{% endblock %}
17
18{% block sub_nav %}{% endblock %}
19
20{% block content %}
21
22<article class="main-content">
23 <h2>{{message|safe}}</h2>
24
25 {% if exception %}
26 <p>{{exception.message|safe}}</p>
27 {% endif %}
28
29 {% if solution %}
30 <p>{{solution|safe}}</p>
31 {% endif %}
32
33 <p>If you continue to experience problems with Summit, please <a href='https://bugs.launchpad.net/summit'>Report it!</a>
34 </p>
35</article>
36
37{% endblock %}
038
=== modified file 'developer_network/common/views.py'
--- developer_network/common/views.py 2013-02-08 22:36:08 +0000
+++ developer_network/common/views.py 2013-10-31 19:44:44 +0000
@@ -1,1 +1,27 @@
1# Create your views here.1from django.shortcuts import render_to_response, redirect
2from django.template.loader import render_to_string
3from django.template import RequestContext
4from django.http import HttpResponse, HttpResponseRedirect
5from django.core.urlresolvers import reverse
6from django.contrib.auth import logout
7
8def login_failure(request, message, status=403,
9 template_name='login_failure.html',
10 exception=None):
11 """Render an error page to the user."""
12 context = {
13 'message': message,
14 'exception': exception,
15 }
16 if isinstance(exception, MissingPhysicalMultiFactor):
17 context['solution'] = 'Try logging in again using your Yubikey'
18 elif isinstance(exception, MissingUsernameViolation):
19 context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use The API Website'
20
21 data = render_to_string(template_name, context,
22 context_instance=RequestContext(request))
23 return HttpResponse(data, status=status)
24
25def logout_view(request):
26 logout(request)
27 return HttpResponseRedirect('/')
228
=== modified file 'developer_network/settings.py'
--- developer_network/settings.py 2013-09-13 18:35:01 +0000
+++ developer_network/settings.py 2013-10-31 19:44:44 +0000
@@ -128,6 +128,7 @@
128 'related',128 'related',
129 'web',129 'web',
130 'ubuntu_website',130 'ubuntu_website',
131 'django_openid_auth',
131)132)
132133
133# A sample logging configuration. The only tangible logging134# A sample logging configuration. The only tangible logging
@@ -152,3 +153,21 @@
152 },153 },
153 }154 }
154}155}
156
157AUTHENTICATION_BACKENDS = (
158 'django_openid_auth.auth.OpenIDBackend',
159 'django.contrib.auth.backends.ModelBackend',
160)
161# OPENID Related settings
162OPENID_STRICT_USERNAMES = True
163OPENID_FOLLOW_RENAMES = True
164OPENID_SREG_REQUIRED_FIELDS = ['email']
165OPENID_CREATE_USERS = True
166OPENID_REUSE_USERS = True
167OPENID_UPDATE_DETAILS_FROM_SREG = True
168OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/'
169OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True
170
171# Tell django.contrib.auth to use the OpenID signin URLs.
172LOGIN_URL = '/api/login'
173LOGIN_REDIRECT_URL = '/'
155174
=== modified file 'developer_network/urls.py'
--- developer_network/urls.py 2013-10-04 19:56:27 +0000
+++ developer_network/urls.py 2013-10-31 19:44:44 +0000
@@ -8,6 +8,16 @@
8from django.contrib.staticfiles.urls import staticfiles_urlpatterns8from django.contrib.staticfiles.urls import staticfiles_urlpatterns
9urlpatterns = staticfiles_urlpatterns()9urlpatterns = staticfiles_urlpatterns()
1010
11from common.views import login_failure
12urlpatterns += patterns(
13 'django_openid_auth.views',
14 url(r'^api/login/$', 'login_begin', name='openid-login',
15 kwargs={'render_failure': login_failure}),
16 url(r'^api/openid/complete/$', 'login_complete', name='openid-complete',
17 kwargs={'render_failure': login_failure}),
18 url(r'^api/openid/logo.gif$', 'logo', name='openid-logo'),
19)
20
11urlpatterns += patterns('',21urlpatterns += patterns('',
12 # Examples:22 # Examples:
13 # url(r'^developer_network/', include('developer_network.foo.urls')),23 # url(r'^developer_network/', include('developer_network.foo.urls')),
@@ -17,14 +27,33 @@
1727
18 # Uncomment the next line to enable the admin:28 # Uncomment the next line to enable the admin:
19 url(r'^api/admin/', include(admin.site.urls)),29 url(r'^api/admin/', include(admin.site.urls)),
30 url(r'^api/logout/$', 'common.views.logout_view', name='logout'),
2031
21 url(r'^$', 'web.views.overview', name='overview'),32 url(r'^$', 'web.views.overview', name='overview'),
22 url(r'^api/$', 'web.views.overview', name='overview'),33 url(r'^api/$', 'web.views.overview', name='overview'),
34
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'),
36 url(r'^api/\+topic/$', 'web.views.topic_edit', name='topic_edit'),
37 url(r'^api/\+topic/(?P<topic_id>[\d]+)/$', 'web.views.topic_edit', name='topic_edit'),
38
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'),
40 url(r'^api/(?P<topic_name>[\w\.-]+)/\+version/$', 'web.views.version_edit', name='version_edit'),
41 url(r'^api/(?P<topic_name>[\w\.-]+)/\+version/(?P<version_id>[\d]+)/$', 'web.views.version_edit', name='version_edit'),
42
43 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+section/(?P<section_id>[\d]+)/$', 'web.views.section_edit', name='section_edit'),
44 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+section/$', 'web.views.section_edit', name='section_edit'),
45
46 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+namespace/(?P<namespace_id>[\d]+)/$', 'web.views.namespace_edit', name='namespace_edit'),
47 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<version_name>[\w\.-]+)/\+namespace/$', 'web.views.namespace_edit', name='namespace_edit'),
48
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'),
2650
27 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/(?P<element_fullname>[\w\.\-\:]+).html$', 'web.views.element_view', name='element'),
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'),
52 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+element/(?P<element_id>[\d]+)/$', 'web.views.element_edit', name='element_edit'),
53 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+element/$', 'web.views.element_edit', name='element_edit'),
54 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+page/(?P<page_id>[\d]+)/$', 'web.views.page_edit', name='page_edit'),
55 url(r'^api/(?P<topic_name>[\w\.-]+)/(?P<release_version>[\w\.-]+)/\+page/$', 'web.views.page_edit', name='page_edit'),
2956
30)57)
58
59
3160
=== modified file 'developer_network/web/static/css/site.css'
--- developer_network/web/static/css/site.css 2013-10-22 20:54:40 +0000
+++ developer_network/web/static/css/site.css 2013-10-31 19:44:44 +0000
@@ -21,6 +21,25 @@
21 display: inline;21 display: inline;
22}22}
2323
24#editor_actions {
25 background-color: #F1F1F1;
26 padding: 5px;
27 margin-bottom: 10px;
28 /* border-bottom: 1px dotted; */
29}
30
31#editor_actions ul {
32 margin: 0px;
33}
34
35#editor_actions li {
36 margin-right: 10px;
37 margin-bottom: 0;
38 line-height: 33px;
39 float: left;
40 list-style: none;
41 list-style-image: none;
42}
24/*43/*
25 * release.html44 * release.html
26 */45 */
@@ -47,6 +66,16 @@
47 border-top: 1px dotted;66 border-top: 1px dotted;
48}67}
4968
69.section_title A.section_editor_action {
70 float: right;
71 font-size: .7em;
72 display: none;
73}
74
75.section_title:hover A.section_editor_action {
76 display: inherit;
77}
78
50/*79/*
51 * element.html80 * element.html
52*/81*/
@@ -75,54 +104,63 @@
75 padding: 3px;104 padding: 3px;
76}105}
77106
107/*
108 * element.html
109*/
110#element_content TEXTAREA {
111 height: inherit;
112 width: inherit;
113 max-width: none;
114 max-height: none;
115}
78/* 116/*
79 * sidenav.html117 * sidenav.html
80 */118 */
81119
82.ui-state-focus {120.ui-state-focus {
83 outline: none;121 outline: none;
84}122}
85.ui-accordion {123.ui-accordion {
86 border-bottom: 1px dotted #aea79f;124 border-bottom: 1px dotted #aea79f;
87}125}
88.ui-accordion a {126.ui-accordion a {
89 display: block;127 display: block;
90}128}
91.ui-accordion h3 {129.ui-accordion h3 {
92 margin-bottom: 0;130 margin-bottom: 0;
93 border-top: 1px dotted #aea79f;131 border-top: 1px dotted #aea79f;
94 position: relative;132 position: relative;
95 font-size: 13px;133 font-size: 13px;
96 font-weight: bold;134 font-weight: bold;
97}135}
98.ui-accordion h3 a {136.ui-accordion h3 a {
99 padding: 10px 0;137 padding: 10px 0;
100 color: #333;138 color: #333;
101}139}
102.ui-accordion h4 {140.ui-accordion h4 {
103 margin-bottom: 5px;141 margin-bottom: 5px;
104}142}
105.ui-accordion div fieldset {143.ui-accordion div fieldset {
106 padding-bottom: 5px;144 padding-bottom: 5px;
107}145}
108.ui-accordion div li,146.ui-accordion div li,
109.ui-accordion div input {147.ui-accordion div input {
110 margin-bottom: 10px;148 margin-bottom: 10px;
111}149}
112.ui-accordion .ui-icon {150.ui-accordion .ui-icon {
113 position: absolute;151 position: absolute;
114 top: 15px;152 top: 15px;
115 right: 0;153 right: 0;
116 display: block;154 display: block;
117 width: 8px;155 width: 8px;
118 height: 8px;156 height: 8px;
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;
120}158}
121.ui-accordion .ui-state-active .ui-icon {159.ui-accordion .ui-state-active .ui-icon {
122 background-image: url("../img/icon-accordion-active.png");160 background-image: url("../img/icon-accordion-active.png");
123}161}
124.ui-accordion .current_page_item a {162.ui-accordion .current_page_item a {
125 color: #333;163 color: #333;
126}164}
127165
128/*166/*
129167
=== modified file 'developer_network/web/templates/web/article.html'
--- developer_network/web/templates/web/article.html 2013-09-23 21:27:54 +0000
+++ developer_network/web/templates/web/article.html 2013-10-31 19:44:44 +0000
@@ -26,6 +26,23 @@
26 {% endblock %}26 {% endblock %}
27 </span>27 </span>
28 </section>28 </section>
29 {% block editor_actions %}
30 {% if perms.common or perms.apidocs %}
31 <section id="editor_actions">
32 <span style="float: right;">
33 <ul class="clearfix">
34 <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li>
35 </ul>
36 </span>
37 <span id="editor_links">
38 <ul class="clearfix">
39 {% block editor_links %}
40 {% endblock %}
41 </ul>
42 </span>
43 </section>
44 {% endif %}
45 {% endblock %}
29 <article>46 <article>
30 {% block article_content %}47 {% block article_content %}
31 {% endblock %}48 {% endblock %}
3249
=== modified file 'developer_network/web/templates/web/distro.html'
--- developer_network/web/templates/web/distro.html 2013-09-13 14:01:30 +0000
+++ developer_network/web/templates/web/distro.html 2013-10-31 19:44:44 +0000
@@ -3,6 +3,26 @@
3{% block sub_nav %}{% endblock %}3{% block sub_nav %}{% endblock %}
44
5{% block content %}5{% block content %}
6{% if perms.common %}
7<section id="editor_actions">
8 <span style="float: right;">
9 <ul class="clearfix">
10 <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li>
11 </ul>
12 </span>
13 <span id="editor_links">
14 <ul class="clearfix">
15 {% if perms.common.change_topic %}
16 <li><a href="{% url topic_edit topic.id %}">Edit</a></li>
17 {% endif %}
18 {% if perms.common.add_version %}
19 <li><a href="{% url version_edit topic.slug %}">+ Version</a></li>
20 {% endif %}
21 </ul>
22 </span>
23</section>
24{% endif %}
25
6<h2>{{topic.name}} Versions</h2>26<h2>{{topic.name}} Versions</h2>
7<ul>27<ul>
8{% for version in topic.version_set.all %}28{% for version in topic.version_set.all %}
929
=== modified file 'developer_network/web/templates/web/element.html'
--- developer_network/web/templates/web/element.html 2013-09-19 17:48:26 +0000
+++ developer_network/web/templates/web/element.html 2013-10-31 19:44:44 +0000
@@ -1,5 +1,14 @@
1{% extends "web/article.html" %}1{% extends "web/article.html" %}
22
3{% block editor_links %}
4 {% if perms.apidocs.change_element %}
5 <li><a href="{% url element_edit topic.slug, version.slug, element.id %}">Edit</a></li>
6 {% endif %}
7 {% if perms.apidocs.delete_element %}
8 <li><a href="{% url element_edit topic.slug, version.slug, element.id %}?action=delete">Delete</a></li>
9 {% endif %}
10{% endblock %}
11
3{% block breadcrumbs %}12{% block breadcrumbs %}
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>
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>
615
=== added file 'developer_network/web/templates/web/element_edit.html'
--- developer_network/web/templates/web/element_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/element_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,48 @@
1{% extends "web/article.html" %}
2
3{% block editor_links %}
4 {% if element.id and perms.apidocs.delete_element %}
5 <li><a href="{% url element_edit topic.slug version.slug element.id %}?action=delete">Delete</a></li>
6 {% endif %}
7{% endblock %}
8
9{% block breadcrumbs %}
10{% endblock %}
11
12{% block article_content %}
13{% if element.id %}
14<h1>Edit: {{element.name}}</h1>
15{% else %}
16<h1>New Element</h1>
17{% endif %}
18
19<form action="" method="POST" id="element_form">
20{% csrf_token %}
21<div id="element_content">
22{{ form.as_p }}
23</div>
24<input type="submit" value="Save">
25</form>
26
27{% comment %}
28<h3>Snippets</h3>
29{% for snippet in snippets %}
30 <div>
31 <li>{{ snippet.name }}</li>
32 </div>
33{% endfor %}
34
35<h3>Questions & Answers</h3>
36{% for question in questions %}
37 <div>
38 <li><a href="{{ question.url }}">{{ question.name }}</a></li>
39 </div>
40{% endfor %}
41<h3>Tutorials</h3>
42{% for tutorial in tutorials %}
43 <div>
44 <li><a href="{{ tutorial.url }}">{{ tutorial.name }}</a></li>
45 </div>
46{% endfor %}
47{% endcomment %}
48{% endblock %}
049
=== modified file 'developer_network/web/templates/web/namespace.html'
--- developer_network/web/templates/web/namespace.html 2013-10-04 19:56:27 +0000
+++ developer_network/web/templates/web/namespace.html 2013-10-31 19:44:44 +0000
@@ -1,5 +1,17 @@
1{% extends "web/article.html" %}1{% extends "web/article.html" %}
22
3{% block editor_links %}
4 {% if perms.apidocs.change_namespace %}
5 <li><a href="{% url namespace_edit version.topic.slug version.slug namespace.id%}">Edit</a></li>
6 {% endif %}
7 {% if perms.apidocs.add_element %}
8 <li><a href="{% url element_edit version.topic.slug version.slug %}">+ Element</a></li>
9 {% endif %}
10 {% if perms.apidocs.add_page %}
11 <li><a href="{% url page_edit version.topic.slug version.slug %}">+ Page</a></li>
12 {% endif %}
13{% endblock %}
14
3{% block breadcrumbs %}15{% block breadcrumbs %}
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>
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>
618
=== added file 'developer_network/web/templates/web/namespace_edit.html'
--- developer_network/web/templates/web/namespace_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/namespace_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,48 @@
1{% extends "web/article.html" %}
2
3{% block editor_links %}
4 {% if namespace.id and perms.apidocs.delete_namespace %}
5 <li><a href="{% url namespace_edit topic.slug version.slug namespace.id %}?action=delete">Delete</a></li>
6 {% endif %}
7{% endblock %}
8
9{% block breadcrumbs %}
10{% endblock %}
11
12{% block article_content %}
13{% if namespace.id %}
14<h1>Edit: {{namespace.name}}</h1>
15{% else %}
16<h1>New Namespace</h1>
17{% endif %}
18
19<form action="" method="POST" id="namespace_form">
20{% csrf_token %}
21<div id="namespace_content">
22{{ form.as_p }}
23</div>
24<input type="submit" value="Save">
25</form>
26
27{% comment %}
28<h3>Snippets</h3>
29{% for snippet in snippets %}
30 <div>
31 <li>{{ snippet.name }}</li>
32 </div>
33{% endfor %}
34
35<h3>Questions & Answers</h3>
36{% for question in questions %}
37 <div>
38 <li><a href="{{ question.url }}">{{ question.name }}</a></li>
39 </div>
40{% endfor %}
41<h3>Tutorials</h3>
42{% for tutorial in tutorials %}
43 <div>
44 <li><a href="{{ tutorial.url }}">{{ tutorial.name }}</a></li>
45 </div>
46{% endfor %}
47{% endcomment %}
48{% endblock %}
049
=== modified file 'developer_network/web/templates/web/overview.html'
--- developer_network/web/templates/web/overview.html 2013-09-13 14:01:30 +0000
+++ developer_network/web/templates/web/overview.html 2013-10-31 19:44:44 +0000
@@ -3,6 +3,23 @@
3{% block sub_nav %}{% endblock %}3{% block sub_nav %}{% endblock %}
44
5{% block content %}5{% block content %}
6{% if perms.common %}
7<section id="editor_actions">
8 <span style="float: right;">
9 <ul class="clearfix">
10 <li><a href="{% url logout %}" title="You are logged in as: {{user.username}}">Logout</a></li>
11 </ul>
12 </span>
13 <span id="editor_links">
14 <ul class="clearfix">
15 {% if perms.common.add_topic %}
16 <li><a href="{% url topic_edit %}">+ Topic</a></li>
17 {% endif %}
18 </ul>
19 </span>
20</section>
21{% endif %}
22
6<h2>Topics</h2>23<h2>Topics</h2>
7<ul>24<ul>
8{% for topic in topics %}25{% for topic in topics %}
926
=== modified file 'developer_network/web/templates/web/page.html'
--- developer_network/web/templates/web/page.html 2013-10-04 19:56:27 +0000
+++ developer_network/web/templates/web/page.html 2013-10-31 19:44:44 +0000
@@ -1,5 +1,14 @@
1{% extends "web/article.html" %}1{% extends "web/article.html" %}
22
3{% block editor_links %}
4 {% if perms.apidocs.change_page %}
5 <li><a href="{% url page_edit topic.slug version.slug page.id %}">Edit</a></li>
6 {% endif %}
7 {% if perms.apidocs.delete_page %}
8 <li><a href="{% url page_edit topic.slug version.slug page.id %}?action=delete">Delete</a></li>
9 {% endif %}
10{% endblock %}
11
3{% block breadcrumbs %}12{% block breadcrumbs %}
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>
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>
615
=== added file 'developer_network/web/templates/web/page_edit.html'
--- developer_network/web/templates/web/page_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/page_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,25 @@
1{% extends "web/article.html" %}
2
3{% block editor_links %}
4 {% if page.id and perms.apidocs.delete_page %}
5 <li><a href="{% url page_edit topic.slug version.slug page.id %}?action=delete">Delete</a></li>
6 {% endif %}
7{% endblock %}
8
9{% block breadcrumbs %}
10{% endblock %}
11
12{% block article_content %}
13{% if page.id %}
14<h2>Edit {{page.name}}</h2>
15{% else %}
16<h2>New Page</h2>
17{% endif %}
18
19<form action="" method="POST" id="page_form">
20{% csrf_token %}
21{{ form.as_p }}
22<input type="submit" value="Save">
23</form>
24
25{% endblock %}
026
=== modified file 'developer_network/web/templates/web/release.html'
--- developer_network/web/templates/web/release.html 2013-09-19 17:48:26 +0000
+++ developer_network/web/templates/web/release.html 2013-10-31 19:44:44 +0000
@@ -1,5 +1,20 @@
1{% extends "web/article.html" %}1{% extends "web/article.html" %}
22
3{% block editor_links %}
4 {% if perms.common.change_version %}
5 <li><a href="{% url version_edit version.topic.slug version.id %}">Edit</a></li>
6 {% endif %}
7 {% if perms.common.add_section %}
8 <li><a href="{% url section_edit version.topic.slug version.slug %}">+ Section</a></li>
9 {% endif %}
10 {% if perms.apidocs.add_namespace %}
11 <li><a href="{% url namespace_edit version.topic.slug version.slug %}">+ Namespace</a></li>
12 {% endif %}
13 {% if perms.apidocs.add_element %}
14 <li><a href="{% url element_edit version.topic.slug version.slug %}">+ Element</a></li>
15 {% endif %}
16{% endblock %}
17
3{% block breadcrumbs %}18{% block breadcrumbs %}
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>
5<li> › {{version.name}}</li>20<li> › {{version.name}}</li>
@@ -10,7 +25,7 @@
10<table class="section_list"><tr>25<table class="section_list"><tr>
11 <td id="first_column">26 <td id="first_column">
12 {% for section in first_column %}27 {% for section in first_column %}
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>
14 <ul>29 <ul>
15 {% for namespace in section.namespace_set.all %}30 {% for namespace in section.namespace_set.all %}
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>
@@ -33,7 +48,7 @@
33 {% if second_column %}48 {% if second_column %}
34 <td id="second_column">49 <td id="second_column">
35 {% for section in second_column %}50 {% for section in second_column %}
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>
37 <ul>52 <ul>
38 {% for namespace in section.namespace_set.all %}53 {% for namespace in section.namespace_set.all %}
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>
4055
=== modified file 'developer_network/web/templates/web/search.html'
--- developer_network/web/templates/web/search.html 2013-09-23 21:27:54 +0000
+++ developer_network/web/templates/web/search.html 2013-10-31 19:44:44 +0000
@@ -1,5 +1,7 @@
1{% extends "web/article.html" %}1{% extends "web/article.html" %}
22
3{% block editor_actions %}{% endblock %}
4
3{% block breadcrumbs %}5{% block breadcrumbs %}
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>
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>
68
=== added file 'developer_network/web/templates/web/section_edit.html'
--- developer_network/web/templates/web/section_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/section_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,25 @@
1{% extends "web/article.html" %}
2
3{% block editor_links %}
4 {% if section.id and perms.common.delete_section %}
5 <li><a href="{% url section_edit topic.slug version.slug section.id %}?action=delete">Delete</a></li>
6 {% endif %}
7{% endblock %}
8
9{% block breadcrumbs %}
10{% endblock %}
11
12{% block article_content %}
13{% if section.id %}
14<h2>Edit {{section.name}}</h2>
15{% else %}
16<h2>New Section</h2>
17{% endif %}
18
19<form action="" method="POST" id="section_form">
20{% csrf_token %}
21{{ form.as_p }}
22<input type="submit" value="Save">
23</form>
24
25{% endblock %}
026
=== added file 'developer_network/web/templates/web/topic_edit.html'
--- developer_network/web/templates/web/topic_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/topic_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,18 @@
1{% extends "web/base.html" %}
2
3{% block sub_nav %}{% endblock %}
4
5{% block content %}
6
7{% if topic.id %}
8<h2>Edit: {{topic.name}}</h2>
9{% else %}
10<h2>New Topic</h2>
11{% endif %}
12
13<form action="" method="POST" id="topic_form">
14{% csrf_token %}
15{{ form.as_p }}
16<input type="submit" value="Save">
17</form>
18{% endblock %}
019
=== added file 'developer_network/web/templates/web/version_edit.html'
--- developer_network/web/templates/web/version_edit.html 1970-01-01 00:00:00 +0000
+++ developer_network/web/templates/web/version_edit.html 2013-10-31 19:44:44 +0000
@@ -0,0 +1,23 @@
1{% extends "web/base.html" %}
2
3{% block editor_links %}
4 <li><a href="{% url version_edit version.id %}?action=delete">Delete</a></li>
5{% endblock %}
6
7{% block breadcrumbs %}
8{% endblock %}
9
10{% block content %}
11{% if version.id %}
12<h2>Edit {{version.name}}</h2>
13{% else %}
14<h2>New Version</h2>
15{% endif %}
16
17<form action="" method="POST" id="element_form">
18{% csrf_token %}
19{{ form.as_p }}
20<input type="submit" value="Save">
21</form>
22
23{% endblock %}
024
=== modified file 'developer_network/web/views.py'
--- developer_network/web/views.py 2013-10-04 19:56:27 +0000
+++ developer_network/web/views.py 2013-10-31 19:44:44 +0000
@@ -2,6 +2,7 @@
2from django.http import HttpResponse, HttpResponseRedirect2from django.http import HttpResponse, HttpResponseRedirect
3from django.core.urlresolvers import reverse3from django.core.urlresolvers import reverse
4from django.template import loader, RequestContext4from django.template import loader, RequestContext
5from django.forms import ModelForm
56
6from common.models import Topic, Version, Section7from common.models import Topic, Version, Section
7from apidocs.models import Namespace, Element, Page8from apidocs.models import Namespace, Element, Page
@@ -24,6 +25,32 @@
24 }25 }
25 return render_to_response('web/distro.html', context, RequestContext(request))26 return render_to_response('web/distro.html', context, RequestContext(request))
2627
28class TopicForm(ModelForm):
29 class Meta:
30 model = Topic
31
32def topic_edit(request, topic_id=0):
33 if topic_id:
34 topic = get_object_or_404(Topic, id=topic_id)
35 else:
36 topic = Topic()
37
38 if not request.user.has_perm('common.change_topic'):
39 return HttpResponseRedirect(reverse(topic_view, args=[topic.slug]))
40
41 if request.method == 'POST':
42 form = TopicForm(request.POST, instance=topic)
43 if form.is_valid():
44 form.save()
45 return HttpResponseRedirect(reverse(topic_view, args=[topic.slug]))
46 else:
47 form = TopicForm(instance=topic)
48 context = {
49 'form': form,
50 'topic': topic,
51 }
52 return render_to_response('web/topic_edit.html', context, RequestContext(request))
53
27def version_view(request, topic_name, release_version):54def version_view(request, topic_name, release_version):
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)
2956
@@ -63,6 +90,68 @@
63 }90 }
64 return render_to_response('web/release.html', context, RequestContext(request))91 return render_to_response('web/release.html', context, RequestContext(request))
6592
93class VersionForm(ModelForm):
94 class Meta:
95 model = Version
96
97def version_edit(request, topic_name, version_id=0):
98 if version_id:
99 version = get_object_or_404(Version, topic__slug=topic_name, id=version_id)
100 topic = version.topic
101 else:
102 topic = get_object_or_404(Topic, slug=topic_name)
103 version = Version(topic=topic)
104
105 if not request.user.has_perm('common.change_version'):
106 return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug]))
107
108 if request.method == 'POST':
109 form = VersionForm(request.POST, instance=version)
110 if form.is_valid():
111 form.save()
112 return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug]))
113 else:
114 form = VersionForm(instance=version)
115 context = {
116 'form': form,
117 'topic': topic,
118 'version': version,
119 }
120 return render_to_response('web/version_edit.html', context, RequestContext(request))
121
122class SectionForm(ModelForm):
123 class Meta:
124 model = Section
125
126def section_edit(request, topic_name, version_name, section_id=0):
127 if section_id:
128 section = get_object_or_404(Section, topic_version__topic__slug=topic_name, topic_version__slug=version_name, id=section_id)
129 version = section.topic_version
130 topic = version.topic
131 else:
132 topic = get_object_or_404(Topic, slug=topic_name)
133 version = get_object_or_404(Version, topic=topic, slug=version_name)
134 section = Section(topic_version=version)
135
136 if not request.user.has_perm('common.change_section'):
137 return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug]))
138
139 if request.method == 'POST':
140 form = SectionForm(request.POST, instance=section)
141 if form.is_valid():
142 form.save()
143 return HttpResponseRedirect(reverse(version_view, args=[topic.slug, version.slug]))
144 else:
145 form = SectionForm(instance=section)
146 context = {
147 'sidenav': topic_name,
148 'form': form,
149 'topic': topic,
150 'version': version,
151 'section': section,
152 }
153 return render_to_response('web/section_edit.html', context, RequestContext(request))
154
66def namespace_view(request, topic_name, release_version, namespace_name):155def namespace_view(request, topic_name, release_version, namespace_name):
67 try:156 try:
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)
@@ -82,6 +171,50 @@
82 }171 }
83 return render_to_response('web/namespace.html', context, RequestContext(request))172 return render_to_response('web/namespace.html', context, RequestContext(request))
84173
174class NamespaceForm(ModelForm):
175 class Meta:
176 model = Namespace
177
178 def __init__(self, *args, **kargs):
179 if 'version' in kargs:
180 version = kargs['version']
181 del kargs['version']
182 elif hasattr(self, 'instance') and self.instance.section:
183 version = self.instance.section.topic_version
184 else:
185 version=None
186 super(NamespaceForm, self).__init__(*args, **kargs)
187 self.fields['platform_section'].queryset = Section.objects.filter(topic_version=version)
188
189def namespace_edit(request, topic_name, version_name, namespace_id=0):
190 if namespace_id:
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)
192 version = namespace.platform_section.topic_version
193 topic = version.topic
194 else:
195 topic = get_object_or_404(Topic, slug=topic_name)
196 version = get_object_or_404(Version, slug=version_name, topic=topic)
197 namespace = Namespace()
198
199 if not request.user.has_perm('apidocs.change_namespace'):
200 return HttpResponseRedirect(reverse(element_view, args=[topic_name, version_name, namespace.name]))
201
202 if request.method == 'POST':
203 form = NamespaceForm(request.POST, instance=namespace, version=version)
204 if form.is_valid():
205 form.save()
206 return HttpResponseRedirect(reverse(element_view, args=[topic_name, version_name, namespace.name]))
207 else:
208 form = NamespaceForm(instance=namespace, version=version)
209 context = {
210 'form': form,
211 'sidenav': topic_name,
212 'topic': topic,
213 'version': version,
214 'namespace': namespace,
215 }
216 return render_to_response('web/namespace_edit.html', context, RequestContext(request))
217
85def page_view(request, topic_name, release_version, page_fullname):218def page_view(request, topic_name, release_version, page_fullname):
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)
87220
@@ -99,6 +232,51 @@
99 }232 }
100 return render_to_response('web/page.html', context, RequestContext(request))233 return render_to_response('web/page.html', context, RequestContext(request))
101234
235class PageForm(ModelForm):
236 class Meta:
237 model = Page
238
239 def __init__(self, *args, **kargs):
240 if 'version' in kargs:
241 version = kargs['version']
242 del kargs['version']
243 elif hasattr(self, 'instance') and self.instance.section:
244 version = self.instance.section.topic_version
245 else:
246 version=None
247 super(PageForm, self).__init__(*args, **kargs)
248 self.fields['section'].queryset = Section.objects.filter(topic_version=version)
249 self.fields['namespace'].queryset = Namespace.objects.filter(platform_section__topic_version=version)
250
251def page_edit(request, topic_name, release_version, page_id=0):
252 if page_id:
253 page = get_object_or_404(Page, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, id=page_id)
254 version = page.section.topic_version
255 topic = version.topic
256 else:
257 topic = get_object_or_404(Topic, slug=topic_name)
258 version = get_object_or_404(Version, slug=release_version, topic=topic)
259 page = Page()
260
261 if not request.user.has_perm('apidocs.change_page'):
262 return HttpResponseRedirect(reverse(version_view, args=[topic_name, release_version]))
263
264 if request.method == 'POST':
265 form = PageForm(request.POST, instance=page, version=version)
266 if form.is_valid():
267 form.save()
268 return HttpResponseRedirect(reverse(version_view, args=[topic_name, release_version]))
269 else:
270 form = PageForm(instance=page, version=version)
271 context = {
272 'form': form,
273 'sidenav': topic_name,
274 'topic': topic,
275 'version': version,
276 'page': page,
277 }
278 return render_to_response('web/page_edit.html', context, RequestContext(request))
279
102def element_view(request, topic_name, release_version, element_fullname):280def element_view(request, topic_name, release_version, element_fullname):
103 try:281 try:
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)
@@ -120,6 +298,51 @@
120 'tutorials': tutorials298 'tutorials': tutorials
121 }299 }
122 return render_to_response('web/element.html', context, RequestContext(request))300 return render_to_response('web/element.html', context, RequestContext(request))
301
302class ElementForm(ModelForm):
303 class Meta:
304 model = Element
305
306 def __init__(self, *args, **kargs):
307 if 'version' in kargs:
308 version = kargs['version']
309 del kargs['version']
310 elif hasattr(self, 'instance') and self.instance.section:
311 version = self.instance.section.topic_version
312 else:
313 version=None
314 super(ElementForm, self).__init__(*args, **kargs)
315 self.fields['section'].queryset = Section.objects.filter(topic_version=version)
316 self.fields['namespace'].queryset = Namespace.objects.filter(platform_section__topic_version=version)
317
318def element_edit(request, topic_name, release_version, element_id=0):
319 if element_id:
320 element = get_object_or_404(Element, section__topic_version__slug=release_version, section__topic_version__topic__slug=topic_name, id=element_id)
321 version = element.section.topic_version
322 topic = version.topic
323 else:
324 topic = get_object_or_404(Topic, slug=topic_name)
325 version = get_object_or_404(Version, slug=release_version, topic=topic)
326 element = Element()
327
328 if not request.user.has_perm('apidocs.change_element'):
329 return HttpResponseRedirect(reverse(element_view, args=[topic_name, release_version, element.fullname]))
330
331 if request.method == 'POST':
332 form = ElementForm(request.POST, instance=element, version=version)
333 if form.is_valid():
334 form.save()
335 return HttpResponseRedirect(reverse(element_view, args=[topic_name, release_version, element.fullname]))
336 else:
337 form = ElementForm(instance=element, version=version)
338 context = {
339 'form': form,
340 'sidenav': topic_name,
341 'topic': topic,
342 'version': version,
343 'element': element,
344 }
345 return render_to_response('web/element_edit.html', context, RequestContext(request))
123 346
124def search(request, topic_name, release_version):347def search(request, topic_name, release_version):
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)
126349
=== modified file 'requirements.txt'
--- requirements.txt 2013-09-11 16:48:02 +0000
+++ requirements.txt 2013-10-31 19:44:44 +0000
@@ -3,3 +3,5 @@
3distribute==0.6.313distribute==0.6.31
4wsgiref==0.1.24wsgiref==0.1.2
5South==0.8.25South==0.8.2
6django-openid-auth==0.5
7python-openid==2.2.4

Subscribers

People subscribed via source and target branches