Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'glamkit-events' of github.com:ic-labs/django-icekit int…
Browse files Browse the repository at this point in the history
…o glamkit-events

# Conflicts:
#	icekit/content_collections/tests.py
#	icekit/page_types/article/__init__.py
#	icekit/page_types/article/apps.py
#	project_template/icekit_settings.py
  • Loading branch information
Greg Turner committed Oct 17, 2016
2 parents b1cf4c3 + 3e6b51c commit e032cae
Show file tree
Hide file tree
Showing 46 changed files with 221 additions and 278 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get update \
python \
python-dev \
pv \
vim-tiny \
&& rm -rf /var/lib/apt/lists/*

RUN echo 'deb https://dl.bintray.com/sobolevn/deb git-secret main' | tee -a /etc/apt/sources.list
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* New `icekit.page_types.author` app which models a content author and a
listing page, based on the `content_collections` pattern.

* New `icekit.page_types.article` app which is a concrete implementation of
the content collections pattern.

Breaking changes:

Expand Down
6 changes: 1 addition & 5 deletions icekit/admin_mixins.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from fluent_contents.admin import PlaceholderEditorAdmin
from fluent_contents.models import PlaceholderData

from icekit.utils.admin.mixins import \
PolymorphicChildModelAdminGetParentAdminFix


class FluentLayoutsMixin(PlaceholderEditorAdmin,
PolymorphicChildModelAdminGetParentAdminFix):
class FluentLayoutsMixin(PlaceholderEditorAdmin):
"""
Mixin class for models that have a ``layout`` field and fluent content.
"""
Expand Down
1 change: 1 addition & 0 deletions icekit/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ else
for cmd in elasticsearch md5sum nginx npm psql python pv redis-server; do
hash $cmd 2>/dev/null || {
>&2 echo "ERROR: Missing program: $cmd"
>&2 echo 'See: https://github.com/ic-labs/django-icekit/blob/develop/docs/intro/manual-setup.md'
exit 1
}
done
Expand Down
11 changes: 7 additions & 4 deletions icekit/content_collections/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.contrib.auth import get_user_model
from django.http.request import HttpRequest
from django_webtest import WebTest

from icekit.tests.models import Article, ArticleListing
from icekit.models import Layout

User = get_user_model()


class TestContentCollections(WebTest):
"""
Test Article publishing
Expand Down Expand Up @@ -55,15 +57,16 @@ def setUp(self):
)

def test_model(self):
req = HttpRequest()
self.article.publish()
self.article_2.publish()
# test the listing contains the published article
self.assertTrue(self.article.get_published() in self.listing.get_items_to_list())
self.assertTrue(self.article.get_published() in self.listing.get_items_to_list(req))
# ...not the draft one
self.assertTrue(self.article not in self.listing.get_items_to_list())
self.assertTrue(self.article not in self.listing.get_items_to_list(req))
# ...not an article that isn't associated with the listing
self.assertTrue(self.article_2 not in self.listing.get_items_to_list())
self.assertTrue(self.article_2.get_published() not in self.listing.get_items_to_list())
self.assertTrue(self.article_2 not in self.listing.get_items_to_list(req))
self.assertTrue(self.article_2.get_published() not in self.listing.get_items_to_list(req))
self.article.unpublish()
self.article_2.unpublish()

Expand Down
11 changes: 11 additions & 0 deletions icekit/dashboard/templatetags/dashboard_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ class AppObject(object):
pass


def models_key(model):
"""
Return verbose name (plural), verbose name, or model name, to use as a
comparison key when sorting.
"""
return model.get(
'verbose_name', model.get(
'verbose_name_plural', model['object_name']))


@register.filter
def filter_featured_apps(admin_apps, request):
"""
Expand Down Expand Up @@ -100,6 +110,7 @@ def filter_featured_apps(admin_apps, request):

# Only add the panel if more than one model listed.
if len(new_app.models) > 0:
new_app.models.sort(key=models_key)
featured_apps.append(new_app)

return featured_apps
Expand Down
1 change: 0 additions & 1 deletion icekit/page_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__author__ = 'sjdines'
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from django.contrib import admin
from icekit.publishing.admin import PublishableFluentContentsAdmin

from .models import Article


class ArticleAdmin(PublishableFluentContentsAdmin):
prepopulated_fields = {"slug": ("title",)}
list_filter = PublishableFluentContentsAdmin.list_filter + ('parent', )


admin.site.register(Article, ArticleAdmin)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.apps import AppConfig


class AppConfig(AppConfig):
name = '.'.join(__name__.split('.')[:-1])
label = "glamkit_articles"
verbose_name = "Articles"
label = 'icekit_article'
verbose_name = 'Articles'
59 changes: 59 additions & 0 deletions icekit/page_types/article/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.utils.timezone
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('fluent_pages', '0001_initial'),
('icekit', '0006_auto_20150911_0744'),
]

operations = [
migrations.CreateModel(
name='Article',
fields=[
('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)),
('publishing_is_draft', models.BooleanField(db_index=True, editable=False, default=True)),
('publishing_modified_at', models.DateTimeField(editable=False, default=django.utils.timezone.now)),
('publishing_published_at', models.DateTimeField(null=True, editable=False)),
('title', models.CharField(max_length=255)),
('slug', models.SlugField(max_length=255)),
('layout', models.ForeignKey(related_name='icekit_article_article_related', blank=True, null=True, to='icekit.Layout')),
],
),
migrations.CreateModel(
name='ArticleCategoryPage',
fields=[
('urlnode_ptr', models.OneToOneField(serialize=False, primary_key=True, auto_created=True, parent_link=True, to='fluent_pages.UrlNode')),
('publishing_is_draft', models.BooleanField(db_index=True, editable=False, default=True)),
('publishing_modified_at', models.DateTimeField(editable=False, default=django.utils.timezone.now)),
('publishing_published_at', models.DateTimeField(null=True, editable=False)),
('layout', models.ForeignKey(related_name='icekit_article_articlecategorypage_related', blank=True, null=True, to='icekit.Layout')),
('publishing_linked', models.OneToOneField(null=True, related_name='publishing_draft', on_delete=django.db.models.deletion.SET_NULL, editable=False, to='icekit_article.ArticleCategoryPage')),
],
options={
'db_table': 'pagetype_icekit_article_articlecategorypage',
'abstract': False,
},
bases=('fluent_pages.htmlpage', models.Model),
),
migrations.AddField(
model_name='article',
name='parent',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='icekit_article.ArticleCategoryPage'),
),
migrations.AddField(
model_name='article',
name='publishing_linked',
field=models.OneToOneField(null=True, related_name='publishing_draft', on_delete=django.db.models.deletion.SET_NULL, editable=False, to='icekit_article.Article'),
),
migrations.AlterUniqueTogether(
name='article',
unique_together=set([('slug', 'parent', 'publishing_linked')]),
),
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from icekit.content_collections.abstract_models import AbstractCollectedContent, \
AbstractListingPage, TitleSlugMixin
from icekit.publishing.models import PublishableFluentContents
from django.db import models
from icekit.content_collections.abstract_models import \
AbstractCollectedContent, AbstractListingPage, TitleSlugMixin
from icekit.publishing.models import PublishableFluentContents


class ArticleCategoryPage(AbstractListingPage):
def get_items_to_list(self, request):
Expand All @@ -13,12 +14,13 @@ def get_items_to_mount(self, request):
return Article.objects.visible().filter(parent_id=unpublished_pk)


class Article(PublishableFluentContents, AbstractCollectedContent, TitleSlugMixin):
class Article(
PublishableFluentContents, AbstractCollectedContent, TitleSlugMixin):
parent = models.ForeignKey(
"ArticleCategoryPage",
'ArticleCategoryPage',
limit_choices_to={'publishing_is_draft': True},
on_delete=models.PROTECT,
)

class Meta:
unique_together = (('parent', 'slug', 'publishing_linked'),)
unique_together = (('slug', 'parent', 'publishing_linked'), )
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fluent_pages.extensions import page_type_pool

from icekit.content_collections.page_type_plugins import ListingPagePlugin

from .models import ArticleCategoryPage


Expand Down
4 changes: 2 additions & 2 deletions icekit/page_types/layout_page/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class UnpublishableLayoutPageAdmin(FluentLayoutsMixin, FluentContentsPageAdmin):
raw_id_fields = ('parent',)


class LayoutPageAdmin(FluentLayoutsMixin, FluentContentsPageAdmin,
PublishingAdmin):
class LayoutPageAdmin(
FluentLayoutsMixin, FluentContentsPageAdmin, PublishingAdmin):
raw_id_fields = ('parent',)
1 change: 0 additions & 1 deletion icekit/page_types/search_page/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__author__ = 'sjdines'
default_app_config = 'icekit.page_types.search_page.apps.SearchPageConfig'
1 change: 0 additions & 1 deletion icekit/pages_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
default_app_config = '%s.apps.PagesAPIConfig' % __name__
__author__ = 'sjdines'
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3 class="carousel-title">{{ gallery.title }}</h3>
title="{% if item.title %}{{ item.title }}{% endif %}{% if item.title and item.caption %}<br>{% endif %}{% if item.caption %}{{ item.caption }}{% endif %}"
{% endif %}
>
<img src="{% thumbnail item.image.image 200x0 upscale %}" alt="{{ item.image.alt_text }}" />
<img src="{% thumbnail item.image.image "image_gallery_thumb" %}" alt="{{ item.image.alt_text }}" />
</a>
</div>
{% if forloop.last or forloop.counter|divisibleby:4 %}
Expand Down
1 change: 0 additions & 1 deletion icekit/plugins/map_with_text/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__author__ = 'sjdines'
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h3 class="carousel-title">{{ slideshow.title }}</h3>
<div class="carousel-inner" role="listbox">
{% for item in slideshow.content.get_content_items %}
<div class="item {% if forloop.first %}active{% endif %}">
<img src="{% thumbnail item.image.image 1200x0 upscale %}" alt="{{ item.image.alt_text }}">
<img src="{% thumbnail item.image.image "slideshow_slide" upscale %}" alt="{{ item.image.alt_text }}">
{% if item.image.caption %}
<div class="carousel-caption">
{{ item.image.caption }}
Expand Down
6 changes: 3 additions & 3 deletions icekit/project/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
try:
try:
# Local (override) project settings.
from icekit_settings_local import *
from project_settings_local import *
except ImportError:
# Project settings.
from icekit_settings import *
from project_settings import *
except ImportError:
# ICEkit settings.
from .calculated import *
from .icekit import *
46 changes: 33 additions & 13 deletions icekit/project/settings/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
variable, and override settings in `local.py`.
"""

from __future__ import absolute_import

import hashlib
import multiprocessing
import os
Expand All @@ -28,14 +30,12 @@
# other projects running on the same system.
SETTINGS_MODULE_HASH = hashlib.md5(__file__ + BASE_SETTINGS_MODULE).hexdigest()

SITE_NAME = os.environ.get(
'SITE_NAME', os.environ.get('ICEKIT_PROJECT_NAME', 'ICEkit'))
SITE_SLUG = slugify(unicode(SITE_NAME))
PROJECT_NAME = os.environ.get('ICEKIT_PROJECT_NAME', 'ICEkit')
PROJECT_SLUG = re.sub(r'[^0-9A-Za-z]+', '-', slugify(unicode(PROJECT_NAME)))

SITE_DOMAIN = os.environ.get('SITE_DOMAIN', '%s.lvh.me' % PROJECT_SLUG)
SITE_NAME = os.environ.get('SITE_NAME', PROJECT_NAME)

SITE_DOMAIN = re.sub(
r'[^-.0-9A-Za-z]',
'-',
os.environ.get('SITE_DOMAIN', '%s.lvh.me' % SITE_SLUG))
SITE_PORT = 8000

# FILE SYSTEM PATHS ###########################################################
Expand Down Expand Up @@ -87,7 +87,7 @@
'default': {
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('PGDATABASE', SITE_SLUG),
'NAME': os.environ.get('PGDATABASE', PROJECT_SLUG),
'HOST': os.environ.get('PGHOST'),
'PORT': os.environ.get('PGPORT'),
'USER': os.environ.get('PGUSER'),
Expand Down Expand Up @@ -153,7 +153,7 @@
'level': 'DEBUG',
'class': 'cloghandler.ConcurrentRotatingFileHandler',
'filename': os.path.join(
VAR_DIR, 'logs', '%s.log' % SITE_SLUG),
VAR_DIR, 'logs', '%s.log' % PROJECT_SLUG),
'maxBytes': 10 * 1024 * 1024, # 10 MiB
'backupCount': 10,
'formatter': 'logfile',
Expand Down Expand Up @@ -341,7 +341,7 @@

BROKER_URL = CELERY_RESULT_BACKEND = 'redis://%s/0' % REDIS_ADDRESS
CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml'] # 'pickle'
CELERY_DEFAULT_QUEUE = SITE_SLUG
CELERY_DEFAULT_QUEUE = PROJECT_SLUG

CELERY_QUEUES = (
Queue(
Expand Down Expand Up @@ -411,11 +411,11 @@
INSTALLED_APPS += ('easy_thumbnails', )

# Scoped aliases allows us to pre-generate all the necessary thumbnails for a
# given model/field, without generating additional unecessary thumbnails. This
# given model/field, without generating additional unnecessary thumbnails. This
# is essential when using a remote storage backend.
THUMBNAIL_ALIASES = {
# 'app[.model][.field]': {
# 'name-WxH': { 'size': (W, H), },
# 'name': { 'size': (W, H), },
# },
'': {
'icekit_authors_portrait_large': {
Expand All @@ -426,6 +426,12 @@
},
'content_image': {
'size': (1138, 0), # maximum width of a bootstrap content column
},
'slideshow_slide': {
'size': (1138, 0),
},
'image_gallery_thumb': {
'size': (200, 0),
}
}
}
Expand Down Expand Up @@ -547,6 +553,9 @@
'verbose_name': 'Content',
'icon_html': '<i class="content-type-icon fa fa-files-o"></i>',
'models': {
'icekit_article.Article': {
'verbose_name_plural': 'Articles',
},
'fluent_pages.Page': {
'verbose_name_plural': 'Pages',
},
Expand Down Expand Up @@ -597,6 +606,7 @@
'icekit.content_collections',
'notifications',

'icekit.page_types.article',
'icekit.page_types.author',
'icekit.page_types.layout_page',
'icekit.page_types.search_page',
Expand All @@ -621,6 +631,16 @@

MIDDLEWARE_CLASSES += ('icekit.publishing.middleware.PublishingMiddleware', )

# ICEKIT PRESS RELEASES #######################################################

FEATURED_APPS[0]['models'].update({
'icekit_press_releases.PressRelease': {
'verbose_name_plural': 'Press releases',
},
})

INSTALLED_APPS += ('press_releases', )

# MASTER PASSWORD #############################################################

AUTHENTICATION_BACKENDS += ('master_password.auth.ModelBackend', )
Expand Down Expand Up @@ -701,7 +721,7 @@
AWS_SECRET_ACCESS_KEY = os.environ.get('MEDIA_AWS_SECRET_ACCESS_KEY')

AWS_STORAGE_BUCKET_NAME = os.environ.get(
'MEDIA_AWS_STORAGE_BUCKET_NAME', '%s-stg' % SITE_SLUG)
'MEDIA_AWS_STORAGE_BUCKET_NAME', '%s-stg' % PROJECT_SLUG)

ENABLE_S3_MEDIA = False
INSTALLED_APPS += ('storages', )
Expand Down

0 comments on commit e032cae

Please sign in to comment.