Commits

Fabio Michelini committed e18625e

Fixed collector.

Comments (0)

Files changed (17)

swingcms/cms/_settings.py

                   'html':(('view','add','change','delete','cut','copy','change status')),
                   'folder':(('view','add','change','delete','cut','copy','change status','edit', \
                              'add article to', 'add event to', 'add image to', 'add file to', \
-                             'add link to', 'add page to', 'add html to', 'add folder to')),
-                             # 'add collage to', 'add collector to'
+                             'add link to', 'add page to', 'add html to', 'add folder to', \
+                             'add collector to')), # 'add collage to',
                   'collage':(('view','add','change','delete','cut','copy','change status','edit')),
-                  'collector':(('view','add','change','delete','cut','copy','change status','edit'))}
+                  'collector':(('view','add','change','delete','cut','copy','change status'))}
 
 # layouts start-up structure for context generation
 LAYOUTS = {'standard':("cms/layout_standard.html", (('plugin','head',None),),
             ("cms/view_collector.html", _("view collector")),
         ),
         'add': (
-            ("cms/add_change_obj.html", _("add collector")),
+            ("cms/add_change_collector.html", _("add collector")),
         ),
         'change': (
-            ("cms/add_change_obj.html", _("change collector")),
-        ),
-        'edit': (
-            ("cms/edit_collector.html", _("edit collector")),
+            ("cms/add_change_collector.html", _("change collector")),
         ),
     },
     'article': {

swingcms/cms/forms.py

 from sys import getsizeof # required python 2.6 or higher
 
 from django import forms
+from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ValidationError
 from django.utils.html import escape, conditional_escape
 from django.utils.translation import ugettext_lazy as _
 from django.forms.util import flatatt
 
 import settings
+from loading import swingcache
 from cms.code import list_to_choices, strip_tags, thumbify
 from cms import models
 
                   'in_navigation', 'in_sitemap', 'template', "keywords", 'description')
 
 
-##################
-##  COLLECTION  ##
-##################
+#################
+##  COLLECTOR  ##
+#################
 
 
 class CollectorForm(BaseContentForm):
                                    max_length=2048, required=False,
                                    widget=forms.Textarea({'rows':20,'cols':80}))
     order_field = forms.ChoiceField(choices=(), initial='dt_addition')
-    param_dt_field = forms.ChoiceField(choices=(), initial='dt_addition')
+    param_dt_field = forms.ChoiceField(choices=(), initial='dt_addition', required=False)
 
     def __init__(self, *args, **kwargs):
 
         super(CollectorForm, self).__init__(*args, **kwargs)
-        self.fields['order_field'].choices = list_to_choices(ALL_FIELD_NAMES)
-        self.fields['param_dt_field'].choices = list_to_choices(swingcms.DATETIME_FIELD_NAMES)
-        self.fields['param_contenttypes'].choices = list_to_choices(settings.COLLECTIBLE)
+        self.fields['order_field'].choices = list_to_choices(swingcache.FIELD_NAMES)
+        self.fields['param_dt_field'].choices = list_to_choices(swingcache.DATETIME_FIELD_NAMES)
         self.fields['param_folders'].choices = models.Folder.objects.all().values_list('id','name')
