peeyush-tm / django-cube

Automatically exported from code.google.com/p/django-cube
GNU General Public License v3.0
1 stars 0 forks source link

Query the cube directly in the templates #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It is hard for now to get a value from the cube directly in the templates, 
because of the keys used for dictionnary search :

*find a more convenient key that could also be used in templates
*duplicate this key search by providing another interface that is accessible 
from a template
*write a template tag

Original issue reported on code.google.com by seb...@gmail.com on 10 Jun 2010 at 2:11

GoogleCodeExporter commented 9 years ago

Original comment by seb...@gmail.com on 10 Jun 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Template tags written:
-coords for getting coordinates
-subcube to remove some dimensions

Original comment by seb...@gmail.com on 11 Jun 2010 at 7:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Template tags previously written are not convenient. The right thing to do is : 

1. leave the data filtering and processing to the views
2. find a convenient way of navigating the data in the template. This data is 
potentially regrouped by dimension(s). Maybe check towards teh *regroup* 
standard template tag :

some crappy code I had to write :

    {% regroup teams.measures by userunit as submeasures %}
        {% for team in submeasures %}
        <tr>
            <td>{{ team.grouper }}</td>
            {% if team.list.0.internal == 0 %}
            <td>{{ team.list.0.measure }}</td>
            <td>{{ team.list.1.measure }}</td>
            {% else %}
            <td>{{ team.list.1.measure }}</td>
            <td>{{ team.list.0.measure }}</td>
            {% endif %}
            <td>{{ team.list.0.measure|add:team.list.1.measure }}</td>
        </tr>
        {% endfor %}

Would be better if can do :

{% regroup teams.itercubes by team as teamcubes %}
{% for teamcube in teamcubes %}
<tr>
   <td>{{ teamcube.team }}</td>
   {% regroup teamcube.itercubes by internal as intcubes %}
   {% for intcube in intcubes %}
       <td>{{ intcube.measure }}</td>
       {% endfor %}
   <td>{{ teamcube.measure }}</td>
</tr>
{% endfor %}

Original comment by seb...@gmail.com on 22 Jun 2010 at 1:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Replaced first attempts of tags and filters by one tag "subcubes" and one 
filter "getconstraint".

Example :

<ul>
        {% subcubes musician_cube by name, instrument as m_subcube %}
                <li> {{ m_subcube|getconstraint:"instrument" }}
                <ul>
                    {% subcubes m_subcube by name as i_subcube %}
                    <li>{{ i_subcube|getconstraint:"name" }} : {{ i_subcube.measure }}</li>
                    {% endfor %}
                </ul>
                </li>
        {% endsubcubes %}
        </ul>

    Would for example output : ::

        * Trumpet
            - John : 9
            - Jack : 67
            - Miles : 1
        * Saxophone
            - Jean-michel : 10
            ...

Original comment by seb...@gmail.com on 23 Jun 2010 at 1:27