diff --git a/mpicms/base/migrations/0007_remove_wikipage_date.py b/mpicms/base/migrations/0007_remove_wikipage_date.py new file mode 100644 index 0000000..ac592a6 --- /dev/null +++ b/mpicms/base/migrations/0007_remove_wikipage_date.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.1 on 2019-05-28 14:00 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0006_contacts_position'), + ] + + operations = [ + migrations.RemoveField( + model_name='wikipage', + name='date', + ), + ] diff --git a/mpicms/base/models.py b/mpicms/base/models.py index 3e48b62..3138166 100644 --- a/mpicms/base/models.py +++ b/mpicms/base/models.py @@ -1,3 +1,4 @@ +from django.apps import apps from django.db import models from django.utils.translation import gettext as _ @@ -11,7 +12,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.snippets.edit_handlers import SnippetChooserPanel -from mpicms.news.models import NewsPage +from mpicms.news.mixins import NewsMixin Page.show_in_menus_default = True @@ -45,22 +46,17 @@ class Meta: # noqa abstract = True -class HomePage(Page): +class HomePage(NewsMixin, Page): parent_page_types = ['wagtailcore.Page'] # Restrict parent to be root content_panels = Page.content_panels - def get_context(self, request): - context = super().get_context(request) - context['news'] = NewsPage.objects.first() - return context - class Meta: # noqa verbose_name = _("homepage") verbose_name_plural = _("homepages") -class CategoryPage(Page): +class CategoryPage(NewsMixin, Page): body = RichTextField(_("content"), blank=True) side_content = RichTextField( _("sidebar content"), blank=True, @@ -94,7 +90,6 @@ class WikiPage(CategoryMixin, Page): ('image', ImageChooserBlock()), ('url', blocks.URLBlock()) ], blank=True) - date = models.DateField("Post date", auto_now_add=True) search_fields = Page.search_fields + [ index.SearchField('body'), diff --git a/mpicms/news/migrations/0004_newsentry_date.py b/mpicms/news/migrations/0004_newsentry_date.py new file mode 100644 index 0000000..4ed78c2 --- /dev/null +++ b/mpicms/news/migrations/0004_newsentry_date.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.1 on 2019-05-28 14:00 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('news', '0003_auto_20190525_1616'), + ] + + operations = [ + migrations.AddField( + model_name='newsentry', + name='date', + field=models.DateField(auto_now_add=True, default=datetime.date(2019, 5, 28), verbose_name='Post date'), + preserve_default=False, + ), + ] diff --git a/mpicms/news/mixins.py b/mpicms/news/mixins.py new file mode 100644 index 0000000..965aec7 --- /dev/null +++ b/mpicms/news/mixins.py @@ -0,0 +1,13 @@ +from django.apps import apps +from django.db import models + + +class NewsMixin(models.Model): + + @property + def news(self): + news_page = apps.get_model('news', 'NewsPage') + return self.get_children().type(news_page) + + class Meta: # noqa + abstract = True diff --git a/mpicms/news/models.py b/mpicms/news/models.py index 66f5672..1bee895 100644 --- a/mpicms/news/models.py +++ b/mpicms/news/models.py @@ -5,8 +5,10 @@ from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel +from mpicms.base.models import CategoryMixin -class NewsPage(Page): + +class NewsPage(CategoryMixin, Page): content_panels = Page.content_panels parent_page_types = ['base.CategoryPage', 'base.HomePage'] @@ -18,9 +20,10 @@ class Meta: # noqa verbose_name_plural = _("news Blogs") -class NewsEntry(Page): +class NewsEntry(CategoryMixin, Page): preview = models.TextField(_("preview"), blank=True) body = RichTextField(_("content")) + date = models.DateField("Post date", auto_now_add=True) content_panels = Page.content_panels + [ FieldPanel('preview'), diff --git a/mpicms/static/css/custom.css b/mpicms/static/css/custom.css index b7133f8..50e7a30 100644 --- a/mpicms/static/css/custom.css +++ b/mpicms/static/css/custom.css @@ -88,6 +88,7 @@ select, input { padding-left: 2rem; padding-bottom: 2rem; margin-top: 3rem; + align-content: flex-start; } .sidebar ul { @@ -116,6 +117,18 @@ select, input { flex: 0 0 100%; } +.sidebar time { + color: black; + font-size: 85%; + text-align: end; + flex-basis: 100%; +} + +.event-button { + display: flex !important; + flex-wrap: wrap; +} + .contact { padding-bottom: 1em; line-height: 90%; @@ -166,8 +179,9 @@ select, input { .card { margin: 1rem; flex-grow: 1; - flex-basis: auto; + flex-basis: 18rem; width: inherit; + flex-shrink: 0; } .flex-align { @@ -175,12 +189,11 @@ select, input { flex-wrap: nowrap; align-items: center; justify-content: space-between; - width: 100%; } .flex-base { display: flex !important; - flex-wrap: nowrap; + flex-wrap: wrap; align-items: stretch; width: 100%; } @@ -224,4 +237,8 @@ select, input { .fa-chevron-right { padding-left: 0.8rem; +} + +.select:not(.is-multiple):not(.is-loading)::after { + border-color: #006c66; } \ No newline at end of file diff --git a/mpicms/templates/base/category_page.html b/mpicms/templates/base/category_page.html index 2afe92a..6afd8ed 100644 --- a/mpicms/templates/base/category_page.html +++ b/mpicms/templates/base/category_page.html @@ -9,6 +9,9 @@