+        collectible = ContentType.objects.filter(model__in=settings.COLLECTIBLE)
+        self.fields['param_contenttypes'].choices = collectible.values_list('id','name')
 
     class Meta:
 
         model = models.Collector
         fields = ('name', 'title', 'subtitle', 'introduction', 'language', 'order_field',
                   'order_direction', 'limit', 'dt_validity', 'dt_expired', 'categories',
-                  'template', "keywords", 'description',
+                  'template', "keywords", 'description', 'layout',
 
                   'datetime_criterion', 'param_dt_field', 'param_dt_operator', 'param_delta_year',
                   'param_delta_month', 'param_delta_day',

swingcms/cms/models.py

 
     def __unicode__(self):
 
-        return '%s' % self.name
+        return '%s (in %s)' % (self.name, self.scope)
 
 
 class Logger(models.Model):
         if self.list is not None:
             self._init_list()
 
-    def remove_slot(self):
+    def remove_slot(self, y, x):
 
         slot = self.grid[int(y)].pop(int(x))
         if self.list is not None:
 
     # datetime criterion
     datetime_criterion = models.BooleanField(_('datetime criterion'), default=False)
-    param_dt_field = models.CharField(_('datetime field'), max_length=32)
+    param_dt_field = models.CharField(_('datetime field'), max_length=32, blank=True, null=True)
     param_dt_operator = models.CharField(_('datetime operator'), choices=DATETIME_OPERATOR_CHOICES,
-                                         default='minor of', max_length=32)
+                                         default='minor of', max_length=32, blank=True, null=True)
     param_delta_year = models.IntegerField(_('delta year'), choices=DELTA_YEAR, default='0',
-                                           max_length=16)
+                                           max_length=16, blank=True, null=True)
     param_delta_month = models.IntegerField(_('delta month'), choices=DELTA_MONTH, default='0',
-                                            max_length=16)
+                                            max_length=16, blank=True, null=True)
     param_delta_day= models.IntegerField(_('delta day'), choices=DELTA_DAY, default='0',
-                                         max_length=16)
+                                         max_length=16, blank=True, null=True)
 
     # category criterion
     category_criterion = models.BooleanField(_('category criterion'), default=False)
     # status criterion
     status_criterion = models.BooleanField(_('status criterion'), default=False)
     param_statuses = models.CharField(_('statuses'), choices=STATUS_CHOICE, default='public',
-                                      max_length=32)
+                                      max_length=32, blank=True, null=True)
 
     def get_contents_list(self, user=None, language=None, caching=False, check_view_perms=True):
 
                 return  cached
 
         # PHASE 1
+        now = datetime.datetime.now()
         if self.datetime_criterion:
-            ref = datetime.datetime.now()
-            date_time = ref + datetime.timedelta(days=self.param_delta_year*365 +
-                                                      self.param_delta_month*30 +
-                                                      self.param_delta_day)
+            ref = now + datetime.timedelta(days=self.param_delta_year * 365 +
+                                           self.param_delta_month * 30 +
+                                           self.param_delta_day)
         contents_phase1 = []
 
-        # if localization criterion specified evaluate folders children with others criteria
+        # if localization criterion specified evaluate folders
+        # children or descendants with others criteria
         if self.localization_criterion:
             children_or_descendants = []
 
             for cd in children_or_descendants:
 
                 # model names criterion
-                if self.contenttype_criterion and cd.model_name not in self.param_contenttypes.all().values_list('model', flat=True):
+                if cd.model_name not in settings.COLLECTIBLE or \
+                self.contenttype_criterion and \
+                cd.model_name not in self.param_contenttypes.all().values_list('model', flat=True):
                     continue
 
                 # status criterion
 
                 # datetime criterion
                 if self.datetime_criterion:
-                    val = getattr(cd, self.param_dt_field, None)
-                    if self.param_dt_operator == 'minor of' and val and not (val < date_time):
+                    dt = getattr(cd, self.param_dt_field, None)
+                    if self.param_dt_operator == 'minor of' and dt and not (dt < ref):
                         continue
-                    elif self.param_dt_operator == 'major of' and val and not (val > date_time):
+                    elif self.param_dt_operator == 'major of' and dt and not (dt > ref):
                         continue
 
                 # category criterion
                 if self.category_criterion and not (set(cd.categories.all()) & set(self.param_categories.all())):
                     continue
+
                 contents_phase1.append(cd)
 
-        # if not localization criterion specified apply queryset filtering
+        # if not localization criterion specified
+        # apply queryset filtering
         else:
 
             # model names criterion
                         op = 'lte'
                     elif self.param_dt_operator == 'major of':
                         op = 'gte'
