diff --git a/colegend/configuration/settings/base.py b/colegend/configuration/settings/base.py index cb8d818a..245c405c 100644 --- a/colegend/configuration/settings/base.py +++ b/colegend/configuration/settings/base.py @@ -255,6 +255,7 @@ 'markitup', # usability 'keyboard', + 'easy_thumbnails', ) EXTRA_APPS = ( 'django_extensions', diff --git a/colegend/configuration/urls.py b/colegend/configuration/urls.py index 3750abe2..ddf4113e 100644 --- a/colegend/configuration/urls.py +++ b/colegend/configuration/urls.py @@ -53,7 +53,7 @@ # django-autocomplet-light url(r'^autocomplete/', include('autocomplete_light.urls')), - # robots.txt file for crawlers + # Added robots.txt file for crawlers (google/etc) (r'^robots.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: /", mimetype="text/plain")), ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/colegend/features/admin.py b/colegend/features/admin.py index dcc45d47..c4466bc7 100644 --- a/colegend/features/admin.py +++ b/colegend/features/admin.py @@ -1,4 +1,7 @@ from django.contrib import admin +from django.conf import settings +from easy_thumbnails.fields import ThumbnailerField +from easy_thumbnails.widgets import ImageClearableFileInput from features.models import Feature __author__ = 'eraldo' @@ -8,4 +11,17 @@ class FeatureAdmin(admin.ModelAdmin): list_display = ['name', 'date_published', 'role'] list_filter = ['role'] search_fields = ['name'] + + # formfield_overrides = { + # ThumbnailerField: {'widget': ImageClearableFileInput}, + # } + + # def thumbnail(self, value): + # image = value.image + # if image: + # return ''.format(settings.MEDIA_URL, image) + # else: + # return '' + # thumbnail.allow_tags = True + admin.site.register(Feature, FeatureAdmin) diff --git a/colegend/features/migrations/0003_feature_image.py b/colegend/features/migrations/0003_feature_image.py new file mode 100644 index 00000000..64e56b96 --- /dev/null +++ b/colegend/features/migrations/0003_feature_image.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import easy_thumbnails.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('features', '0002_feature_role'), + ] + + operations = [ + migrations.AddField( + model_name='feature', + name='image', + field=easy_thumbnails.fields.ThumbnailerImageField(blank=True, upload_to='features', default=''), + preserve_default=False, + ), + ] diff --git a/colegend/features/models.py b/colegend/features/models.py index ea5c4629..94b73735 100644 --- a/colegend/features/models.py +++ b/colegend/features/models.py @@ -1,5 +1,6 @@ from django.db import models from django.utils import timezone +from easy_thumbnails.fields import ThumbnailerImageField __author__ = 'eraldo' @@ -25,6 +26,8 @@ class Feature(models.Model): ) role = models.CharField(verbose_name="System Role", max_length=2, choices=ROLE_CHOICES, default=OPERATOR) + image = ThumbnailerImageField(upload_to='features', blank=True, resize_source=dict(size=(40, 40))) + objects = FeatureManager() class Meta: diff --git a/colegend/features/templates/features/_feature.html b/colegend/features/templates/features/_feature.html index 127f7b07..adfdfb36 100644 --- a/colegend/features/templates/features/_feature.html +++ b/colegend/features/templates/features/_feature.html @@ -1,4 +1,9 @@
+ {% if feature.image %} +
+ Feature Image +
+ {% endif %} {{ feature }}
— {{ feature.date_published }}
{{ feature.get_role_display }} diff --git a/requirements/base.txt b/requirements/base.txt index d28db56c..e371354d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -18,6 +18,7 @@ markdown-checklist==0.4.0 # Images Pillow==2.5.3 +easy-thumbnails==2.2 # For user registration, either via email or social # Well-built with regular release cycles!