forked from rc/aircox
		
	rename 'item' in list_item template into 'object' to be more django compliant
This commit is contained in:
		@ -317,6 +317,7 @@ class RelatedMeta (models.base.ModelBase):
 | 
				
			|||||||
            elif rel.auto_create(instance) if callable(rel.auto_create) else \
 | 
					            elif rel.auto_create(instance) if callable(rel.auto_create) else \
 | 
				
			||||||
                 rel.auto_create:
 | 
					                 rel.auto_create:
 | 
				
			||||||
                post = model(related = instance)
 | 
					                post = model(related = instance)
 | 
				
			||||||
 | 
					                # TODO: hackish way: model.objects.filter(related=null,...).delete()
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            post.rel_to_post()
 | 
					            post.rel_to_post()
 | 
				
			||||||
@ -325,7 +326,6 @@ class RelatedMeta (models.base.ModelBase):
 | 
				
			|||||||
        post_save.connect(handler_rel, model._relation.model, False)
 | 
					        post_save.connect(handler_rel, model._relation.model, False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __new__ (cl, name, bases, attrs):
 | 
					    def __new__ (cl, name, bases, attrs):
 | 
				
			||||||
        # TODO: allow proxy models and better inheritance
 | 
					 | 
				
			||||||
        # TODO: check bindings
 | 
					        # TODO: check bindings
 | 
				
			||||||
        if name == 'RelatedPost':
 | 
					        if name == 'RelatedPost':
 | 
				
			||||||
            return super().__new__(cl, name, bases, attrs)
 | 
					            return super().__new__(cl, name, bases, attrs)
 | 
				
			||||||
@ -348,7 +348,6 @@ class RelatedMeta (models.base.ModelBase):
 | 
				
			|||||||
        name = rel.model._meta.object_name
 | 
					        name = rel.model._meta.object_name
 | 
				
			||||||
        if name == model._meta.object_name:
 | 
					        if name == model._meta.object_name:
 | 
				
			||||||
            model._meta.default_related_name = '{} Post'.format(name)
 | 
					            model._meta.default_related_name = '{} Post'.format(name)
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return model
 | 
					        return model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -401,7 +400,7 @@ class RelatedPost (Post, metaclass = RelatedMeta):
 | 
				
			|||||||
        bindings = None
 | 
					        bindings = None
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        dict of `post_attr: rel_attr` that represent bindings of values
 | 
					        dict of `post_attr: rel_attr` that represent bindings of values
 | 
				
			||||||
        between the post and the related object. Field are updated according
 | 
					        between the post and the related object. Fields are updated according
 | 
				
			||||||
        to `post_to_rel` and `rel_to_post`.
 | 
					        to `post_to_rel` and `rel_to_post`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        If there is a post_attr "thread", the corresponding rel_attr is used
 | 
					        If there is a post_attr "thread", the corresponding rel_attr is used
 | 
				
			||||||
@ -413,6 +412,11 @@ class RelatedPost (Post, metaclass = RelatedMeta):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        note: bound values can be any value, not only Django field.
 | 
					        note: bound values can be any value, not only Django field.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
					        defaults = None
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        dict of `post_attr: value` that gives default value for the given
 | 
				
			||||||
 | 
					        fields.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
        post_to_rel = False
 | 
					        post_to_rel = False
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        update related object when the post is saved, using bindings
 | 
					        update related object when the post is saved, using bindings
 | 
				
			||||||
@ -474,7 +478,6 @@ class RelatedPost (Post, metaclass = RelatedMeta):
 | 
				
			|||||||
        if save:
 | 
					        if save:
 | 
				
			||||||
            self.related.save()
 | 
					            self.related.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def rel_to_post(self, save = True):
 | 
					    def rel_to_post(self, save = True):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Change the post using the related object bound values. Save the
 | 
					        Change the post using the related object bound values. Save the
 | 
				
			||||||
@ -508,13 +511,6 @@ class RelatedPost (Post, metaclass = RelatedMeta):
 | 
				
			|||||||
        if has_changed and save:
 | 
					        if has_changed and save:
 | 
				
			||||||
            self.save()
 | 
					            self.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__ (self, *kargs, **kwargs):
 | 
					 | 
				
			||||||
        super().__init__(*kargs, **kwargs)
 | 
					 | 
				
			||||||
        # we use this method for sync, in order to avoid intrusive code on other
 | 
					 | 
				
			||||||
        # applications, e.g. using signals.
 | 
					 | 
				
			||||||
        if self.pk and self._relation.rel_to_post:
 | 
					 | 
				
			||||||
            self.rel_to_post(False)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def save (self, avoid_sync = False, save = True, *args, **kwargs):
 | 
					    def save (self, avoid_sync = False, save = True, *args, **kwargs):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        * avoid_sync: do not synchronise the post/related object;
 | 
					        * avoid_sync: do not synchronise the post/related object;
 | 
				
			||||||
 | 
				
			|||||||
@ -288,9 +288,6 @@ class List(Section):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        Prepare objects before context is sent to the template renderer.
 | 
					        Prepare objects before context is sent to the template renderer.
 | 
				
			||||||
        Return the object_list that is prepared.
 | 
					        Return the object_list that is prepared.
 | 
				
			||||||
 | 
					 | 
				
			||||||
        Remember: since we are in a rendering process, the items should
 | 
					 | 
				
			||||||
        not be saved.
 | 
					 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        return object_list
 | 
					        return object_list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% block content %}
 | 
					{% block content %}
 | 
				
			||||||
