from django.contrib import admin
-from chunks.models import Chunk
+from chunks.models import Chunk, Attachment
class ChunkAdmin(admin.ModelAdmin):
admin.site.register(Chunk, ChunkAdmin)
+
+class AttachmentAdmin(admin.ModelAdmin):
+ list_display = ('key',)
+ search_fields = ('key',)
+
+admin.site.register(Attachment, AttachmentAdmin)
\ No newline at end of file
verbose_name_plural = _('chunks')
def __unicode__(self):
- return u'%s' % (self.key,)
+ return self.key
+
+
+class Attachment(models.Model):
+ key = models.CharField(_('key'), help_text=_('A unique name for this attachment'), primary_key=True, max_length=255)
+ attachment = models.FileField(upload_to='chunks/attachment')
+
+ class Meta:
+ ordering = ('key',)
+ verbose_name, verbose_name_plural = _('attachment'), _('attachments')
+
+ def __unicode__(self):
+ return self.key
from django.db import models
from django.core.cache import cache
+
register = template.Library()
Chunk = models.get_model('chunks', 'chunk')
-CACHE_PREFIX = "chunk_"
+Attachment = models.get_model('chunks', 'attachment')
+
def do_get_chunk(parser, token):
# split_contents() knows not to split quoted strings.
# 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
def render(self, context):
try:
- cache_key = CACHE_PREFIX + self.key
+ cache_key = 'chunk_' + self.key
c = cache.get(cache_key)
if c is None:
c = Chunk.objects.get(key=self.key)
return content
register.tag('chunk', do_get_chunk)
+
+
+def attachment(key, cache_time=0):
+ try:
+ cache_key = 'attachment_' + key
+ c = cache.get(cache_key)
+ if c is None:
+ c = Attachment.objects.get(key=key)
+ cache.set(cache_key, c, int(cache_time))
+ return c.attachment.url
+ except Attachment.DoesNotExist:
+ return ''
+
+register.simple_tag(attachment)
+
e-mail: <a href="mailto:fundacja@nowoczesnapolska.org.pl">fundacja@nowoczesnapolska.org.pl</a>
</p>
<p>
- <img src="/media/img/footer.png" usemap="#footermap" alt="Partnerzy serwisu" />
-<MAP NAME="footermap"><AREA SHAPE="rect" COORDS="104,83,261,101" HREF="http://edukacja.gazeta.pl" ALT="GazetaEdukacja.pl - matura, testy, egzaminy, studia" TITLE="GazetaEdukacja.pl - matura, testy, egzaminy, studia"><AREA SHAPE="rect" COORDS="539,38,656,73" ALT="Kurier Wileński" HREF="http://www.kurierwilenski.lt/"><AREA SHAPE="rect" COORDS="687,81,789,116" ALT="Radio znad Wilii" HREF="http://www.znadwilii.lt"><AREA SHAPE="rect" COORDS="376,34,520,75" ALT="Ministerstwo Edukacji Narodowej" HREF="http://www.men.gov.pl/"><AREA SHAPE="rect" COORDS="761,59,822,77" ALT="Biblioteka Analiz" HREF="http://www.rynek-ksiazki.pl/"><AREA SHAPE="rect" COORDS="734,55,759,76" ALT="Przekrój" HREF="http://www.przekroj.pl/"><AREA SHAPE="rect" COORDS="695,55,732,76" ALT="TVP Kultura" HREF="http://www.tvp.pl/tvpkultura/"><AREA SHAPE="rect" COORDS="762,35,821,59" ALT="Elle" HREF="http://elle.interia.pl/"><AREA SHAPE="rect" COORDS="659,55,693,77" ALT="Radio TOK.FM" HREF="http://www.tok.fm/"><AREA SHAPE="rect" COORDS="658,35,760,53" ALT="Tygodnik Powszechny" HREF="http://tygodnik.onet.pl/"><AREA SHAPE="rect" COORDS="265,35,366,74" ALT="Ministerstwo Kultury i Dziedzictwa Narodowego" HREF="http://www.mkidn.gov.pl/"><AREA SHAPE="rect" COORDS="222,29,261,83" ALT="Biblioteka Narodowa" HREF="http://www.bn.org.pl/"><AREA SHAPE="rect" COORDS="188,58,217,81" ALT="PZL" HREF="http://www.pzl.pl/"><AREA SHAPE="rect" COORDS="162,32,218,56" ALT="EO Networks" HREF="http://eo.pl/"><AREA SHAPE="rect" COORDS="104,61,184,76" ALT="Kancelaria Prawna Grynhoff Woźny Maliński Spółka komandytowa" HREF="http://www.gww.pl/"><AREA SHAPE="rect" COORDS="104,35,160,60" ALT="Information is art" HREF="http://www.informationisart.com/"><AREA SHAPE="rect" COORDS="15,39,98,75" ALT="Fundacja Nowoczesna Polska" HREF="http://nowoczesnapolska.org.pl/"><AREA SHAPE="default" COORDS="0,0,860,120" NOHREF></MAP>
+ <img src="{% attachment 'footer-img' %}" usemap="#footermap" alt="Partnerzy serwisu" />
+<MAP NAME="footermap">{% chunk 'footer-map' %}</MAP>
</p>
</div>