This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
11 changed files
with
384 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,57 @@ | ||
from datetime import datetime | ||
|
||
from django.contrib import admin | ||
from django.core import serializers | ||
from django.http import HttpResponse | ||
|
||
from smuggler.settings import SMUGGLER_FORMAT | ||
from smuggler.utils import serialize_to_response | ||
|
||
from wiki.models import Document, Revision, EditorToolbar | ||
|
||
|
||
def dump_selected(modeladmin, request, queryset): | ||
objects = [] | ||
for doc in queryset.all(): | ||
rev = Revision.objects.get(id=doc.current_revision.id) | ||
doc.current_revision = None | ||
objects.append(doc) | ||
objects.append(rev) | ||
serializers.get_serializer('json') | ||
filename = "documents_%s.%s" % ( | ||
datetime.now().isoformat(), SMUGGLER_FORMAT) | ||
response = HttpResponse(mimetype="text/plain") | ||
response['Content-Disposition'] = 'attachment; filename=%s' % filename | ||
return serialize_to_response(objects, response) | ||
|
||
dump_selected.short_description = "Dump selected objects as JSON data" | ||
|
||
|
||
class DocumentAdmin(admin.ModelAdmin): | ||
exclude = ('tags',) | ||
list_display = ('id', 'locale', 'slug', 'title', 'category', | ||
'is_localizable') | ||
actions = [dump_selected, ] | ||
change_list_template = 'admin/wiki/document/change_list.html' | ||
fields = ('title', 'slug', 'locale', 'parent', 'category') | ||
list_display = ('id', 'locale', 'slug', 'title', 'is_localizable', | ||
'modified', 'parent_document_link', | ||
'current_revision_link', 'related_revisions_link',) | ||
list_display_links = ('id', 'slug',) | ||
list_filter = ('is_template', 'is_localizable', 'category', 'locale') | ||
raw_id_fields = ('parent',) | ||
readonly_fields = ('id', 'current_revision') | ||
search_fields = ('title',) | ||
search_fields = ('title', 'slug', 'html') | ||
|
||
|
||
class RevisionAdmin(admin.ModelAdmin): | ||
fields = ('title', 'slug', 'summary', 'content', 'keywords', 'tags', | ||
'reviewed', 'comment', 'is_approved') | ||
list_display = ('id', 'slug', 'title', 'is_approved', 'created', | ||
'creator',) | ||
list_display_links = ('id', 'slug') | ||
list_filter = ('is_approved', ) | ||
ordering = ('-created',) | ||
search_fields = ('title', 'slug', 'summary', 'content', 'tags') | ||
|
||
|
||
admin.site.register(Document, DocumentAdmin) | ||
admin.site.register(Revision, admin.ModelAdmin) | ||
admin.site.register(Revision, RevisionAdmin) | ||
admin.site.register(EditorToolbar, admin.ModelAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
[ | ||
{ | ||
"pk": 8, | ||
"model": "wiki.document", | ||
"fields": { | ||
"category": 10, | ||
"parent": null, | ||
"title": "Template:test", | ||
"locale": "en-US", | ||
"mindtouch_page_id": null, | ||
"html": "<p>{%= new Date() %}</p>", | ||
"current_revision": 24, | ||
"modified": "2012-03-20 10:09:16", | ||
"is_template": true, | ||
"is_localizable": false, | ||
"slug": "Template:test" | ||
} | ||
}, | ||
{ | ||
"pk": 9, | ||
"model": "wiki.document", | ||
"fields": { | ||
"category": 10, | ||
"parent": null, | ||
"title": "test-template", | ||
"locale": "en-US", | ||
"mindtouch_page_id": null, | ||
"html": "<p>{{ test() }}</p>", | ||
"current_revision": 25, | ||
"modified": "2012-03-20 10:09:38", | ||
"is_template": false, | ||
"is_localizable": false, | ||
"slug": "test-template" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "wiki.reviewtag", | ||
"fields": { | ||
"name": "technical", | ||
"slug": "technical" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "wiki.reviewtag", | ||
"fields": { | ||
"name": "editorial", | ||
"slug": "editorial" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "wiki.reviewtaggedrevision", | ||
"fields": { | ||
"content_object": 24, | ||
"tag": 1 | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "wiki.reviewtaggedrevision", | ||
"fields": { | ||
"content_object": 24, | ||
"tag": 2 | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "wiki.reviewtaggedrevision", | ||
"fields": { | ||
"content_object": 25, | ||
"tag": 1 | ||
} | ||
}, | ||
{ | ||
"pk": 4, | ||
"model": "wiki.reviewtaggedrevision", | ||
"fields": { | ||
"content_object": 25, | ||
"tag": 2 | ||
} | ||
}, | ||
{ | ||
"pk": 24, | ||
"model": "wiki.revision", | ||
"fields": { | ||
"comment": "", | ||
"based_on": null, | ||
"is_approved": true, | ||
"reviewed": null, | ||
"title": "Template:test", | ||
"tags": "", | ||
"summary": "", | ||
"content": "<p>{%= new Date() %}</p>", | ||
"mindtouch_old_id": null, | ||
"is_mindtouch_migration": false, | ||
"created": "2012-03-20 10:09:16", | ||
"significance": null, | ||
"keywords": "", | ||
"reviewer": null, | ||
"document": 8, | ||
"creator": 7, | ||
"slug": "Template:test" | ||
} | ||
}, | ||
{ | ||
"pk": 25, | ||
"model": "wiki.revision", | ||
"fields": { | ||
"comment": "", | ||
"based_on": null, | ||
"is_approved": true, | ||
"reviewed": null, | ||
"title": "test-template", | ||
"tags": "", | ||
"summary": "", | ||
"content": "<p>{{ test() }}</p>", | ||
"mindtouch_old_id": null, | ||
"is_mindtouch_migration": false, | ||
"created": "2012-03-20 10:09:38", | ||
"significance": null, | ||
"keywords": "", | ||
"reviewer": null, | ||
"document": 9, | ||
"creator": 7, | ||
"slug": "test-template" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.