-                    queryset = queryset.filter(**{"%s__%s" % (self.param_dt_field, op):date_time})
+                    queryset = queryset.filter(**{"%s__%s" % (self.param_dt_field, op):ref})
 
                 # category criterion
                 if self.category_criterion:
-                    queryset = queryset.filter(categories__name__in=self.param_categories.all().values_list('name', flat=True)) # errore: DOPPIO
+                    categories = self.param_categories.all().values_list('name', flat=True)
+                    queryset = queryset.filter(categories__name__in=categories) # distinct verify
 
-                contents_phase1.extend(list(queryset))
+                contents_phase1.extend(queryset)
 
         # PHASE 2
 
         contents_phase2 = []
         count = 0
 
-        # check permissions and language, limit contents, guess and attach preview template path
         for c in contents_phase1:
+
+            # check permissions and language
             if check_view_perms and not has_perm(user, 'view', obj=c):
                 continue
             elif settings.LANGUAGE_RESTRICTED and c.language and language and c.language != language:
                 continue
-            c.template_path = "%s/preview_%s.html" % (c.__module__.split('.')[0], c.model_name)
+            if c.dt_validity and now < c.dt_validity or c.dt_expired and now > c.dt_expired:
+                continue
+
+            # guess and attach preview template path
+            try:
+                c.template_path = settings.TEMPLATES[c.model_name]['preview'][0][0]
+            except KeyError:
+                c.template_path = None
+
+            # append content
             contents_phase2.append(c)
             count += 1
+
+            # limit contents
             if count == self.limit: break
 
         # sort as order_field
-        reverse = (self.order_direction == 'decrescent')
-        try:
-            contents_phase2.sort(key=lambda c: getattr(c, self.order_field), reverse=reverse)
-        except:
-            pass
+        contents_phase2.sort(key=lambda c: getattr(c, self.order_field),
+                             reverse=self.order_direction == 'decrescent')
 
         # cache
         if caching:
             cache.set(cache_key, contents_phase2)
-
+            
         return contents_phase2
 
     def actualize(self, **kwargs):

swingcms/cms/static/cms/css/base.css

 	text-align: left;
 	vertical-align: top;
 	padding-right: 10px;
-    max-width: 120px;
+    max-width: 180px;
 }
 
 form th label {
 	font-size: 10px;
 }
 
+/* collector */
+
+form tr.criterion {
+    padding: 2px;
+    background: #d1d1d1;
+}
+
+#collector .item {
+    width: 400px;
+    margin: 20px 0 20px 0;
+    padding: 20px 0 20px 0;
+    border-bottom: 1px solid #d1d1d1;
+}
 
 /* preview article */
 
 #preview_article {
-	padding: 0px 20px 20px 20px;
-	margin: 0 0 40px 0;
-	height: 345px;
-	width: 611px;
-	background: url("/static/cms/files/box2.png") transparent top left no-repeat;
 }
 
 #preview_article #box_header {
 #preview_article #box_body {
 }
 
-#preview_article #box_body .date {
-	padding: 22px 0 0 10px;
-	width: 160px;
-	font-size: 12px;
-	font-weight: bold;
-}
-
-#preview_article #box_body .title {
-	width: 400px;
-}
-
-#preview_article #box_body .introduction {
-}
-
-#preview_article #box_body .text{
-}
-
-#preview_article #box_body .read_more {
-	margin: 10px 0 0 490px;
-}
-
 #preview_article #box_footer {
 }
 
-
 /* preview event */
 
 #preview_event {
 }
 
