diff --git a/fmartingrcom/apps/_core/views.py b/fmartingrcom/apps/_core/views.py index 4bf95d4..1afd1ce 100644 --- a/fmartingrcom/apps/_core/views.py +++ b/fmartingrcom/apps/_core/views.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from django.views.generic import View as DjangoView @@ -6,5 +7,6 @@ class View(DjangoView): data = {} def __init__(self, *args, **kwargs): + self.data = {} self.data['section'] = self.section return super(View, self).__init__(*args, **kwargs) diff --git a/fmartingrcom/apps/blog/admin.py b/fmartingrcom/apps/blog/admin.py index 5d6139b..76b08ff 100644 --- a/fmartingrcom/apps/blog/admin.py +++ b/fmartingrcom/apps/blog/admin.py @@ -1,19 +1,35 @@ from django.contrib import admin from .models import Entry, Tag +from ckeditor.widgets import CKEditorWidget from django.utils.translation import ugettext as _ -import reversion +from reversion.admin import VersionAdmin +from django import forms + + +class EntryAdminForm(forms.ModelForm): + content = forms.CharField(widget=CKEditorWidget()) + + class Meta: + model = Entry + fields = ('title', 'slug', 'draft', 'date', 'tags', 'content') + # # ENTRY # -class EntryAdmin(reversion.VersionAdmin): +class EntryAdmin(VersionAdmin): + form = EntryAdminForm + list_display = ('title', 'date', 'status', 'tag_list', 'preview_link') list_display_links = ('title', ) - list_filter = ('date', 'draft', ) search_fields = ('title', 'content', ) + filter_horizontal = ('tags',) + + actions_on_top = True + prepopulated_fields = {"slug": ("title",)} suit_form_tabs = ( @@ -22,12 +38,12 @@ class EntryAdmin(reversion.VersionAdmin): ) fieldsets = [ - (None, { - 'classes': ('suit-tab suit-tab-general',), - 'fields': ('title', 'slug', 'draft', 'date', 'tags', ) + ('General', { + 'classes': ('suit-tab suit-tab-general collapse',), + 'fields': (('title', 'slug', 'draft'), ('date', 'tags'), ) }), - (None, { - 'classes': ('suit-tab suit-tab-content full-width',), + ('Content', { + 'classes': ('suit-tab suit-tab-content full-width wide',), 'fields': ('content', ) }), ] @@ -53,7 +69,7 @@ admin.site.register(Entry, EntryAdmin) # # TAG # -class TagAdmin(reversion.VersionAdmin): +class TagAdmin(VersionAdmin): pass admin.site.register(Tag, TagAdmin) diff --git a/fmartingrcom/apps/blog/migrations/0001_initial.py b/fmartingrcom/apps/blog/migrations/0001_initial.py index 89ce93d..e7ca1ff 100644 --- a/fmartingrcom/apps/blog/migrations/0001_initial.py +++ b/fmartingrcom/apps/blog/migrations/0001_initial.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from django.db import models, migrations from django.conf import settings -import ckeditor.fields +#import ckeditor.fields class Migration(migrations.Migration): @@ -19,7 +19,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('title', models.CharField(max_length=128)), ('date', models.DateTimeField()), - ('content', ckeditor.fields.RichTextField()), + ('content', models.TextField()), ('slug', models.SlugField(max_length=128)), ('draft', models.BooleanField(default=True)), ('author', models.ForeignKey(related_name='author', editable=False, to=settings.AUTH_USER_MODEL)), diff --git a/fmartingrcom/apps/blog/models.py b/fmartingrcom/apps/blog/models.py index 3bdd10d..648931e 100644 --- a/fmartingrcom/apps/blog/models.py +++ b/fmartingrcom/apps/blog/models.py @@ -2,10 +2,8 @@ from django.db import models from django.conf import settings from datetime import datetime from django.utils.timezone import utc -from ckeditor.fields import RichTextField +#from ckeditor.fields import RichTextField from django.core.urlresolvers import reverse -from django.utils.translation import activate - # # ENTRY @@ -13,7 +11,7 @@ from django.utils.translation import activate class Entry(models.Model): title = models.CharField(max_length=128) date = models.DateTimeField() - content = RichTextField() + content = models.TextField() slug = models.SlugField(max_length=128) draft = models.BooleanField(default=True) author = models.ForeignKey( @@ -21,7 +19,7 @@ class Entry(models.Model): editable=False, related_name='author' ) - tags = models.ManyToManyField('Tag', null=True, blank=True) + tags = models.ManyToManyField('Tag', blank=True) def __unicode__(self): return self.title diff --git a/fmartingrcom/apps/blog/urls.py b/fmartingrcom/apps/blog/urls.py index 40f0e74..dd221e7 100644 --- a/fmartingrcom/apps/blog/urls.py +++ b/fmartingrcom/apps/blog/urls.py @@ -1,10 +1,9 @@ -from django.conf.urls import patterns, url +from django.conf.urls import url from .views import ListView, EntryView, SearchView, RSSView -urlpatterns = patterns( - None, +urlpatterns = [ # Post list with page url( r'^page/(?P\d+)/$', @@ -35,4 +34,4 @@ urlpatterns = patterns( SearchView.as_view(), name='search', ) -) +] diff --git a/fmartingrcom/apps/blog/views.py b/fmartingrcom/apps/blog/views.py index 926d40b..53eaeaa 100644 --- a/fmartingrcom/apps/blog/views.py +++ b/fmartingrcom/apps/blog/views.py @@ -1,11 +1,9 @@ -from datetime import datetime - -from django.shortcuts import render_to_response +# -*- coding: utf-8 -*- +from django.shortcuts import render from django.template.loader import get_template from django.template import RequestContext from django.http import Http404, HttpResponseRedirect, HttpResponse from django.core.urlresolvers import reverse -from django.conf import settings import fmartingrcom.apps.blog.utils as blog_utils from .models import Entry @@ -30,8 +28,7 @@ class ListView(View): self.data['page_number'] = page_number self.data['paginator'] = paginator - context = RequestContext(request, self.data) - return render_to_response(self.template, context_instance=context) + return render(request, self.template, self.data) class EntryView(View): @@ -57,8 +54,7 @@ class EntryView(View): self.data['paginator'] = paginator self.data['item'] = item - context = RequestContext(request, self.data) - return render_to_response(self.template, context_instance=context) + return render(request, self.template, self.data) class SearchView(ListView): @@ -83,8 +79,7 @@ class SearchView(ListView): self.data['paginator'] = paginator self.data['search_query'] = search_query - context = RequestContext(request, self.data) - return render_to_response(self.template, context_instance=context) + return render(request, self.template, self.data) class RSSView(View): @@ -96,8 +91,8 @@ class RSSView(View): self.data['items'] = items context = RequestContext(request, self.data) - template = get_template(self.template) - return HttpResponse( - template.render(context), + template = get_template(self.template) + return HttpResponse( + template.render(context), content_type='text/xml' ) diff --git a/fmartingrcom/apps/homepage/urls.py b/fmartingrcom/apps/homepage/urls.py index b5aed23..fea0614 100644 --- a/fmartingrcom/apps/homepage/urls.py +++ b/fmartingrcom/apps/homepage/urls.py @@ -1,13 +1,12 @@ -from django.conf.urls import patterns, url - +# -*- coding: utf-8 -*- +from django.conf.urls import url from .views import HomepageView -urlpatterns = patterns( - None, +urlpatterns = [ url( r'^$', HomepageView.as_view(), name='homepage' ), -) +] diff --git a/fmartingrcom/apps/homepage/views.py b/fmartingrcom/apps/homepage/views.py index 25f62b8..102c0ab 100644 --- a/fmartingrcom/apps/homepage/views.py +++ b/fmartingrcom/apps/homepage/views.py @@ -1,5 +1,5 @@ -from django.shortcuts import render_to_response -from django.template import RequestContext +# -*- coding: utf-8 -*- +from django.shortcuts import render from fmartingrcom.apps._core.views import View @@ -8,5 +8,4 @@ class HomepageView(View): section = 'homepage' def get(self, request): - context = RequestContext(request, self.data) - return render_to_response(self.template, context_instance=context) + return render(request, self.template, self.data) diff --git a/fmartingrcom/apps/projects/admin.py b/fmartingrcom/apps/projects/admin.py index 0a7e9ed..fb1f201 100644 --- a/fmartingrcom/apps/projects/admin.py +++ b/fmartingrcom/apps/projects/admin.py @@ -4,7 +4,7 @@ from django.contrib import admin # 3rd party -import reversion +from reversion.admin import VersionAdmin # app from . import models @@ -13,7 +13,7 @@ from . import models # # Group # -class GroupAdmin(reversion.VersionAdmin): +class GroupAdmin(VersionAdmin): list_display = ('name', 'order', ) list_display_links = ('name', ) list_editable = ('order', ) @@ -36,11 +36,17 @@ class ProjectImageInline(admin.TabularInline): model = models.ProjectImage -class ProjectAdmin(reversion.VersionAdmin): +class ProjectAdmin(VersionAdmin): list_display = ('title', 'date', 'group', 'company', 'role', 'visible', ) list_editable = ('visible', ) inlines = (ProjectImageInline, ) prepopulated_fields = {"slug": ("title",)} + fieldsets = [ + ('General', { + 'fields': ('group', ('title', 'slug'), ('company', 'role'), 'date', ('stack', 'url', 'visible'), 'description') + }) + ] + admin.site.register(models.Project, ProjectAdmin) diff --git a/fmartingrcom/apps/projects/migrations/0001_initial.py b/fmartingrcom/apps/projects/migrations/0001_initial.py index cc2e574..f09eaf6 100644 --- a/fmartingrcom/apps/projects/migrations/0001_initial.py +++ b/fmartingrcom/apps/projects/migrations/0001_initial.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from django.db import models, migrations import fmartingrcom.apps.projects.models -import ckeditor.fields class Migration(migrations.Migration): @@ -33,7 +32,7 @@ class Migration(migrations.Migration): ('date', models.DateTimeField()), ('company', models.CharField(max_length=128, null=True, blank=True)), ('role', models.CharField(max_length=128)), - ('description', ckeditor.fields.RichTextField()), + ('description', models.TextField()), ('visible', models.BooleanField(default=True)), ('stack', models.CharField(default=None, max_length=256, null=True, blank=True)), ('url', models.CharField(default=None, max_length=256, null=True, blank=True)), diff --git a/fmartingrcom/apps/projects/models.py b/fmartingrcom/apps/projects/models.py index da64063..d123ba9 100644 --- a/fmartingrcom/apps/projects/models.py +++ b/fmartingrcom/apps/projects/models.py @@ -1,16 +1,12 @@ # coding: utf-8 - -# python import os import random import string -# django from django.db import models -from django.conf import settings # 3rd party -from ckeditor.fields import RichTextField +#from ckeditor.fields import RichTextField # @@ -32,7 +28,7 @@ class Project(models.Model): date = models.DateTimeField() company = models.CharField(max_length=128, null=True, blank=True) role = models.CharField(max_length=128) - description = RichTextField() + description = models.TextField() visible = models.BooleanField(default=True) stack = models.CharField(max_length=256, null=True, blank=True, default=None) diff --git a/fmartingrcom/apps/projects/urls.py b/fmartingrcom/apps/projects/urls.py index 84748be..1b2fc98 100644 --- a/fmartingrcom/apps/projects/urls.py +++ b/fmartingrcom/apps/projects/urls.py @@ -1,18 +1,13 @@ -# coding: utf-8 - -# django -from django.conf.urls import patterns, url - -# app +# -*- coding: utf-8 -*- +from django.conf.urls import url from . import views -urlpatterns = patterns( - None, +urlpatterns = [ # Project list url( r'^$', views.ListView.as_view(), name='list' ), -) +] diff --git a/fmartingrcom/apps/projects/views.py b/fmartingrcom/apps/projects/views.py index 5612801..a1002b5 100644 --- a/fmartingrcom/apps/projects/views.py +++ b/fmartingrcom/apps/projects/views.py @@ -1,14 +1,7 @@ -# coding: utf-8 - -# django -from django.shortcuts import render_to_response -from django.template import RequestContext - -# project +# -*- coding: utf-8 -*- +from django.shortcuts import render from fmartingrcom.apps._core.views import View from fmartingrcom.apps.config.models import SiteConfiguration - -# app from . import models config = SiteConfiguration.objects.get() @@ -25,5 +18,4 @@ class ListView(View): 'groups': models.Group.objects.all().order_by('order'), } - context = RequestContext(request, data) - return render_to_response(self.template, context_instance=context) + return render(request, self.template, data) diff --git a/fmartingrcom/settings/base.py b/fmartingrcom/settings/base.py index b5cc6b1..f30e68a 100644 --- a/fmartingrcom/settings/base.py +++ b/fmartingrcom/settings/base.py @@ -15,16 +15,13 @@ SECRET_KEY = '0123456789' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -TEMPLATE_DEBUG = True - ALLOWED_HOSTS = [] - # # APPLICATIONS # INSTALLED_APPS = ( - 'suit', + #'suit', 'solo', 'django.contrib.admin', 'django.contrib.auth', @@ -136,7 +133,16 @@ CKEDITOR_UPLOAD_PATH = 'ckeditor/' CKEDITOR_CONFIGS = { 'default': { - 'toolbar': 'Standard', + 'toolbar': 'Custom', + 'toolbar_Custom': ( + ['Styles'], + ['Bold', 'Italic', 'Underline'], + ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], + ['Image'], + ['Link', 'Unlink'], + ['Table'], + ['RemoveFormat', 'Source'] + ), 'width': '100%', 'stylesSet': ( { @@ -166,44 +172,61 @@ CKEDITOR_CONFIGS = { # # TEMPLATES # -TEMPLATE_LOADERS = ( - 'django_jinja.loaders.AppLoader', - 'django_jinja.loaders.FileSystemLoader', -) - - -TEMPLATE_DIRS = ( - '{}/themes/v1/templates/'.format(BASE_DIR), -) - -JINJA2_EXTENSIONS = [ - "jinja2.ext.do", - "jinja2.ext.loopcontrols", - "jinja2.ext.with_", - "jinja2.ext.i18n", - "jinja2.ext.autoescape", - "django_jinja.builtins.extensions.CsrfExtension", - "django_jinja.builtins.extensions.CacheExtension", - "django_jinja.builtins.extensions.TimezoneExtension", - "django_jinja.builtins.extensions.UrlsExtension", - "django_jinja.builtins.extensions.StaticFilesExtension", - "django_jinja.builtins.extensions.DjangoFiltersExtension", - "django_jinja.builtins.extensions.DjangoExtraFiltersExtension", - "compressor.contrib.jinja2ext.CompressorExtension", +TEMPLATE_PATHS = ('{}/themes/v1/templates/'.format(BASE_DIR), ) +TEMPLATES = [ + { + "BACKEND": "django_jinja.backend.Jinja2", + "DIRS": TEMPLATE_PATHS, + "OPTIONS": { + "match_extension": ".jinja", + "context_processors": ( + "django.contrib.auth.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", + "django.core.context_processors.static", + "django.core.context_processors.tz", + "django.core.context_processors.request", + "django.contrib.messages.context_processors.messages", + "fmartingrcom.apps.config.context_processors.config" + ), + "extensions": ( + "jinja2.ext.do", + "jinja2.ext.loopcontrols", + "jinja2.ext.with_", + "jinja2.ext.i18n", + "jinja2.ext.autoescape", + "django_jinja.builtins.extensions.CsrfExtension", + "django_jinja.builtins.extensions.CacheExtension", + "django_jinja.builtins.extensions.TimezoneExtension", + "django_jinja.builtins.extensions.UrlsExtension", + "django_jinja.builtins.extensions.StaticFilesExtension", + "django_jinja.builtins.extensions.DjangoFiltersExtension", + "django_jinja.builtins.extensions.DjangoExtraFiltersExtension", + "compressor.contrib.jinja2ext.CompressorExtension", + ) + } + }, + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'DIRS': (), + 'OPTIONS': { + "context_processors": ( + "django.contrib.auth.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", + "django.core.context_processors.static", + "django.core.context_processors.tz", + "django.core.context_processors.request", + "django.contrib.messages.context_processors.messages", + "fmartingrcom.apps.config.context_processors.config" + ) + }, + }, ] -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.core.context_processors.tz", - "django.core.context_processors.request", - "django.contrib.messages.context_processors.messages", - "fmartingrcom.apps.config.context_processors.config" -) - # # ADMIN # diff --git a/fmartingrcom/themes/v1/templates/_layout.jinja b/fmartingrcom/themes/v1/templates/_layout.jinja index 41af882..c04678d 100644 --- a/fmartingrcom/themes/v1/templates/_layout.jinja +++ b/fmartingrcom/themes/v1/templates/_layout.jinja @@ -5,8 +5,8 @@ {% compress css %} {% block stylesheets %} - - + + {% endblock %} {% endcompress %} {% block head %}{% endblock %} @@ -66,7 +66,7 @@ {% compress js %} - + {% block javascript %}{% endblock %} {% endcompress %} {% if config.google_analytics %} diff --git a/fmartingrcom/urls.py b/fmartingrcom/urls.py index 531849f..934b9b3 100644 --- a/fmartingrcom/urls.py +++ b/fmartingrcom/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.contrib import admin from .apps.homepage.sitemap import HomeSitemap @@ -13,15 +13,14 @@ sitemaps = { admin.autodiscover() -urlpatterns = patterns( - '', - (r'^ckeditor/', include('ckeditor.urls')), +urlpatterns = [ + #(r'^ckeditor/', include('ckeditor.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^blog/', include('fmartingrcom.apps.blog.urls', namespace='blog')), url(r'^portfolio/', include('fmartingrcom.apps.projects.urls', namespace='projects')), - url(r'^$', include('fmartingrcom.apps.homepage.urls', namespace='home')), -) + url(r'^', include('fmartingrcom.apps.homepage.urls', namespace='home')), +] from django.conf import settings diff --git a/requirements.txt b/requirements.txt index 7d30999..cee73de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,17 @@ -Django==1.7.7 +Django==1.9.4 -Jinja2==2.7.3 -django-jinja==1.3.1 +Jinja2==2.8 +django-jinja==2.1.2 -dj-database-url==0.3.0 +dj-database-url==0.4.0 -django-suit==0.2.12 -django-reversion==1.8.5 -django-solo==1.1.0 -django-ckeditor-updated==4.4.4 +django-suit==0.2.18 +django-reversion==1.10.1 +django-solo==1.1.2 +django-ckeditor==5.0.3 -pytz==2014.10 +pytz==2015.7 -django-compressor==1.4 +django-compressor==2.0 -easy-thumbnails==2.2 +easy-thumbnails==2.3