<ul class="content">
 | 
					<ul class="content">
 | 
				
			||||||
{% for item in object_list %}
 | 
					{% for object in object_list %}
 | 
				
			||||||
{% include "aircox/cms/list_item.html" %}
 | 
					{% include "aircox/cms/list_item.html" %}
 | 
				
			||||||
{% empty %}
 | 
					{% empty %}
 | 
				
			||||||
<div class="message empty">
 | 
					<div class="message empty">
 | 
				
			||||||
 | 
				
			|||||||
@ -2,62 +2,62 @@
 | 
				
			|||||||
{% load i18n %}
 | 
					{% load i18n %}
 | 
				
			||||||
{% load thumbnail %}
 | 
					{% load thumbnail %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<li {% if item.css_class %}class="{{ item.css_class }}"{% endif %}
 | 
					<li {% if object.css_class %}class="{{ object.css_class }}"{% endif %}
 | 
				
			||||||
      {% for k, v in item.attrs.items %}
 | 
					      {% for k, v in object.attrs.items %}
 | 
				
			||||||
      {{ k }} = "{{ v|addslashes }}"
 | 
					      {{ k }} = "{{ v|addslashes }}"
 | 
				
			||||||
      {% endfor %} >
 | 
					      {% endfor %} >
 | 
				
			||||||
  {% if item.url %}
 | 
					  {% if object.url %}
 | 
				
			||||||
      <a class="url" href="{{ item.url }}">
 | 
					      <a class="url" href="{{ object.url }}">
 | 
				
			||||||
  {% endif %}
 | 
					  {% endif %}
 | 
				
			||||||
  {% if 'image' in list.fields and item.image %}
 | 
					  {% if 'image' in list.fields and object.image %}
 | 
				
			||||||
  <img class="image" src="{% thumbnail item.image list.image_size crop %}">
 | 
					  <img class="image" src="{% thumbnail object.image list.image_size crop %}">
 | 
				
			||||||
  {% endif %}
 | 
					  {% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <div class="body">
 | 
					  <div class="body">
 | 
				
			||||||
      {% if 'title' in list.fields and item.title %}
 | 
					      {% if 'title' in list.fields and object.title %}
 | 
				
			||||||
      <h2 class="title">{{ item.title }}</h2>
 | 
					      <h2 class="title">{{ object.title }}</h2>
 | 
				
			||||||
      {% endif %}
 | 
					      {% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      {% if 'content' in list.fields and item.content %}
 | 
					      {% if 'content' in list.fields and object.content %}
 | 
				
			||||||
      <div class="content">
 | 
					      <div class="content">
 | 
				
			||||||
          {% if list.truncate %}
 | 
					          {% if list.truncate %}
 | 
				
			||||||
          {{ item.content|striptags|truncatewords:list.truncate }}
 | 
					          {{ object.content|striptags|truncatewords:list.truncate }}
 | 
				
			||||||
          {% else %}
 | 
					          {% else %}
 | 
				
			||||||
          {{ item.content|striptags }}
 | 
					          {{ object.content|striptags }}
 | 
				
			||||||
          {% endif %}
 | 
					          {% endif %}
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      {% endif %}
 | 
					      {% endif %}
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <div class="meta">
 | 
					  <div class="meta">
 | 
				
			||||||
      {% if item.date and 'date' in list.fields or 'time' in list.fields %}
 | 
					      {% if object.date and 'date' in list.fields or 'time' in list.fields %}
 | 
				
			||||||
      <time datetime="{{ item.date }}">
 | 
					      <time datetime="{{ object.date }}">
 | 
				
			||||||
          {% if 'date' in list.fields %}
 | 
					          {% if 'date' in list.fields %}
 | 
				
			||||||
          <span class="date">
 | 
					          <span class="date">
 | 
				
			||||||
              {{ item.date|date:'D. d F' }}
 | 
					              {{ object.date|date:'D. d F' }}
 | 
				
			||||||
          </span>
 | 
					          </span>
 | 
				
			||||||
          {% endif %}
 | 
					          {% endif %}
 | 
				
			||||||
          {% if 'time' in list.fields %}
 | 
					          {% if 'time' in list.fields %}
 | 
				
			||||||
          <span class="time">
 | 
					          <span class="time">
 | 
				
			||||||
              {{ item.date|date:'H:i' }}
 | 
					              {{ object.date|date:'H:i' }}
 | 
				
			||||||
          </span>
 | 
					          </span>
 | 
				
			||||||
          {% endif %}
 | 
					          {% endif %}
 | 
				
			||||||
      </time>
 | 
					      </time>
 | 
				
			||||||
      {% endif %}
 | 
					      {% endif %}
 | 
				
			||||||
      {% if item.author and 'author' in list.fields %}
 | 
					      {% if object.author and 'author' in list.fields %}
 | 
				
			||||||
      <span class="author">
 | 
					      <span class="author">
 | 
				
			||||||
          {{ item.author }}
 | 
					          {{ object.author }}
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
      {% endif %}
 | 
					      {% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      {% if item.info and 'info' in list.fields %}
 | 
					      {% if object.info and 'info' in list.fields %}
 | 
				
			||||||
      <span class="info">
 | 
					      <span class="info">
 | 
				
			||||||
          {{ item.info }}
 | 
					          {{ object.info }}
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
      {% endif %}
 | 
					      {% endif %}
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  {% if item.url %}
 | 
					  {% if object.url %}
 | 
				
			||||||
  </a>
 | 
					  </a>
 | 
				
			||||||
  {% endif %}
 | 
					  {% endif %}
 | 
				
			||||||
</li>
 | 
					</li>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								notes.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								notes.md
									
									
									
									
									
								
							@ -2,12 +2,18 @@
 | 
				
			|||||||
- logs: archive functionnality + track stats for diffusions
 | 
					- logs: archive functionnality + track stats for diffusions
 | 
				
			||||||
- debug/prod configuration
 | 
					- debug/prod configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# TODO ajd
 | 
				
			||||||
 | 
					- website/sections Diffusions/prepare\_object\_list -> sounds
 | 
				
			||||||
 | 
					- players' buttons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# TODO:
 | 
					# TODO:
 | 
				
			||||||
- general:
 | 
					- general:
 | 
				
			||||||
    - timezone shit
 | 
					    - timezone shit
 | 
				
			||||||
    - translation
 | 
					    - translation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- programs:
 | 
					- programs:
 | 
				
			||||||
 | 
					    - schedule changes -> update later diffusions according to the new schedule
 | 
				
			||||||
    - tests:
 | 
					    - tests:
 | 
				
			||||||
        - sound_monitor
 | 
					        - sound_monitor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,13 +32,11 @@
 | 
				
			|||||||
        - cms.exposure; make it right, see nomenclature, + docstring
 | 
					        - cms.exposure; make it right, see nomenclature, + docstring
 | 
				
			||||||
    - admin cms
 | 
					    - admin cms
 | 
				
			||||||
    - sections:
 | 
					    - sections:
 | 
				
			||||||
 | 
					        - calendar title update
 | 
				
			||||||
        - article list with the focus
 | 
					        - article list with the focus
 | 
				
			||||||
            -> set html attribute based on values that are public
 | 
					            -> set html attribute based on values that are public
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- website:
 | 
					- website:
 | 
				
			||||||
    - diff post init:
 | 
					 | 
				
			||||||
        - strftime on title
 | 
					 | 
				
			||||||
        - image?
 | 
					 | 
				
			||||||
    - render schedule does not get the correct list
 | 
					    - render schedule does not get the correct list
 | 
				
			||||||
    - diffusions:
 | 
					    - diffusions:
 | 
				
			||||||
        - filter sounds for undiffused diffusions
 | 
					        - filter sounds for undiffused diffusions
 | 
				
			||||||
@ -44,6 +48,3 @@
 | 
				
			|||||||
        - seek bar
 | 
					        - seek bar
 | 
				
			||||||
    - list of played diffusions and tracks when non-stop;
 | 
					    - list of played diffusions and tracks when non-stop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -101,10 +101,12 @@ class Diffusions(sections.List):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def prepare_object_list(self, object_list):
 | 
					    def prepare_object_list(self, object_list):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        This function just prepare the list of object, in order to have a good
 | 
					        This function just prepare the list of object, in order to:
 | 
				
			||||||
        title
 | 
					        - have a good title
 | 
				
			||||||
 | 
					        - given a stream to listen to if needed
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        for post in object_list:
 | 
					        for post in object_list:
 | 
				
			||||||
 | 
					            # title
 | 
				
			||||||
            if not hasattr(post, 'related') or \
 | 
					            if not hasattr(post, 'related') or \
 | 
				
			||||||
                    not hasattr(post.related , 'program'):
 | 
					                    not hasattr(post.related , 'program'):
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
@ -113,6 +115,7 @@ class Diffusions(sections.List):
 | 
				
			|||||||
                post.title = ': ' + post.title if post.title else \
 | 
					                post.title = ': ' + post.title if post.title else \
 | 
				
			||||||
                            ' // ' + post.related.start.strftime('%A %d %B')
 | 
					                            ' // ' + post.related.start.strftime('%A %d %B')
 | 
				
			||||||
                post.title = name + post.title
 | 
					                post.title = name + post.title
 | 
				
			||||||
 | 
					            # sounds
 | 
				
			||||||
        return object_list
 | 
					        return object_list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_object_list(self):
 | 
					    def get_object_list(self):
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user