+/* preview image */
+
+#preview_image .thumb {
+    float: none;
+}
+
 /* read more */
 
 div.read_more {

swingcms/cms/templates/cms/add_change_collector.html

 
 
 
-<script type="text/javascript">
-    $(document).ready(function() {
-        display_file_input_field_on_change();
-        hide_all_file_input_field();
-    });
-// se contiene Criterion mostra o nascondi se checked o no
-</script>
+<div id='form'>
 
+    {% if introduction %}
+	    {{ introduction }}
+        <br/>
+    {% else %}
+    {% endif %}
 
+    {% blocktrans %}Fields marked with <img src='{{ STATIC_URL }}cms/icons/asterix.png' alt="required"> are required.{% endblocktrans %}<br/>
 
-{% if toolbar %}
+    {% if form.non_field_errors %}
+        <br/>
+        <div class='error'>{{ form.non_field_errors }}</div>
+        <br/>
+    {% else %}
 
-    {% include 'cms/texteditor.html' %}
+        {% if form.errors %}
+            <br/>
+	        <div class='error'>{% trans 'Please correct the error below.' %}</div>
+        {% else %}
+        {% endif %}
 
-{% endif %}
+    {% endif %}
 
 
-{% if introduction %}
-    <br />
-	{{ introduction }}
-    <br />
-{% else %}
 
-{% endif %}
+    <br/>
+    <form enctype="multipart/form-data" method="post" action="" onsubmit="js_single_submit();">
 
-{% blocktrans %}Fields marked with <img src='{{ STATIC_URL }}cms/icons/asterix.png' alt="required"> are required.{% endblocktrans %}<br />
+        {% csrf_token %}
 
-{% if form.errors %}
-    <br />
-	<div class='error'>{% trans 'Please correct the error below.' %}</div>
-    <br />
-{% else %}
+	    <table>
 
-{% endif %}
+		    {% for f in form %}
 
-{% if form.non_field_errors %}
-    <br />
-    <div class='error'>{{ form.non_field_errors }}</div>
-    <br />
-{% else %}
+                <tr><td></td><td>{{ f.errors }}</td></tr>
 
-{% endif %}
+                <tr{% if 'criterion' in f.name %} class='criterion'{% endif %}>
+                    <th>{% if f.label %}<label{% if 'required' in f.css_classes %} class='required' {% endif %}>{{ f.label }}</label>{% endif %}</th>
+                    <td>{{ f.as_widget }}</td>
+                </tr>
 
+                <tr><td></td><td class='help_text'>{{ f.help_text }}<br /><br /></td></tr>
 
-<br />
-<form enctype='multipart/form-data' method='post' action=''>
+            {% endfor %}
 
-    <table>
+	        <tr><td></td><td>
+                <input type="submit" name="submit" value="Submit"
+                {% if require_submit_confirm %}
+                    onclick="return confirm('{% trans "Are you sure?" %}')"
+                {% endif %}>
+            </td></tr>
+            <tr><td></td><td><input type="hidden" name='next' value="{{ next }}"></td></tr>
 
-    {% for f in form %}
+	    </table>
 
-        <tr>
-            {% if 'criterion' in f.name %}
-                <td>
-                    <br />
-                    <br />
-                </td>
-                <td>
-                    <br />
-                    <br />
-                </td>
-            {% else %}
-                <td>
-                </td>
-                <td>
-                    {{ f.errors }}
-                </td>
-            {% endif %}
-        </tr>
+    </form>
 
-        <tr{% if 'required' in f.css_classes and not 'param' in f.name %} class='required' {% endif %}>
+    {% if notes %}
+        <br/>
+	    {{ notes }}
+    {% else %}
+    {% endif %}
 
-            <th>{% if f.label %}
-                <label>
-                    {% if 'criterion' in f.name %}
-                        <b>{{ f.label }}</b>
-                    {% else %}
-                        {{ f.label }}
-                    {% endif %}
-                </label>{% endif %}
-            </th>
-
-            <td>{{ f.as_widget }}</td>
-        </tr>
-
-        <tr><td></td><td>{{ f.help_text }}</td></tr>
-
-    {% endfor %}
-
-    <tr><td></td><td></td></tr>
-	<tr><td></td><td><input type="submit" value="Submit" onclick='js_single_submit()'></td></tr>
-    <tr><td></td><td><input type="hidden" name='request_token' value="{{ request_token }}"></td></tr>
-
-    </table>
-
-</form>
-
-{{ notes }}
+</div>

swingcms/cms/templates/cms/preview_article.html

 <div id='preview_article'>
 
     <div id='obj_header'>
-        {% if o.title %}
-            <h4>{{ o.title }}</h4><br />
+        {% if c.title %}
+            <h4>{{ c.title }}</h4>
         {% endif %}
     </div>
 
-    <h5>{% trans 'added' %}:</h5> <i>{{ o.dt_addition|date:'j F Y' }}</i><br />
-    <h5>{% trans 'by' %}:</h5> <i>{{ o.owner|default:_('unidentified') }}</i><br />
+    <b>{% trans 'added' %}:</b> <i>{{ c.dt_addition|date:'j F Y' }}</i><br />
+    <b>{% trans 'by' %}:</b> <i>{{ c.owner|default:_('unidentified') }}</i><br />
     <br />
 
     <div>
-        {% if o.image_thumb %}
+        {% if c.image_thumb %}
             <div class='thumb'>
-                <a class='fancybox' title='{{ o.title }}' href='{{ o.image.url }}'><img src='{{ o.image_thumb.url }}'  alt='{{ o.name }}'/></a>
+                <a class='fancybox' title='{{ c.title }}' href='{{ c.image.url }}'><img src='{{ c.image_thumb.url }}'  alt='{{ c.name }}'/></a>
             </div>
             <br />
         {% endif %}
 
         <div class='text'>
-            {% if o.introduction %}
-                {{ o.introduction|linebreaks|urlize }}
+            {% if c.introduction %}
+                {{ c.introduction|linebreaks|urlize|truncatewords:30 }}
             {% else %}
-                {{ o.text|safe }}
+                {{ c.text|safe|truncatewords:30 }}
             {% endif %}
         </div>
     </div>
 
     <div id='obj_footer'>
-        <div class='read_more'><a href='/view/article/{{ o.id }}'>{% trans 'read more' %}</a></div>
+        <div class='read_more'><a href='/view/article/{{ c.id }}'>{% trans 'read more' %}</a></div>
     </div>
 
 </div>

swingcms/cms/templates/cms/preview_article_large.html

-{% load cms_filters %}
-{% load i18n %}
-
-
-
-<div id='preview_article'>
-
-    <div id='box_header'>
-    </div>
-
-    <div id='box_body'>
-        <table>
-            <tr>
-                <td class='date'>
-                    {{ obj.dt_addition|date:'j F Y' }}
-                </td>
-                <td class='title'>
-
-                    {% if o.title %}
-                        <h2>{{ o.title }}</h2><br />
-                    {% endif %}
-
-                    {% if o.subtitle %}
-                        <h5>{{ o.subtitle }}</h5><br />
-                    {% endif %}
-
-                    {% if o.categories_list %}
-                        ( {% for cat in o.categories_list %}
-                            {% if forloop.last %}
-                                {{ cat }}
-                            {% else %}
-                                {{ cat }},
-                            {% endif %}
-                        {% endfor %} )<br />
-                        <br />
-                    {% endif %}
-                    
-                    <h5>{% trans 'by' %}:</h5> <i>{{ o.owner.username|default:_('unidentified') }}</i><br />
-                </td>
-            </tr>
-        </table>
-        <br />
-
-        <div>
-            {% if o.image_thumb %}
-                <div class='thumb'>
-                    <a class='fancybox' title='{{ o.title }}' href='{{ o.image.url }}'><img src='{{ o.image_thumb.url }}'  alt='{{ o.name }}'/></a><br />
-                        {% if o.image_caption %}
-                        <span class='caption'>
-                            {{ o.image_caption }}
-                        </span>
-                        {% endif %}
-                </div>
-            {% endif %}
-
-            {% if o.introduction %}
-                <div class='introduction'>{{ o.introduction|linebreaks|urlize|slice:':210' }}...</div><br />
-            {% endif %}
-
-            {% if o.text %}
-                <div class='text'>{{ o.text|safe|slice:':400' }}...</div>
-            {% endif %}
-        </div>
-        
-        <div class='read_more'><a href='/view/article/{{ o.id }}'>{% trans 'read more' %}</a></div>
-    </div>
-
-    <div id='box_footer'>
-    </div>
-
-</div>
-
-
-

swingcms/cms/templates/cms/preview_event.html

 
 <div id='preview_event'>
 
-    {{ o.dt_start|date:'j F Y' }}
+    {{ c.dt_start|date:'j F Y' }}
     <br />
 
-    {% if o.title %}
-        <h4>{{ o.title }}</h4><br/>
+    {% if c.title %}
+        <h4>{{ c.title }}</h4>
     {% endif %}<br />
-    {{ o.location }}<br/>
+
+    {{ c.location }}<br/>
     <br />
 
-    {{ o.description|safe }}<br />
+    {{ c.description|safe }}<br />
 
-    <span class='read_more'><a href='/view/event/{{ o.id }}'>{% trans 'read more' %}</a></span>
+    <div id='obj_footer'>
+        <div class='read_more'><a href='/view/event/{{ c.id }}'>{% trans 'read more' %}</a></div>
+    </div>
 
 </div>
 

swingcms/cms/templates/cms/preview_file.html

 
 <div id='preview_file'>
 
-    {% if o.title %}
-        <h4>{{ o.title }}</h4><br />
-    {% endif %}
-        
-    <h5>{% trans 'published' %}:</h5> <div class="date">{{ o.datetime_addition|date:'j F Y' }}</div><br />
-    <h5>{% trans 'by' %}:</h5> <i>{{ o.contributor }}</i><br />	
-    <h5>{% trans 'size' %}:</h5> <i>{{ o.size|filesizeformat }}</i><br />
+    <div id='obj_header'>
+        {% if c.title %}
+            <h4>{{ c.title }}</h4>
+        {% endif %}
+    </div>
 
-    <a href="{{ o.file.url }}">{% trans 'download' %}</a> {% trans 'or' %} 
-    <span class='read_more'><a href='/view/file/{{ o.id }}'>{% trans 'read more' %}</a></span><br />
+    <b>{% trans 'added' %}:</b> <i>{{ c.dt_addition|date:'j F Y' }}</i><br />
+    <b>{% trans 'by' %}:</b> <i>{{ c.owner|default:_('unidentified') }}</i><br />
+    <b>{% trans 'size' %}:</b> <i>{{ c.size|filesizeformat }}</i><br />
+    <br />
+
+    <a href="{{ c.file.url }}">{% trans 'download' %}</a> {% trans 'or' %} 
+
+    <div id='obj_footer'>
+        <div class='read_more'><a href='/view/file/{{ c.id }}'>{% trans 'read more' %}</a></div>
+    </div>
 
 </div>
 

swingcms/cms/templates/cms/preview_image.html

 
 <div id='preview_image'>
 
-    <div id='item_header'>
-        {% if o.title %}
-            <h4>{{ o.title }}</h4><br />
+    <div id='obj_header'>
+        {% if c.title %}
+            <h4>{{ c.title }}</h4>
         {% endif %}
     </div>
-        
-    <!--
-    <h5>{% trans 'published' %}:</h5> <div class="date">{{ o.datetime_addition|date:'j F Y' }}</div><br />
-    <h5>{% trans 'by' %}:</h5> <c>{{ o.owner }}</c><br />	
-    <h5>{% trans 'size' %}:</h5> <c>{{ o.size|filesizeformat }}</c><br />
-    -->
 
     <div class='thumb'>
-        <a class='fancybox' title='{{ o.title }}' href='{{ o.image.url }}'><img src='{{ o.image_thumb.url }}'  alt='{{ o.name }}'/></a><br />
+        <a class='fancybox' title='{{ c.title }}' href='{{ c.image.url }}'><img src='{{ c.image_thumb.url }}' alt='{{ c.name }}'/></a><br />
     </div>
 
-    <div id='item_footer'>
-        <span class='read_more'><a class='read_more' href='/view/image/{{ o.id }}'>{% trans 'read more' %}</a></span>
+    <div id='obj_footer'>
+        <div class='read_more'><a href='/view/image/{{ c.id }}'>{% trans 'read more' %}</a></div>
     </div>
 
 </div>

swingcms/cms/templates/cms/preview_link.html

 
 <div id='preview_link'>
 
-    <a href='{{ o.link }}'>{{ o.name }}</a>
+    <a href='{{ c.link }}'>{{ c.name }}</a>
 
 </div>
 

swingcms/cms/templates/cms/view_collector.html

 <div id='collector'>
 
     {% if obj.title %}
-        <h2>{{ obj.title }}</h2><br />
+        <h2>{{ obj.title }}</h2>
     {% endif %}
 
-    {% if obj.categories_list %}
-        ({% for cat in obj.categories_list %}
-            {% if forloop.last %}
-                {{ cat }}
+    {% for c in obj.contents %}
+
+        <div class='item'>
+
+            {% if c.template_path %}
+
+                {% include c.template_path %}
+
             {% else %}
-                {{ cat }},
-            {% endif %}
-        {% endfor %})<br />
-        <br />
-    {% endif %}
 
-    {% for o in obj.contents %}
+                <div id='preview_generic'>
 
-        {% if o.template_path %}
-            {% include o.template_path %}
-        {% else %}
+                    <div id='obj_header'>
+                        {% if c.title %}
+                            <h4>{{ c.title }}</h4>
+                        {% endif %}
+                    </div>
 
-            <div id='preview_generic'>
+                    <b>{% trans 'added' %}:</b> <i>{{ c.dt_addition|date:'j F Y' }}</i><br />
+                    <b>{% trans 'by' %}:</b> <i>{{ c.owner|default:'unidentified' }}</i><br />
 
-                <div id='obj_header'>
-                    {% if o.title %}
-                        <h4>{{ o.title }}</h4><br />
-                    {% endif %}
+                    <div id='obj_footer'>
+                        <div class='read_more'><a href='/view/{{ c.mode_name }}/{{ c.id }}'>{% trans 'read more' %}</a></div>
+                    </div>
+
                 </div>
 
-                <h5>{% trans 'added' %}:</h5> <div class="date">{{ o.dt_addition|date:'j F Y' }}</div><br />
-                <h5>{% trans 'by' %}:</h5> <c>{{ o.owner|default:'unidentified' }}</c><br />
-                <br />
+            {% endif %}
 
-                {% if o.image_thumb %}
-                    <div class='thumb'>
-                        <a class='fancybox' title='{{ o.title }}' href='{{ o.image.url }}'><img src='{{ o.image_thumb.url }}' alt='{{ o.name }}'/></a>
-                    </div>
-                    <br />
-                {% endif %}
-
-                <div class='text'>
-                    {% if o.introduction %}
-                        {{ o.introduction|linebreaks|truncatewords:30 }}
-                    {% else %}
-                        {{ o.text|linebreaks|truncatewords:30 }}
-                    {% endif %}
-                </div><br />
-
-                <div id='obj_footer'>
-                    <a class='read_more' href='/view/article/{{ o.id }}'>{% trans 'read more' %}</a>
-                </div>
-
-            </div>
-
-        {% endif %}
-        <br />
+        </div>
 
     {% endfor %}
 

swingcms/cms/templates/cms/view_grid.html

 
     <div id='wr_{{ collage.name }}_{{ forloop.counter0 }}'>
 
-        <table id='table_{{ collage.name }}_{{ forloop.counter0 }}'><tr>    
-            
-            {% for x in y %}          
+        <table id='table_{{ collage.name }}_{{ forloop.counter0 }}'><tr>
 
-                <td id='td_{{ x.css_name }}'>
-                    
+            {% for x in y %}
+
+                <td id='td_{{ forloop.parentloop.counter0 }}_{{ forloop.counter0 }}'>
+
                     {% if not x.obj == None %}
 
                         {% with x.obj as obj %}
 
                             {% endwith %}
 
-                        {% endif %} 
+                        {% endif %}
 
-                    {% endif %}           
+                    {% endif %}
 
                 </td>
 
     </div>
 
 {% endfor %}
-
-
-

swingcms/cms/views.py

     # populate context
     context = locals()
     context.update(context_cacheable)
-
+    
     return render_to_response(layout.template_path, context, context_instance=RequestContext(request))
 
 
             for x in range(len(obj.grid[y])):
                 slot_type = request.POST['type.%s.%s' % (y,x)]
                 slot_css_name = request.POST['css_name.%s.%s' % (y, x)] or None
-                slot_template_path = request.POST['template.%s.%s' % (y,x)] or None
+                slot_template_path = request.POST['template_path.%s.%s' % (y,x)] or None
 
                 # is obj
                 if slot_type == 'obj':
                     slot_obj_model_name = request.POST['obj_model_name_or_plugin_name.%s.%s' % (y,x)]
                     slot_obj_id = request.POST['obj_id.%s.%s' % (y,x)]
                     slot = Slot(type_='obj',
-                                obj_model_name=slot_obj_model_name_or_plugin_name,
+                                obj_model_name=slot_obj_model_name,
                                 obj_id=slot_obj_id,
                                 css_name=slot_css_name,
                                 template_path=slot_template_path)
Add a comment to this file

swingcms/db (copia).db3

Binary file modified.

Binary file modified.

swingcms/loading.py

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-from django.db.models.loading import AppCache
+from django.db import models
 
 
 
 # precalculate frequently used structures that are available only at runtime, extending AppCache
-class SwingCache(AppCache):
+class SwingCache(models.loading.AppCache):
 
     __shared_state_integration = dict(
         _get_contents_cache = [],
         _get_contents_names_cache = [],
         _get_models_names_cache = [],
         _get_models_actions_cache = {},
+        _get_field_names_cache = set(),
+        _get_datetime_field_names_cache = set()
     )
 
     def __init__(self, *args, **kwargs):
         self._get_models_names_cache = [m.__name__.lower() for m in self.get_models()]
         return self._get_models_names_cache
 
-    def get_datetime_field_names():
+    def get_field_names(self):
+
+        if self._get_field_names_cache:
+            return self._get_field_names_cache
+
+        self._populate()
+
+        field_names = set()
+        for c in self.get_contents():
+            for f in c._meta.fields:
+                if not isinstance(f, models.AutoField):
+                    field_names.update((f.name,))
+        self._get_field_names_cache =  sorted(field_names)
+
+        return self._get_field_names_cache
+
+    def get_datetime_field_names(self):
 
         if self._get_datetime_field_names_cache:
             return self._get_datetime_field_names_cache
         self._populate()
 
         datetime_field_names = set()
-        for ct in self.get_contents():
-            for f in ct.model_class()._meta.fields:
-                if isinstance(f, DateTimeField):
+        for c in self.get_contents():
+            for f in c._meta.fields:
+                if isinstance(f, models.DateTimeField):
                     datetime_field_names.update((f.name,))
         self._get_datetime_field_names_cache =  sorted(datetime_field_names)
 
         return self.get_models_names()
 
     @property
+    def FIELD_NAMES(self):
+        return self.get_field_names()
+
+    @property
     def DATETIME_FIELD_NAMES(self):
         return self.get_datetime_field_names()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.