From 29f9ae067a1cd8d6fff974e826aed87931ab3032 Mon Sep 17 00:00:00 2001 From: Evgeniy Gulitsyn Date: Mon, 4 Oct 2010 13:14:21 +0600 Subject: [PATCH 01/20] Setup for redsolutioncms --- MANIFEST.in | 2 ++ chunks/redsolution_setup/__init__.py | 0 chunks/redsolution_setup/__init__.pyc | Bin 0 -> 231 bytes chunks/redsolution_setup/__init__.pyo | Bin 0 -> 231 bytes chunks/redsolution_setup/make.py | 19 ++++++++++++++++++ chunks/redsolution_setup/make.pyc | Bin 0 -> 1287 bytes chunks/redsolution_setup/make.pyo | Bin 0 -> 1287 bytes .../chunks/redsolutioncms/base_chunks.html | 17 ++++++++++++++++ .../chunks/redsolutioncms/robots.txt | 3 +++ .../chunks/redsolutioncms/settings.pyt | 2 ++ .../templates/chunks/redsolutioncms/urls.pyt | 3 +++ setup.py | 16 +++++++++++---- 12 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 MANIFEST.in create mode 100755 chunks/redsolution_setup/__init__.py create mode 100644 chunks/redsolution_setup/__init__.pyc create mode 100644 chunks/redsolution_setup/__init__.pyo create mode 100755 chunks/redsolution_setup/make.py create mode 100644 chunks/redsolution_setup/make.pyc create mode 100644 chunks/redsolution_setup/make.pyo create mode 100644 chunks/redsolution_setup/templates/chunks/redsolutioncms/base_chunks.html create mode 100644 chunks/redsolution_setup/templates/chunks/redsolutioncms/robots.txt create mode 100644 chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt create mode 100644 chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a62ed07 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include chunks * +exclude *.orig *.pyc \ No newline at end of file diff --git a/chunks/redsolution_setup/__init__.py b/chunks/redsolution_setup/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/chunks/redsolution_setup/__init__.pyc b/chunks/redsolution_setup/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..170d7d97a982b11506050825612580c474f63c00 GIT binary patch literal 231 zcmZ8b!3hE}5RBkM1pBzpWltZzL@Yr3SU`|ui8=0)aGMC}!X_-pK73h$dmy4N%q-08 z4s(Al<_~|{Yw?~5?;V4tOh$-fH7bXSN&FFAS%Y)v5%6NsyCQAwT%zJ34xvSz2nIA1 zx}03_weAUM(16zd7_3Xvp1ci;4>`dh)s0-rrjBJL*ODLL<9tUd!jvN@<-AKu$ym~i POKtjKa);ZoIx)lxM-)R2 literal 0 HcmV?d00001 diff --git a/chunks/redsolution_setup/__init__.pyo b/chunks/redsolution_setup/__init__.pyo new file mode 100644 index 0000000000000000000000000000000000000000..170d7d97a982b11506050825612580c474f63c00 GIT binary patch literal 231 zcmZ8b!3hE}5RBkM1pBzpWltZzL@Yr3SU`|ui8=0)aGMC}!X_-pK73h$dmy4N%q-08 z4s(Al<_~|{Yw?~5?;V4tOh$-fH7bXSN&FFAS%Y)v5%6NsyCQAwT%zJ34xvSz2nIA1 zx}03_weAUM(16zd7_3Xvp1ci;4>`dh)s0-rrjBJL*ODLL<9tUd!jvN@<-AKu$ym~i POKtjKa);ZoIx)lxM-)R2 literal 0 HcmV?d00001 diff --git a/chunks/redsolution_setup/make.py b/chunks/redsolution_setup/make.py new file mode 100755 index 0000000..5707906 --- /dev/null +++ b/chunks/redsolution_setup/make.py @@ -0,0 +1,19 @@ +from redsolutioncms.make import BaseMake +from redsolutioncms.models import CMSSettings + +class Make(BaseMake): + def make(self): + super(Make, self).make() + cms_settings = CMSSettings.objects.get_settings() + cms_settings.render_to('settings.py', 'chunks/redsolutioncms/settings.pyt') + cms_settings.render_to(['..', 'templates', 'base_chunks.html'], + 'chunks/redsolutioncms/base_chunks.html', { + }, 'w') + cms_settings.render_to('settings.py', 'chunks/redsolutioncms/urls.pyt') + cms_settings.render_to(['..', 'templates', 'robots.txt'], + 'chunks/redsolutioncms/robots.txt') + cms_settings.base_template = 'base_chunks.html' + cms_settings.save() + +make = Make() + diff --git a/chunks/redsolution_setup/make.pyc b/chunks/redsolution_setup/make.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a0dffe6d1aaa0a1cf32ce9fde2ed7caf88f9fb58 GIT binary patch literal 1287 zcmdT@&2G~`5T3Q2q(4*yDtH4VABbHza6$;RSK32zA{Wbzr;Z!{$+Ibn1gCQ3HFzN2 zgA*?R-)z$~po%kC-u2Gx&bQxuGyeADVDEeV_1%otPY>U>7;=Is!)s_kR2rHZGHQFY z@Tl}@>cjSl4P6+@0{TpJP4s>m5C^)N_9*MoBoS=22vK@v&UBWolXE5Y{=AN;VkL+*YML{~PQ* z0g!;`L+HR&9$B{BjrB?=bp@%%t~3Lx{d^HueD9?y6h5 z4ocE14mZHU<%PpRx*MDjf#fFnf>k_kDvtRo=ek%$`4U>ms*c;PaWu9?8#&dwSU>7;=Is!)s_kR2rHZGHQFY z@Tl}@>cjSl4P6+@0{TpJP4s>m5C^)N_9*MoBoS=22vK@v&UBWolXE5Y{=AN;VkL+*YML{~PQ* z0g!;`L+HR&9$B{BjrB?=bp@%%t~3Lx{d^HueD9?y6h5 z4ocE14mZHU<%PpRx*MDjf#fFnf>k_kDvtRo=ek%$`4U>ms*c;PaWu9?8#&dwS{% chunk "contacts" %} + +{% endblock footer %} +{% endraw %} \ No newline at end of file diff --git a/chunks/redsolution_setup/templates/chunks/redsolutioncms/robots.txt b/chunks/redsolution_setup/templates/chunks/redsolutioncms/robots.txt new file mode 100644 index 0000000..03fbd7f --- /dev/null +++ b/chunks/redsolution_setup/templates/chunks/redsolutioncms/robots.txt @@ -0,0 +1,3 @@ +{% load redsolutioncms_tags %}{% raw %} +{% load chunks %}{% chunk "robots.txt" %} +{% endraw %} \ No newline at end of file diff --git a/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt b/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt new file mode 100644 index 0000000..f816385 --- /dev/null +++ b/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt @@ -0,0 +1,2 @@ +# ------------ django-chunks ---------------- +INSTALLED_APPS += ['chunks'] diff --git a/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt b/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt new file mode 100644 index 0000000..c99a5ea --- /dev/null +++ b/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt @@ -0,0 +1,3 @@ +urlpatterns += patterns('', + (r'^robots.txt$', 'django.views.generic.simple.direct_to_template', {'template': 'robots.txt', 'mimetype': 'text/plain'}), +) \ No newline at end of file diff --git a/setup.py b/setup.py index 8b6bbb6..10529ef 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,17 @@ +# -*- coding: utf-8 -*- +import os +from setuptools import setup, find_packages from distutils.core import setup -setup(name='chunks', +setup(name='redsolutioncms.chunks', version='0.1', - description='Keyed blocks of content for use in your Django templates', + description=('Keyed blocks of content for use in your Django templates' + + ' with RedsolutionCMS integration'), author='Clint Ecker', author_email='me@clintecker.com', url='http://code.google.com/p/django-chunks/', - packages=['chunks', 'chunks.templatetags'], + packages=find_packages(), + include_package_data=True, classifiers=['Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Intended Audience :: Developers', @@ -14,4 +19,7 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Utilities'], - ) \ No newline at end of file + entry_points={ + 'redsolutioncms': ['chunks = chunks.redsolution_setup', ], + } + ) From 35381c3b39f3cb79523073ef3c76da74f41baaf5 Mon Sep 17 00:00:00 2001 From: Ivan Gromov Date: Tue, 5 Oct 2010 01:27:12 +0600 Subject: [PATCH 02/20] Fixed redsolutionCMS setup minor bugs --- chunks/redsolution_setup/make.py | 2 +- .../templates/chunks/redsolutioncms/settings.pyt | 3 ++- .../templates/chunks/redsolutioncms/urls.pyt | 4 +++- setup.py | 5 ++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chunks/redsolution_setup/make.py b/chunks/redsolution_setup/make.py index 5707906..f268b3a 100755 --- a/chunks/redsolution_setup/make.py +++ b/chunks/redsolution_setup/make.py @@ -9,7 +9,7 @@ def make(self): cms_settings.render_to(['..', 'templates', 'base_chunks.html'], 'chunks/redsolutioncms/base_chunks.html', { }, 'w') - cms_settings.render_to('settings.py', 'chunks/redsolutioncms/urls.pyt') + cms_settings.render_to('urls.py', 'chunks/redsolutioncms/urls.pyt') cms_settings.render_to(['..', 'templates', 'robots.txt'], 'chunks/redsolutioncms/robots.txt') cms_settings.base_template = 'base_chunks.html' diff --git a/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt b/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt index f816385..368a412 100644 --- a/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt +++ b/chunks/redsolution_setup/templates/chunks/redsolutioncms/settings.pyt @@ -1,2 +1,3 @@ -# ------------ django-chunks ---------------- +# ---- django-chunks ---- + INSTALLED_APPS += ['chunks'] diff --git a/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt b/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt index c99a5ea..1d32a02 100644 --- a/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt +++ b/chunks/redsolution_setup/templates/chunks/redsolutioncms/urls.pyt @@ -1,3 +1,5 @@ +# ---- django-chunks ---- + urlpatterns += patterns('', (r'^robots.txt$', 'django.views.generic.simple.direct_to_template', {'template': 'robots.txt', 'mimetype': 'text/plain'}), -) \ No newline at end of file +) diff --git a/setup.py b/setup.py index 10529ef..cfe8291 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,8 @@ from distutils.core import setup setup(name='redsolutioncms.chunks', - version='0.1', - description=('Keyed blocks of content for use in your Django templates' + - ' with RedsolutionCMS integration'), + version='0.1.0', + description=('Keyed blocks of content for use in your Django templates'), author='Clint Ecker', author_email='me@clintecker.com', url='http://code.google.com/p/django-chunks/', From f9be8cce93134dc4e5592591beb605c0a75c813c Mon Sep 17 00:00:00 2001 From: Ivan Gromov Date: Wed, 6 Oct 2010 23:40:13 +0600 Subject: [PATCH 03/20] Rewrite robots.txt file in setup --- chunks/redsolution_setup/make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/redsolution_setup/make.py b/chunks/redsolution_setup/make.py index f268b3a..4def2e2 100755 --- a/chunks/redsolution_setup/make.py +++ b/chunks/redsolution_setup/make.py @@ -11,7 +11,7 @@ def make(self): }, 'w') cms_settings.render_to('urls.py', 'chunks/redsolutioncms/urls.pyt') cms_settings.render_to(['..', 'templates', 'robots.txt'], - 'chunks/redsolutioncms/robots.txt') + 'chunks/redsolutioncms/robots.txt', {}, 'w') cms_settings.base_template = 'base_chunks.html' cms_settings.save() From 8238ad9f972199f96acc785548077b044f38ea1d Mon Sep 17 00:00:00 2001 From: Ivan Gromov Date: Fri, 22 Oct 2010 02:47:43 +0600 Subject: [PATCH 04/20] Updated setup.py and documentation --- DESCRIPTION | 2 ++ README | 1 + README.md => README.rst | 28 +++++++++++++++++++++++++--- chunks/__init__.py | 1 + setup.py | 27 ++++++++++++++++++++++----- 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 DESCRIPTION create mode 120000 README rename README.md => README.rst (77%) diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..3ff253d --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,2 @@ +Parts of reusable content across your site. Usable for validation meta codes, +analytics codes, phone numbers, addresses and so on. \ No newline at end of file diff --git a/README b/README new file mode 120000 index 0000000..92cacd2 --- /dev/null +++ b/README @@ -0,0 +1 @@ +README.rst \ No newline at end of file diff --git a/README.md b/README.rst similarity index 77% rename from README.md rename to README.rst index 6f4937d..1079abd 100644 --- a/README.md +++ b/README.rst @@ -1,16 +1,31 @@ -Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface. +Django chunks documentation +=========================== + +Preface +======= +Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface. This is really nothing more than a model and a template tag. By adding `chunks` to your installed apps list in your Django project and performing a `./manage.py syncdb`, you'll be able to add as many "keyed" bits of content chunks to your site. The idea here is that you can create a chunk of content, name it with a unique key (for example: `home_page_left_bottom`) and then you can call this content from a normal template. -### Why would anyone want this? ### +Why would anyone want this? +---------------------------- Well it essentially allows someone to define "chunks" (I had wanted to call it blocks, but that would be very confusing for obvious reasons) of content in your template that can be directly edited from the awesome Django admin interface. Throwing a rich text editor control on top of it make it even easier. -### Usage: ### +Installation +============ + +1. Add ``chunks`` to your ``INSTALLED_APPS`` +2. Run ``manage.py syncdb`` + +Usage: +====== + +In your template :: {% load chunks %} @@ -32,3 +47,10 @@ Well it essentially allows someone to define "chunks" (I had wanted to call it b This is really helpful in those cases where you want to use `django.contrib.flatpages` but you need multiple content areas. I hope this is helpful to people and I'll be making minor edits as I see them necessary. + +Redsolution CMS classifiers: +---------------------------- + +`Content plugins`_ + +.. _`Content plugins`: http://www.redsolutioncms.org/classifiers/content diff --git a/chunks/__init__.py b/chunks/__init__.py index e69de29..b794fd4 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -0,0 +1 @@ +__version__ = '0.1.0' diff --git a/setup.py b/setup.py index cfe8291..a18799a 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,28 @@ # -*- coding: utf-8 -*- import os from setuptools import setup, find_packages -from distutils.core import setup -setup(name='redsolutioncms.chunks', - version='0.1.0', - description=('Keyed blocks of content for use in your Django templates'), +# Utility function to read the README file. +# Used for the long_description. It's nice, because now 1) we have a top level +# README file and 2) it's easier to type in the README file than to put a raw +# string in below ... +def read(fname): + try: + return open(os.path.join(os.path.dirname(__file__), fname)).read() + except IOError: + return '' + +setup(name='redsolutioncms.django-chunks', + version=__import__('chunks').__version__, + description=read('DESCRIPTION'), + author='Clint Ecker', author_email='me@clintecker.com', + url='http://code.google.com/p/django-chunks/', + packages=find_packages(), - include_package_data=True, + classifiers=['Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Intended Audience :: Developers', @@ -18,6 +30,11 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Utilities'], + + include_package_data=True, + zip_safe=False, + long_description=read('README'), + entry_points={ 'redsolutioncms': ['chunks = chunks.redsolution_setup', ], } From def1f119d72f8fd669299f573712f4c3945dde88 Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Fri, 3 Feb 2012 14:32:17 +0600 Subject: [PATCH 05/20] Description field added. --- chunks/admin.py | 4 +-- chunks/migrations/0001_initial.py | 35 +++++++++++++++++++ .../0002_auto__add_field_chunk_description.py | 31 ++++++++++++++++ chunks/migrations/__init__.py | 0 chunks/models.py | 1 + 5 files changed, 69 insertions(+), 2 deletions(-) mode change 100644 => 100755 chunks/admin.py create mode 100644 chunks/migrations/0001_initial.py create mode 100644 chunks/migrations/0002_auto__add_field_chunk_description.py create mode 100644 chunks/migrations/__init__.py mode change 100644 => 100755 chunks/models.py diff --git a/chunks/admin.py b/chunks/admin.py old mode 100644 new mode 100755 index 06dd917..b1544b3 --- a/chunks/admin.py +++ b/chunks/admin.py @@ -2,7 +2,7 @@ from models import Chunk class ChunkAdmin(admin.ModelAdmin): - list_display = ('key',) + list_display = ('key', 'description') search_fields = ('key', 'content') -admin.site.register(Chunk, ChunkAdmin) \ No newline at end of file +admin.site.register(Chunk, ChunkAdmin) diff --git a/chunks/migrations/0001_initial.py b/chunks/migrations/0001_initial.py new file mode 100644 index 0000000..ddd7d9e --- /dev/null +++ b/chunks/migrations/0001_initial.py @@ -0,0 +1,35 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding model 'Chunk' + db.create_table('chunks_chunk', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('key', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), + ('content', self.gf('django.db.models.fields.TextField')(blank=True)), + )) + db.send_create_signal('chunks', ['Chunk']) + + + def backwards(self, orm): + + # Deleting model 'Chunk' + db.delete_table('chunks_chunk') + + + models = { + 'chunks.chunk': { + 'Meta': {'object_name': 'Chunk'}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) + } + } + + complete_apps = ['chunks'] diff --git a/chunks/migrations/0002_auto__add_field_chunk_description.py b/chunks/migrations/0002_auto__add_field_chunk_description.py new file mode 100644 index 0000000..f2447b6 --- /dev/null +++ b/chunks/migrations/0002_auto__add_field_chunk_description.py @@ -0,0 +1,31 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding field 'Chunk.description' + db.add_column('chunks_chunk', 'description', self.gf('django.db.models.fields.CharField')(default='', max_length=255, blank=True), keep_default=False) + + + def backwards(self, orm): + + # Deleting field 'Chunk.description' + db.delete_column('chunks_chunk', 'description') + + + models = { + 'chunks.chunk': { + 'Meta': {'object_name': 'Chunk'}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) + } + } + + complete_apps = ['chunks'] diff --git a/chunks/migrations/__init__.py b/chunks/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/chunks/models.py b/chunks/models.py old mode 100644 new mode 100755 index cdb36be..ed994d6 --- a/chunks/models.py +++ b/chunks/models.py @@ -9,6 +9,7 @@ class Chunk(models.Model): """ key = models.CharField(help_text="A unique name for this chunk of content", blank=False, max_length=255, unique=True) content = models.TextField(blank=True) + description = models.TextField(blank=True, unique=False) def __unicode__(self): return u"%s" % (self.key,) From 9ff84dfd2de48f679aba4430b84b2441fd860a8e Mon Sep 17 00:00:00 2001 From: Victor Smirnov Date: Fri, 3 Feb 2012 14:37:51 +0600 Subject: [PATCH 06/20] Version set in 0.2.0 --- chunks/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/__init__.py b/chunks/__init__.py index b794fd4..7fd229a 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1 @@ -__version__ = '0.1.0' +__version__ = '0.2.0' From d87ba63c298513f2dcec93ca8718018329bcd444 Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Mon, 16 Jul 2012 13:04:20 +0600 Subject: [PATCH 07/20] Cache entries keys variation for different django projects added. --- chunks/templatetags/__init__.py | 9 +++++++++ chunks/templatetags/chunks.py | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/chunks/templatetags/__init__.py b/chunks/templatetags/__init__.py index e69de29..5a31598 100644 --- a/chunks/templatetags/__init__.py +++ b/chunks/templatetags/__init__.py @@ -0,0 +1,9 @@ +from django.conf import settings +from md5 import md5 + +def get_cache_suffix(): + try: + project_hash = md5(settings.SECRET_KEY).hexdigest() + return "_%s" % project_hash + except AttributeError: + return "_%s" % md5().hexdigest() \ No newline at end of file diff --git a/chunks/templatetags/chunks.py b/chunks/templatetags/chunks.py index 2b06cad..32f8e12 100644 --- a/chunks/templatetags/chunks.py +++ b/chunks/templatetags/chunks.py @@ -1,11 +1,13 @@ from django import template from django.db import models from django.core.cache import cache +from templatetags import get_cache_suffix register = template.Library() Chunk = models.get_model('chunks', 'chunk') -CACHE_PREFIX = "chunk_" +CACHE_PREFIX = 'chunks_' +CACHE_SUFFIX = get_cache_suffix() def do_get_chunk(parser, token): # split_contents() knows not to split quoted strings. @@ -30,7 +32,7 @@ def __init__(self, key, cache_time=0): def render(self, context): try: - cache_key = CACHE_PREFIX + self.key + cache_key = CACHE_PREFIX + self.key + CACHE_SUFFIX c = cache.get(cache_key) if c is None: c = Chunk.objects.get(key=self.key) From 2777049abdd73eab1b0f8ea0d16ab08c362f598f Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Mon, 16 Jul 2012 14:44:23 +0600 Subject: [PATCH 08/20] Version set in 0.2.1 --- .gitignore | 1 + chunks/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f7ebcbb..4e08c5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp .svn +*.pyc diff --git a/chunks/__init__.py b/chunks/__init__.py index 7fd229a..fc79d63 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1 @@ -__version__ = '0.2.0' +__version__ = '0.2.1' From 3d5641c3009a05b9ebefced943aa58068b09d9f8 Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Wed, 18 Jul 2012 12:07:49 +0600 Subject: [PATCH 09/20] Template tags library bug fixed --- chunks/templatetags/__init__.py | 9 --------- chunks/templatetags/chunks.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/chunks/templatetags/__init__.py b/chunks/templatetags/__init__.py index 5a31598..e69de29 100644 --- a/chunks/templatetags/__init__.py +++ b/chunks/templatetags/__init__.py @@ -1,9 +0,0 @@ -from django.conf import settings -from md5 import md5 - -def get_cache_suffix(): - try: - project_hash = md5(settings.SECRET_KEY).hexdigest() - return "_%s" % project_hash - except AttributeError: - return "_%s" % md5().hexdigest() \ No newline at end of file diff --git a/chunks/templatetags/chunks.py b/chunks/templatetags/chunks.py index 32f8e12..5c0a692 100644 --- a/chunks/templatetags/chunks.py +++ b/chunks/templatetags/chunks.py @@ -1,7 +1,8 @@ from django import template -from django.db import models +from django.conf import settings from django.core.cache import cache -from templatetags import get_cache_suffix +from django.db import models +from md5 import md5 register = template.Library() @@ -9,6 +10,13 @@ CACHE_PREFIX = 'chunks_' CACHE_SUFFIX = get_cache_suffix() +def get_cache_suffix(): + try: + project_hash = md5(settings.SECRET_KEY).hexdigest() + return "_%s" % project_hash + except AttributeError: + return "_%s" % md5().hexdigest() + def do_get_chunk(parser, token): # split_contents() knows not to split quoted strings. tokens = token.split_contents() From b18910a696f0f5a32497178844261bcb1459fcd0 Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Wed, 18 Jul 2012 12:27:00 +0600 Subject: [PATCH 10/20] Another bug fixed --- chunks/templatetags/chunks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chunks/templatetags/chunks.py b/chunks/templatetags/chunks.py index 5c0a692..e04e5f9 100644 --- a/chunks/templatetags/chunks.py +++ b/chunks/templatetags/chunks.py @@ -6,10 +6,6 @@ register = template.Library() -Chunk = models.get_model('chunks', 'chunk') -CACHE_PREFIX = 'chunks_' -CACHE_SUFFIX = get_cache_suffix() - def get_cache_suffix(): try: project_hash = md5(settings.SECRET_KEY).hexdigest() @@ -17,6 +13,10 @@ def get_cache_suffix(): except AttributeError: return "_%s" % md5().hexdigest() +Chunk = models.get_model('chunks', 'chunk') +CACHE_PREFIX = 'chunks_' +CACHE_SUFFIX = get_cache_suffix() + def do_get_chunk(parser, token): # split_contents() knows not to split quoted strings. tokens = token.split_contents() From 888a083d40ed94f219b74aeab4906b24d7afa49c Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Fri, 10 Aug 2012 13:42:23 +0600 Subject: [PATCH 11/20] Deprecated module 'md5' has been replaced with 'hashlib' --- chunks/templatetags/chunks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/templatetags/chunks.py b/chunks/templatetags/chunks.py index e04e5f9..28f91c8 100644 --- a/chunks/templatetags/chunks.py +++ b/chunks/templatetags/chunks.py @@ -2,7 +2,7 @@ from django.conf import settings from django.core.cache import cache from django.db import models -from md5 import md5 +from hashlib import md5 register = template.Library() From 7e66f2d6b521170dc3055870e41d0a11f206f56b Mon Sep 17 00:00:00 2001 From: "victor.smirnov" Date: Tue, 21 May 2013 11:54:13 +0600 Subject: [PATCH 12/20] New version 0.2.2 --- MANIFEST.in | 2 +- chunks/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index a62ed07..8a3837a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ recursive-include chunks * -exclude *.orig *.pyc \ No newline at end of file +global-exclude *.orig *.pyc diff --git a/chunks/__init__.py b/chunks/__init__.py index fc79d63..020ed73 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1 @@ -__version__ = '0.2.1' +__version__ = '0.2.2' From 0f860cb858a8f8e76f1421d1976b884ccb58e1cb Mon Sep 17 00:00:00 2001 From: "egor.slesarev" Date: Thu, 25 Dec 2014 16:22:38 +0500 Subject: [PATCH 13/20] Fixed ineffective usage of caching --- chunks/__init__.py | 2 +- chunks/templatetags/chunks.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/chunks/__init__.py b/chunks/__init__.py index 020ed73..d93b5b2 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1 @@ -__version__ = '0.2.2' +__version__ = '0.2.3' diff --git a/chunks/templatetags/chunks.py b/chunks/templatetags/chunks.py index 28f91c8..dd0224f 100644 --- a/chunks/templatetags/chunks.py +++ b/chunks/templatetags/chunks.py @@ -44,7 +44,8 @@ def render(self, context): c = cache.get(cache_key) if c is None: c = Chunk.objects.get(key=self.key) - cache.set(cache_key, c, int(self.cache_time)) + if self.cache_time != 0: + cache.set(cache_key, c, int(self.cache_time)) content = c.content except Chunk.DoesNotExist: content = '' From 8aa72f39f800bf583504621d7cc133c1f6aea01c Mon Sep 17 00:00:00 2001 From: "konstantin.gabbasov" Date: Fri, 17 Apr 2015 18:04:50 +0500 Subject: [PATCH 14/20] _Russian translation added. --- chunks/__init__.py | 2 +- chunks/locale/ru/LC_MESSAGES/django.mo | Bin 0 -> 900 bytes chunks/locale/ru/LC_MESSAGES/django.po | 45 +++++++++++++++++++++++++ chunks/models.py | 12 +++++-- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 chunks/locale/ru/LC_MESSAGES/django.mo create mode 100644 chunks/locale/ru/LC_MESSAGES/django.po mode change 100755 => 100644 chunks/models.py diff --git a/chunks/__init__.py b/chunks/__init__.py index d93b5b2..a6587ae 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1 @@ -__version__ = '0.2.3' +__version__ = '0.2.4' diff --git a/chunks/locale/ru/LC_MESSAGES/django.mo b/chunks/locale/ru/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..3850d078266d51b3d78820fa866896c309aa8b15 GIT binary patch literal 900 zcmZvYOK;Oa5XYBNiexUR;>ck*P^i!bJ53>S>e7&;RfSWc)>`(tkH{(HD>8(9N79;~NUHyZoJ0mr5b_NfLQ3fW7$D><+EGjnqjk}qLt96i#_t_j zg%(SCz0ve~rTww|k28o~ItM93%%g`f10Jq0SP~NSa-^WS9P8pv)% zDo4R8Q%xClbtE{s#a2l}iu1>PMVNzk(%{nP-o^^%Pw65Awi{6aeiUz_3t8qJ^ z70JT11+9jfxsbP=acUQ+a}At=J9hnwJ#O15r1R`il=l3OuIT2Ana&TDrhyE(>V#TI z7p50|ALh#S8cfvcR678WKgKjiH=Y%?0LaK#0`JU6pgo-(!rLPq&40Yt%$c> zDBg>-)#$`B?9gc;SCk99+jEsSR)Xy5UFH`Z+w&Y48G-a^U+^3UZh#FaM}N}GAEzd~ zLi+4g*b|NoYin5vYV1+0aj+&oTC(oa8OE8+ep5rRR;0nnjpquO$y~Z1V%cPsY!?@@ zWr%rU-k1;O9o`3K*KC8?GKXf*?4WxH=54Z(tS6h0JnN-Dp=>YNGzZCs*(c_8@&p6# m&A!>j(E2}tWP_Mj*lx>gqjKl?8^pXcpUrOav>*6u3i2B+s3B$m literal 0 HcmV?d00001 diff --git a/chunks/locale/ru/LC_MESSAGES/django.po b/chunks/locale/ru/LC_MESSAGES/django.po new file mode 100644 index 0000000..4100fb9 --- /dev/null +++ b/chunks/locale/ru/LC_MESSAGES/django.po @@ -0,0 +1,45 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: chunks\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-04-16 14:37+0500\n" +"PO-Revision-Date: 2015-04-16 18:28+0500\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Generator: Poedit 1.5.4\n" +"X-Poedit-SourceCharset: UTF-8\n" + +#: models.py:11 +msgid "Key" +msgstr "Название" + +#: models.py:11 +msgid "A unique name for this chunk of content" +msgstr "Название должно быть уникальным" + +#: models.py:12 +msgid "Content" +msgstr "Содержание" + +#: models.py:13 +msgid "Description" +msgstr "Описание" + +#: models.py:19 +msgid "Chunk" +msgstr "Фрагмент" + +#: models.py:20 +msgid "Chunks" +msgstr "Фрагменты" diff --git a/chunks/models.py b/chunks/models.py old mode 100755 new mode 100644 index ed994d6..522c8a0 --- a/chunks/models.py +++ b/chunks/models.py @@ -1,4 +1,6 @@ +# -*- coding: utf-8 -*- from django.db import models +from django.utils.translation import ugettext_lazy as _ class Chunk(models.Model): """ @@ -7,9 +9,13 @@ class Chunk(models.Model): any template with the use of a special template tag """ - key = models.CharField(help_text="A unique name for this chunk of content", blank=False, max_length=255, unique=True) - content = models.TextField(blank=True) - description = models.TextField(blank=True, unique=False) + key = models.CharField( _('Key'), help_text=_("A unique name for this chunk of content"), blank=False, max_length=255, unique=True) + content = models.TextField( _('Content'),blank=True) + description = models.TextField( _('Description'),blank=True, unique=False) def __unicode__(self): return u"%s" % (self.key,) + + class Meta: + verbose_name = _('Chunk') + verbose_name_plural = _('Chunks') From 8b57be141681f548e6be0ca90ff3a3825970a562 Mon Sep 17 00:00:00 2001 From: "azat.zakirov" Date: Mon, 21 Oct 2019 14:52:39 +0500 Subject: [PATCH 15/20] Up to Django 1.11 - Up to Django 1.11 - Optimization: Added context processor and caching chunks --- .gitignore | 1 + README | 1 - README.md | 75 ++++++++++++++++++ README.rst | 56 ------------- USAGE | 58 -------------- chunks/__init__.py | 3 +- chunks/admin.py | 14 +++- chunks/apps.py | 13 +++ chunks/context_processors.py | 33 ++++++++ chunks/locale/ru/LC_MESSAGES/django.mo | Bin 900 -> 969 bytes chunks/locale/ru/LC_MESSAGES/django.po | 4 + chunks/migrations/0001_initial.py | 51 +++++------- .../0002_auto__add_field_chunk_description.py | 41 ++++------ chunks/migrations/0003_chunk_file.py | 20 +++++ chunks/models.py | 4 +- chunks/signals.py | 12 +++ chunks/templatetags/chunks.py | 54 ------------- chunks/templatetags/chunks_tags.py | 21 +++++ 18 files changed, 232 insertions(+), 229 deletions(-) delete mode 120000 README create mode 100644 README.md delete mode 100644 README.rst delete mode 100644 USAGE mode change 100755 => 100644 chunks/admin.py create mode 100644 chunks/apps.py create mode 100644 chunks/context_processors.py create mode 100644 chunks/migrations/0003_chunk_file.py create mode 100644 chunks/signals.py delete mode 100644 chunks/templatetags/chunks.py create mode 100644 chunks/templatetags/chunks_tags.py diff --git a/.gitignore b/.gitignore index 4e08c5b..e574f58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp .svn *.pyc +.idea/* \ No newline at end of file diff --git a/README b/README deleted file mode 120000 index 92cacd2..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -README.rst \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c8d753 --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# Django chunks documentation + +## Preface + +Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface. +This is really nothing more than a model and a template tag. + +By adding `chunks` to your installed apps list in your Django project and performing a `./manage.py syncdb`, you'll be able to add as many "keyed" bits of content chunks to your site. + +The idea here is that you can create a chunk of content, name it with a unique key (for example: `home_page_left_bottom`) and then you can call this content from a normal template. + +### Why would anyone want this? + +Well it essentially allows someone to define "chunks" (I had wanted to call it blocks, but that would be very confusing for obvious reasons) of content in your template that can be directly edited from the awesome Django admin interface. Throwing a rich text editor control on top of it make it even easier. + +## Installation and basic usage + +1. Install package + + `` pip install git+git://github.com/oldroute/django-chunks.git`` + +2. Configure your settings file: + + ``` + INSTALLED_APPS += ['chunks'] + ``` +3. Call chunks in the html template + + Usage example №1: + ``` html + {% load chunks_tags %} + + ... + {% chunk "phone" %} + ... + + ``` + Usage example №2: + ``` html + {% load chunks_tags %} + + ... + {% get_chunk "phone" as phone %} + {% if phone.content %} + {{ phone.content }} + {% endif %} + ... + +4. Apply migrations and run local server + + ```python + python manage.py migrate chunks + python manage.py runserver + ``` +5. Create chunks in admin interface + +## Advansed usage +In many cases you may need in many chunks. Basic usage examples generate one request to database for each chunk - +this is a bad idea for large projects. For large progects your must use cached chunks. + +1. Add context processor to settings.py + + ```python + TEMPLATES[0]['OPTIONS']['context_processors'] += ['chunks.context_processors.chunks_processor'] + ``` +2. Call chunks in the html template + ```html + + ... + {% if chunks.phone %} + {{ chunks.phone.content }} + {% endif %} + ... + + ``` diff --git a/README.rst b/README.rst deleted file mode 100644 index 1079abd..0000000 --- a/README.rst +++ /dev/null @@ -1,56 +0,0 @@ -Django chunks documentation -=========================== - -Preface -======= - -Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface. -This is really nothing more than a model and a template tag. - -By adding `chunks` to your installed apps list in your Django project and performing a `./manage.py syncdb`, you'll be able to add as many "keyed" bits of content chunks to your site. - -The idea here is that you can create a chunk of content, name it with a unique key (for example: `home_page_left_bottom`) and then you can call this content from a normal template. - -Why would anyone want this? ----------------------------- - -Well it essentially allows someone to define "chunks" (I had wanted to call it blocks, but that would be very confusing for obvious reasons) of content in your template that can be directly edited from the awesome Django admin interface. Throwing a rich text editor control on top of it make it even easier. - -Installation -============ - -1. Add ``chunks`` to your ``INSTALLED_APPS`` -2. Run ``manage.py syncdb`` - -Usage: -====== - -In your template :: - - {% load chunks %} - - - Test - - -

Blah blah blah

- -
- {% chunk "home_page_left" %} -
- - - - -This is really helpful in those cases where you want to use `django.contrib.flatpages` but you need multiple content areas. I hope this is helpful to people and I'll be making minor edits as I see them necessary. - -Redsolution CMS classifiers: ----------------------------- - -`Content plugins`_ - -.. _`Content plugins`: http://www.redsolutioncms.org/classifiers/content diff --git a/USAGE b/USAGE deleted file mode 100644 index c7dbb42..0000000 --- a/USAGE +++ /dev/null @@ -1,58 +0,0 @@ -Think of it as flatpages for small bits of reusable content you might want to -insert into your templates and manage from the admin interface. - -This is really nothing more than a model and a template tag. - -By adding `chunks` to your installed apps list in your Django project and -performing a `./manage.py syncdb`, you'll be able to add as many "keyed" bits -of content chunks to your site. - -The idea here is that you can create a chunk of content, name it with a unique -key (for example: `home_page_left_bottom`) and then you can call this content -from a normal template. - -Why would anyone want this? - -It essentially allows someone to define "chunks" (I had wanted to call it - blocks, but that would be very confusing for obvious reasons) of content in -your template that can be directly edited from the awesome Django admin -interface. Throwing a rich text editor control on top of it make it even -easier. - -Template tag usage: - -{% load chunks %} - - - Test - - -

Blah blah blah

- -
- {% chunk "home_page_left" %} -
- - - - -This is really helpful in those cases where you want to use -`django.contrib.flatpages` but you need multiple content areas. I hope this -is helpful to people and I'll be making minor edits as I see them necessary. - -Caching - -If you want to cache the content of your chunks you can pass along a caching -time argument in your chunk tag. Example: - -{% chunk "home_page_left" 3600 %} - -The caching time is specified in seconds. For caching to work properly you -must configure a cache backend in your settings.py. See the Django -documentation for more information: - -http://www.djangoproject.com/documentation/cache/ diff --git a/chunks/__init__.py b/chunks/__init__.py index a6587ae..43357f3 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1 +1,2 @@ -__version__ = '0.2.4' +__version__ = '1.11' +default_app_config = 'chunks.apps.ChunksAppConfig' diff --git a/chunks/admin.py b/chunks/admin.py old mode 100755 new mode 100644 index b1544b3..c22fec1 --- a/chunks/admin.py +++ b/chunks/admin.py @@ -1,8 +1,16 @@ +from django.utils.translation import ugettext_lazy as _ from django.contrib import admin -from models import Chunk +from .models import Chunk + class ChunkAdmin(admin.ModelAdmin): - list_display = ('key', 'description') - search_fields = ('key', 'content') + + def get_content(self, obj): + return obj.content[0:50] + + get_content.short_description = _('content') + list_display = ('key', 'description', 'get_content') + search_fields = ('key', 'content') + admin.site.register(Chunk, ChunkAdmin) diff --git a/chunks/apps.py b/chunks/apps.py new file mode 100644 index 0000000..bcd2302 --- /dev/null +++ b/chunks/apps.py @@ -0,0 +1,13 @@ +from django.apps import AppConfig +from django.utils.translation import ugettext_lazy as _ + + +class ChunksAppConfig(AppConfig): + name = 'chunks' + verbose_name = _('Chunk') + + class Meta: + app_label = 'chunks' + + def ready(self): + from . import signals \ No newline at end of file diff --git a/chunks/context_processors.py b/chunks/context_processors.py new file mode 100644 index 0000000..ffae29c --- /dev/null +++ b/chunks/context_processors.py @@ -0,0 +1,33 @@ +import json +from django.core.cache import cache +from django.utils.html import mark_safe +from .models import Chunk + +CACHE_KEY = 'chunks' + + +def get_chunks_data(): + result = {} + for chunk in Chunk.objects.all(): + result[chunk.key] = { + 'content': chunk.content, + 'file': chunk.file.url if chunk.file else None + } + return result + + +def chunks_processor(request): + chunks_json = cache.get(CACHE_KEY) + if chunks_json: + raw_chunks = json.loads(chunks_json) + else: + raw_chunks = get_chunks_data() + cache.set(CACHE_KEY, json.dumps(raw_chunks, ensure_ascii=False)) + + chunks = {} + for key, val in raw_chunks.iteritems(): + chunks[key] = { + 'content': mark_safe(val['content']), + 'file': val['file'] + } + return {'chunks': chunks} diff --git a/chunks/locale/ru/LC_MESSAGES/django.mo b/chunks/locale/ru/LC_MESSAGES/django.mo index 3850d078266d51b3d78820fa866896c309aa8b15..8e0d98994cee0af4a9d49980552b1b285dc4b415 100644 GIT binary patch delta 222 zcmZo+KgnKyPl#nI0}yZku?!H$05LZZ&jDf(I03}!KztI2S%LT?5VHaCcOYg5;(tI4 zQqRW7z`zTng@80OkX8WF&wyA3h^;|tfPw-*+8sy>0qF=JEyBPc#gGk^XaLe`K#7S^ z{*H;A%8VQn*M{=CW#*(R;PhQAl?bYtU&w_h}nSnIS_;NyaQs8 z`fotY48%-~3=GeJm<@=nf&8~j3=9H5S`#QK1f;Eiv 3: - raise template.TemplateSyntaxError, "%r tag should have either 2 or 3 arguments" % (tokens[0],) - if len(tokens) == 2: - tag_name, key = tokens - cache_time = 0 - if len(tokens) == 3: - tag_name, key, cache_time = tokens - # Check to see if the key is properly double/single quoted - if not (key[0] == key[-1] and key[0] in ('"', "'")): - raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name - # Send key without quotes and caching time - return ChunkNode(key[1:-1], cache_time) - -class ChunkNode(template.Node): - def __init__(self, key, cache_time=0): - self.key = key - self.cache_time = cache_time - - def render(self, context): - try: - cache_key = CACHE_PREFIX + self.key + CACHE_SUFFIX - c = cache.get(cache_key) - if c is None: - c = Chunk.objects.get(key=self.key) - if self.cache_time != 0: - cache.set(cache_key, c, int(self.cache_time)) - content = c.content - except Chunk.DoesNotExist: - content = '' - return content - -register.tag('chunk', do_get_chunk) diff --git a/chunks/templatetags/chunks_tags.py b/chunks/templatetags/chunks_tags.py new file mode 100644 index 0000000..0c0dbb2 --- /dev/null +++ b/chunks/templatetags/chunks_tags.py @@ -0,0 +1,21 @@ +from django import template +from chunks.models import Chunk +from django.utils.safestring import mark_safe + +register = template.Library() + + +@register.simple_tag +def chunk(key): + try: + return mark_safe(Chunk.objects.get(key=key).content) + except: + return '' + + +@register.assignment_tag +def get_chunk(key): + try: + return Chunk.objects.get(key=key) + except: + return None From d880440d823fa02091a090bf7bb355edaac2822f Mon Sep 17 00:00:00 2001 From: "egor.merkushkin" Date: Tue, 1 Sep 2020 16:39:41 +0500 Subject: [PATCH 16/20] Template tags fix for django 2.2 --- chunks/templatetags/chunks_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/templatetags/chunks_tags.py b/chunks/templatetags/chunks_tags.py index 0c0dbb2..2e9ee6b 100644 --- a/chunks/templatetags/chunks_tags.py +++ b/chunks/templatetags/chunks_tags.py @@ -13,7 +13,7 @@ def chunk(key): return '' -@register.assignment_tag +@register.simple_tag def get_chunk(key): try: return Chunk.objects.get(key=key) From f317cd923b43f892a980b187ed3e7b211b09f806 Mon Sep 17 00:00:00 2001 From: "egor.merkushkin" Date: Wed, 2 Sep 2020 14:28:29 +0500 Subject: [PATCH 17/20] Name fix --- chunks/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/models.py b/chunks/models.py index d7b7772..e94c9cd 100644 --- a/chunks/models.py +++ b/chunks/models.py @@ -15,7 +15,7 @@ class Chunk(models.Model): file = models.FileField( _('File or image'), upload_to='uploads', null=True, blank=True) description = models.TextField( _('Description'),blank=True, unique=False) - def __unicode__(self): + def __str__(self): return u"%s" % (self.key,) class Meta: From 6adb6ad855d5185748e6002d1a13c1cb7a1cfd0c Mon Sep 17 00:00:00 2001 From: "egor.merkushkin" Date: Tue, 8 Sep 2020 10:38:38 +0500 Subject: [PATCH 18/20] django 2.2 fix --- README.md | 2 +- chunks/context_processors.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c8d753..673f06b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Well it essentially allows someone to define "chunks" (I had wanted to call it b 1. Install package - `` pip install git+git://github.com/oldroute/django-chunks.git`` + `` pip install git+git://github.com/shoker174/django-chunks.git`` 2. Configure your settings file: diff --git a/chunks/context_processors.py b/chunks/context_processors.py index ffae29c..f08cb28 100644 --- a/chunks/context_processors.py +++ b/chunks/context_processors.py @@ -25,7 +25,7 @@ def chunks_processor(request): cache.set(CACHE_KEY, json.dumps(raw_chunks, ensure_ascii=False)) chunks = {} - for key, val in raw_chunks.iteritems(): + for key, val in raw_chunks.items(): chunks[key] = { 'content': mark_safe(val['content']), 'file': val['file'] From e8993355a21fc2435278af87d60cdaf80878efea Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov Date: Wed, 18 Oct 2023 17:19:32 +0500 Subject: [PATCH 19/20] Fix version in __init__.py --- chunks/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chunks/__init__.py b/chunks/__init__.py index 43357f3..739fd2b 100644 --- a/chunks/__init__.py +++ b/chunks/__init__.py @@ -1,2 +1,2 @@ -__version__ = '1.11' +__version__ = '2.2' default_app_config = 'chunks.apps.ChunksAppConfig' From ab463141d7d3e52fa59cfec5834321acce4dc57b Mon Sep 17 00:00:00 2001 From: Ilya Basyrov <63291720+ilyabasicboy@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:25:40 +0500 Subject: [PATCH 20/20] added_missing_migration --- .../0003_auto__chg_field_chunk_description.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 chunks/migrations/0003_auto__chg_field_chunk_description.py diff --git a/chunks/migrations/0003_auto__chg_field_chunk_description.py b/chunks/migrations/0003_auto__chg_field_chunk_description.py new file mode 100644 index 0000000..bad560e --- /dev/null +++ b/chunks/migrations/0003_auto__chg_field_chunk_description.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'Chunk.description' + db.alter_column('chunks_chunk', 'description', self.gf('django.db.models.fields.TextField')()) + + def backwards(self, orm): + + # Changing field 'Chunk.description' + db.alter_column('chunks_chunk', 'description', self.gf('django.db.models.fields.CharField')(max_length=255)) + + models = { + 'chunks.chunk': { + 'Meta': {'object_name': 'Chunk'}, + 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) + } + } + + complete_apps = ['chunks'] \ No newline at end of file