]> git.parisson.com Git - mezzo.git/commitdiff
Brief : creating content
authorEmilie <zawadzki@ircam.fr>
Thu, 7 Jul 2016 14:58:39 +0000 (16:58 +0200)
committerEmilie <zawadzki@ircam.fr>
Thu, 7 Jul 2016 14:58:39 +0000 (16:58 +0200)
app/local_settings.py
app/organization/magazine/admin.py
app/organization/magazine/migrations/0003_brief.py [new file with mode: 0644]
app/organization/magazine/migrations/0004_auto_20160707_1544.py [new file with mode: 0644]
app/organization/magazine/models.py
app/organization/magazine/translation.py
app/organization/magazine/urls.py [new file with mode: 0644]
app/settings.py
requirements-dev.txt
requirements.txt

index c07e0f7d685e35a0d94928109d48f67015cc4d0d..6417ded7360a3b31898d8cdab2cc3a17f44dca1d 100644 (file)
@@ -145,3 +145,9 @@ DEBUG_TOOLBAR_PANELS = [
 
 # slug
 BLOG_SLUG = 'article'
+
+
+AJAX_LOOKUP_CHANNELS = {
+  'article': {'model': 'organization.magazine.article', 'search_field': 'title'},
+  'basepage': {'model': 'organization.core.basepage', 'search_field': 'title'},
+}
index 8c38f3f3dad51e4585f3984282c2a4bec5349c1e..1554530c9239c511a59ff9782a5423efdb5266bc 100644 (file)
@@ -1,3 +1,23 @@
 from django.contrib import admin
+from django import forms
+from copy import deepcopy
+from mezzanine.core.admin import DisplayableAdmin
+from organization.magazine.models import Brief
+from ajax_select import make_ajax_form
+from ajax_select.admin import AjaxSelectAdmin
+from ajax_select.fields import AutoCompleteSelectField
+from organization.magazine.models import Brief
 
-# Register your models here.
+
+class BriefAdmin(AjaxSelectAdmin):
+
+    model = Brief
+
+class BriefAdminDisplayable(DisplayableAdmin):
+
+    #make_ajax_form(Label, {'ville': 'ville'})
+    #id_local_content = AutoCompleteSelectField('local_content', label="local_content")
+    form = make_ajax_form(Brief, {'local_content': 'article'})
+    fieldsets = deepcopy(BriefAdmin.fieldsets)
+
+admin.site.register(Brief, BriefAdminDisplayable)
diff --git a/app/organization/magazine/migrations/0003_brief.py b/app/organization/magazine/migrations/0003_brief.py
new file mode 100644 (file)
index 0000000..f918c82
--- /dev/null
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-07 11:23
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import mezzanine.core.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('sites', '0002_alter_domain_unique'),
+        ('organization magazine', '0002_article'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Brief',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('keywords_string', models.CharField(blank=True, editable=False, max_length=500)),
+                ('title', models.CharField(max_length=500, verbose_name='Title')),
+                ('slug', models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL')),
+                ('_meta_title', models.CharField(blank=True, help_text='Optional title to be used in the HTML title tag. If left blank, the main title field will be used.', max_length=500, null=True, verbose_name='Title')),
+                ('description', models.TextField(blank=True, verbose_name='Description')),
+                ('gen_description', models.BooleanField(default=True, help_text='If checked, the description will be automatically generated from content. Uncheck if you want to manually set a custom description.', verbose_name='Generate description')),
+                ('created', models.DateTimeField(editable=False, null=True)),
+                ('updated', models.DateTimeField(editable=False, null=True)),
+                ('status', models.IntegerField(choices=[(1, 'Draft'), (2, 'Published')], default=2, help_text='With Draft chosen, will only be shown for admin users on the site.', verbose_name='Status')),
+                ('publish_date', models.DateTimeField(blank=True, db_index=True, help_text="With Published chosen, won't be shown until this time", null=True, verbose_name='Published from')),
+                ('expiry_date', models.DateTimeField(blank=True, help_text="With Published chosen, won't be shown after this time", null=True, verbose_name='Expires on')),
+                ('short_url', models.URLField(blank=True, null=True)),
+                ('in_sitemap', models.BooleanField(default=True, verbose_name='Show in sitemap')),
+                ('content', mezzanine.core.fields.RichTextField(verbose_name='Content')),
+                ('text_button', models.CharField(blank=True, max_length=150, verbose_name='text button')),
+                ('text_button_fr', models.CharField(blank=True, max_length=150, null=True, verbose_name='text button')),
+                ('text_button_en', models.CharField(blank=True, max_length=150, null=True, verbose_name='text button')),
+                ('site', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site')),
+            ],
+            options={
+                'verbose_name': 'brief',
+            },
+        ),
+    ]
diff --git a/app/organization/magazine/migrations/0004_auto_20160707_1544.py b/app/organization/magazine/migrations/0004_auto_20160707_1544.py
new file mode 100644 (file)
index 0000000..c12f98c
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-07 13:44
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('organization magazine', '0003_brief'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='brief',
+            name='local_content',
+            field=models.CharField(blank=True, max_length=1000, verbose_name='local content'),
+        ),
+        migrations.AddField(
+            model_name='brief',
+            name='local_content_en',
+            field=models.CharField(blank=True, max_length=1000, null=True, verbose_name='local content'),
+        ),
+        migrations.AddField(
+            model_name='brief',
+            name='local_content_fr',
+            field=models.CharField(blank=True, max_length=1000, null=True, verbose_name='local content'),
+        ),
+    ]
index 53dd878a8167b7d9bcd2911cdcb99be2ff8a8789..17e41b90ed0ad93a19d4af64d7396b4a9470dcca 100644 (file)
@@ -2,9 +2,11 @@ from __future__ import unicode_literals
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 from django.core.urlresolvers import reverse, reverse_lazy
+from mezzanine.core.models import RichText, Displayable, Slugged
 from mezzanine.blog.models import BlogPost
 from organization.core.models import Named
 