{{ page.title }}

{{ page.body|richtext }}

+ + {% include 'news/components/news_preview.html' with news=page.news %} + {% for child in page.get_children.live %}
diff --git a/mpicms/templates/base/home_page.html b/mpicms/templates/base/home_page.html index 9d7f608..e7742db 100644 --- a/mpicms/templates/base/home_page.html +++ b/mpicms/templates/base/home_page.html @@ -6,6 +6,6 @@ {% block content %}
- {% include 'news/components/news_preview.html' with news=news %} + {% include 'news/components/news_preview.html' with news=page.news %}
{% endblock %} \ No newline at end of file diff --git a/mpicms/templates/base/page.html b/mpicms/templates/base/page.html index 7516a50..a5780fa 100644 --- a/mpicms/templates/base/page.html +++ b/mpicms/templates/base/page.html @@ -3,7 +3,7 @@ {% block content %}
-
+
{% include 'base/components/breadcrumb.html' %} {% block page_content %} diff --git a/mpicms/templates/menus/side.html b/mpicms/templates/menus/side.html index a41df21..8a08a0d 100644 --- a/mpicms/templates/menus/side.html +++ b/mpicms/templates/menus/side.html @@ -3,50 +3,55 @@ {% with page.category as category %} -{% with category.get_children.live.in_menu as children %} - -{% if children %} - - - - -{% endif %} -{% endwith %} - -
- {{ category.specific.side_content|richtext }} -
- - -{% with category.specific.contacts.all as contacts %} - {% if contacts %} -
-

{% trans 'Contact' %}

-
    - {% for contact in contacts %} -
  • -
      -
    • {{ contact.person.first_name }} {{ contact.person.last_name }}
    • -
    • {{ contact.position }}
    • -
    • {{ contact.person.email }}
    • -
    • {{ contact.person.phone }}
    • -
    -
  • + + {% with category.get_children.live.in_menu as children %} + + {% if children %} + +
+ + {% endif %} -{% endwith %} + {% endwith %} + +
+ {% include 'news/components/news_list.html' with news=category.specific.news %} +
+ +
+ {{ category.specific.side_content|richtext }} +
+ + + {% with category.specific.contacts.all as contacts %} + {% if contacts %} +
+

{% trans 'Contact' %}

+
    + {% for contact in contacts %} +
  • +
      +
    • {{ contact.person.first_name }} {{ contact.person.last_name }}
    • +
    • {{ contact.position }}
    • +
    • {{ contact.person.email }}
    • +
    • {{ contact.person.phone }}
    • +
    +
  • + {% endfor %} +
+
+ {% endif %} + {% endwith %} {% endwith %} \ No newline at end of file diff --git a/mpicms/templates/news/components/news_list.html b/mpicms/templates/news/components/news_list.html new file mode 100644 index 0000000..ce6dfc2 --- /dev/null +++ b/mpicms/templates/news/components/news_list.html @@ -0,0 +1,20 @@ +{% load i18n %} +{% load wagtailcore_tags %} + +{% for news_page in news %} + {% with news_page.get_children.live as news_entries %} + {% if news_entries %} +

{{ news_page.title }}

+ + {% trans 'See all' %} + {% endif %} + {% endwith %} +{% endfor %} \ No newline at end of file diff --git a/mpicms/templates/news/components/news_preview.html b/mpicms/templates/news/components/news_preview.html index 8b67c34..4359043 100644 --- a/mpicms/templates/news/components/news_preview.html +++ b/mpicms/templates/news/components/news_preview.html @@ -2,21 +2,27 @@ {% load wagtailcore_tags %} -

News

-
- {% for child in news.get_children.live|slice:3 %} -
-
- {{ child.title }} - -
- {{ child.specific.preview }} +{% for news_page in news %} + {% with news_page.get_children.live as news_entries %} + {% if news_entries %} +

{{ news_page.title }}

+
+ {% for child in news_entries|slice:3 %} +
+
+ {{ child.title }} + +
+ {{ child.specific.preview }} +
+
+
-
- + {% endfor %}
- {% endfor %} -
- \ No newline at end of file + + {% endif %} + {% endwith %} +{% endfor %} \ No newline at end of file diff --git a/mpicms/templates/news/news_entry.html b/mpicms/templates/news/news_entry.html index db2ea3b..7243b11 100644 --- a/mpicms/templates/news/news_entry.html +++ b/mpicms/templates/news/news_entry.html @@ -1,11 +1,11 @@ -{% extends 'base.html' %} +{% extends 'base/page.html' %} {% load wagtailcore_tags %} -{% block content %} - {% include 'base/components/breadcrumb.html' %} +{% block page_content %}

{{ page.title }}

+ {{ page.date }}

{{ page.body|richtext }} diff --git a/mpicms/templates/news/news_page.html b/mpicms/templates/news/news_page.html index 7335a63..b5c6955 100644 --- a/mpicms/templates/news/news_page.html +++ b/mpicms/templates/news/news_page.html @@ -1,8 +1,8 @@ -{% extends 'base.html' %} +{% extends 'base/page.html' %} {% load wagtailcore_tags %} -{% block content %} +{% block page_content %}

{{ page.title }}

@@ -10,7 +10,7 @@

{{ page.title }}

- +

{{ child.title }}

{{ child.specific.preview }}