Commits

Anonymous committed 5f0766f

Templates and fixes

Comments (0)

Files changed (5)

         return item.name
     
     def item_content(self, item):
-        return {"type": "html"}, item.text
+        if item.is_image():
+            return {"type": "html"}, u"<img src="%s" alt=""/><br/>\n%s" % (item.file.url, item.text)
+        else:
+            return {"type": "html"}, item.text
     
     def item_updated(self, item):
         return item.publish_date
     def set_mime(self, mime):
         obj, created = MimeType.objects.get_or_create(name=mime, slug=slugify(mime))
         self.mime = obj
+    
+    def is_image(self):
+        if self.mime.name in ['image/png', 'image/jpeg', 'image/gif']:
+            return True
 
     @permalink
     def get_absolute_url(self):

templates/mediatr/item_detail.html

+{% extends "base.html" %}
+{% if object.stream %}
+{% block stream %}
+<div id="stream-meta">
+<h1><a href="{% url stream_page object.stream.slug %}">{{ object.stream.name }}</a></h1>
+<p>{{ object.stream.description|safe }}</p>
+</div>
+{% endif %}
+<dic id="stream-item">
+    {% if object.is_image %}
+    <a href="{% url stream_item object.slug %}"><img src="{{ object.file.url }}" alt="{{ object.name }}" /></a>
+    <h2 class="stream-item-title"><a href="{% url stream_item object.slug %}">{{ object.name }}</a></h2>
+    <p class="stream-item-descr">{{ object.text|safe }}</p>
+    {% else %}
+    <h2 class="stream-item-title"><a href="{% url stream_item object.slug %}">{{ object.name }}</a></h2>
+    <p class="stream-item-descr">{{ object.text|safe }}</p>
+    <p class="stream-item-attach"><a href="{{ object.file.url }}">Download enclosure.</a></p>
+    {% endif %}
+</div>
+{% endblock %}

templates/mediatr/item_list.html

+{% extends "base.html" %}
+{% block stream %}
+<div id="stream-meta">
+<h1><a href="{% url stream_page stream.slug %}">{{ stream.name }}</a></h1>
+<p>{{ stream.description|safe }}</p>
+</div>
+<ul id="stream-items">
+{% for i in object_list %}
+    <li>
+    {% if i.is_image %}
+    <a href="{% url stream_item i.slug %}"><img src="{{ i.file.url }}" alt="{{ i.name }}" /></a>
+    <h2 class="stream-item-title"><a href="{% url stream_item i.slug %}">{{ i.name }}</a></h2>
+    <p class="stream-item-descr">{{ i.text|safe }}</p>
+    {% else %}
+    <h2 class="stream-item-title"><a href="{% url stream_item i.slug %}">{{ i.name }}</a></h2>
+    <p class="stream-item-descr">{{ i.text|safe }}</p>
+    <p class="stream-item-attach"><a href="{{ i.file.url }}">Download enclosure.</a></p>
+    {% endif %}
+    </li>
+{% endfor %}
+</ul>
+{% endblock %}
     params = dict()
     params['queryset'] = stream.items.filter(publish_date__lte=datetime.now())
     params['paginate_by'] = settings.PAGINATE_BY
+    params['extra_context'] = {'stream': stream}
     return object_list(request, **params)
 
 def item(request, slug):