def save_content(request): """ content save handler Returns a HttpResponse whose content is JSON to tell if the operation succeeded. """ result = {"result": False} if request.method == "POST": if request.POST["content"]: page_items = loads(request.POST["content"]) for content_key, item in page_items.iteritems(): # TODO: move to model/form cleaning content = item["value"] if settings.FEINCMS_TIDY_HTML: content, errors, warnings = get_object(settings.FEINCMS_TIDY_FUNCTION)(content) matches = re.search("^page-page-richtextcontent-(\d+)-(\d+)$", content_key) if matches: page_id, content_id = matches.group(1), matches.group(2) # TODO: replace with more flexible solution (not tied to the RichTextContent model), as done in _frontend_editing_view RTC = Page.content_type_for(RichTextContent) rtc = RTC.objects.get(id=content_id, parent__id=page_id) rtc.text = content rtc.save() # TODO: this should be done differently; being able to handle every page-item separartly (see formsets) result = {"result": True} return HttpResponse(dumps(result), content_type="application/json")
from __future__ import absolute_import, unicode_literals from django.core.files import File as DjangoFile from django.core.management.base import NoArgsCommand from django.contrib.auth.models import User from feincms.contents import FilerFileContent, FilerImageContent from feincms.module.medialibrary.contents import MediaFileContent from feincms.module.medialibrary.models import MediaFile from feincms.module.page.models import Page from filer.models import File, Image PageMediaFileContent = Page.content_type_for(MediaFileContent) PageFilerFileContent = Page.content_type_for(FilerFileContent) PageFilerImageContent = Page.content_type_for(FilerImageContent) assert all( (PageMediaFileContent, PageFilerFileContent, PageFilerImageContent) ), "Not all required models available" class Command(NoArgsCommand): help = "Migrate the medialibrary and contents to django-filer" def handle_noargs(self, **options): user = User.objects.order_by("pk")[0] count = MediaFile.objects.count()
from __future__ import absolute_import, unicode_literals from django.core.files import File as DjangoFile from django.core.management.base import NoArgsCommand from django.contrib.auth.models import User from feincms.contents import FilerFileContent, FilerImageContent from feincms.module.medialibrary.contents import MediaFileContent from feincms.module.medialibrary.models import MediaFile from feincms.module.page.models import Page from filer.models import File, Image PageMediaFileContent = Page.content_type_for(MediaFileContent) PageFilerFileContent = Page.content_type_for(FilerFileContent) PageFilerImageContent = Page.content_type_for(FilerImageContent) assert all((PageMediaFileContent, PageFilerFileContent, PageFilerImageContent)), "Not all required models available" class Command(NoArgsCommand): help = "Migrate the medialibrary and contents to django-filer" def handle_noargs(self, **options): user = User.objects.order_by("pk")[0] count = MediaFile.objects.count() for i, mediafile in enumerate(MediaFile.objects.order_by("pk")): model = Image if mediafile.type == "image" else File
Page.create_content_type(RssFeedContent) Page.create_content_type(MediaFileContent, TYPE_CHOICES=(('default', _('default')), )) Page.create_content_type(ExternallyLinkedMediaFileContent) Page.create_content_type(MailchimpSignup) Page.create_content_type(ApplicationContent, APPLICATIONS=( ('livinglots_lots.map_urls', _('Lots map')), ('extraadmin.cms_urls', _('Extra admin functions')), ('contact_form', _('Contact form'), { 'urls': 'contact.form_urls', }), ('pathways.urls', _('Pathways')), )) Pathway.register_extensions('feincms.module.extensions.translations', ) Pathway.register_regions(('main', _('Main content area')), ) Pathway.create_content_type(RichTextContent) Pathway.create_content_type(MediaFileContent, TYPE_CHOICES=(('default', _('default')), )) watson.register(Page, fields=['title']) watson.register(Page.content_type_for(RichTextContent))