+
 class Article(BlogPost):
 
     sub_title = models.CharField(_('sub title'), blank=True, max_length=1000)
@@ -12,6 +14,15 @@ class Article(BlogPost):
     class Meta:
         verbose_name = _('article')
 
+class Brief(Displayable, RichText):
+
+    text_button = models.CharField(blank=True, max_length=150, null=False, verbose_name='text button')
+    local_content = models.CharField(blank=True, max_length=1000, null=False, verbose_name='local content')
+
+    class Meta:
+        verbose_name = _('brief')
+
+
 class Category(Named):
     """(Category description)"""
 
index db66e9b1fd551ad11e73b1946ba208192155c787..17498296b4d7423863d92d006ab0bebb0b0e298d 100644 (file)
@@ -4,10 +4,16 @@ from modeltranslation.translator import TranslationOptions
 from mezzanine.core.translation import (TranslatedSlugged,
                                         TranslatedDisplayable,
                                         TranslatedRichText)
-from organization.magazine.models import Article
+from organization.magazine.models import Article, Brief
 
 @register(Article)
 #class ArticleTranslationOptions(TranslatedDisplayable, TranslatedRichText):
 class ArticleTranslationOptions(TranslationOptions):
 
     fields = ('sub_title',)
+
+
+@register(Brief)
+class AudioTranslationOptions(TranslationOptions):
+
+    fields = ('text_button', 'local_content')
diff --git a/app/organization/magazine/urls.py b/app/organization/magazine/urls.py
new file mode 100644 (file)
index 0000000..d3336dd
--- /dev/null
@@ -0,0 +1,15 @@
+from __future__ import unicode_literals
+
+from django.conf.urls import patterns, include, url
+from django.conf.urls.i18n import i18n_patterns
+from django.contrib import admin
+
+from django.conf.urls import *
+from django.contribimport admin
+from ajax_select import urls as ajax_select_urls
+
+admin.autodiscover()
+
+urlpatterns = [
+    urls (r'^admin/lookups/', include(ajax_select_urls)), (r'^admin/', include(admin.site.urls)),
+]
index eaa2f40d1cf3e2d0dca910d69408c1b7d2dc6b2c..3702ee2aa43bba0a941db5ec37a4b99155f0451a 100644 (file)
@@ -223,6 +223,7 @@ INSTALLED_APPS = [
     'djangobower',
     "meta",
     "mezzanine_agenda",
+    "ajax_select",
     "organization.core",
     "organization.structure",
     "organization.festival",
index 327f10f473a6fce6e7ef4f40d8866baa7d611a43..381037a59353272dc59cf0bc16d7e16705773551 100644 (file)
@@ -1,5 +1,6 @@
 -e git+https://github.com/yomguy/mezzanine-agenda.git#egg=mezzanine-agenda-0.2.2
 -e git+https://github.com/stephenmcd/mezzanine.git#egg=mezzanine-4.1-dev
+-e git+https://github.com/stephenmcd/grappelli-safe#egg=grappelli-safe-0.4.2
 #https://forge.ircam.fr/p/django-eve/source/download/dev/
 #
 #
index 080247cda17ed84719479dcaa798c5a47a9d60c6..a7f0e9e4ae6f9c7af239315d504f0cb5d2b11e5d 100644 (file)
@@ -12,3 +12,4 @@ django-bower
 django-debug-toolbar
 django-extensions
 django-countries
+django-ajax-selects