little optimisation to avoid guardian request when not necessary.
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html Wed Mar 13 18:14:24 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/projectslist.html Fri Mar 15 12:31:24 2013 +0100
@@ -21,20 +21,27 @@
{% url ldt.ldt_utils.views.json.project_json_id project.ldt_id as json_url_id %}
{% if is_gecko %}
<td class="cellimg"><div class="cellimgdiv"><a href="{% url index_project_full project.ldt_id %}">
- {% if project.change and project.state != 2 %}
+ {% if project.change or project.owner == user %}
+ {% if project.state != 2 %}
<img src='{% absstatic "ldt/img/page_edit.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
+ {% else %}
+ <img src='{% absstatic "ldt/img/page_eye.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
+ {% endif %}
{% else %}
<img src='{% absstatic "ldt/img/page_eye.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
{% endif %}
</a></div></td>
{% else %}
<td class="cellimg"><div class="cellimgdiv"><a href="{% url index_project project.ldt_id %}" class="ldt_link_open_ldt">
- {% if project.change and project.state != 2 %}
+ {% if project.change or project.owner == user %}
+ {% if project.state != 2 %}
<img src='{% absstatic "ldt/img/page_edit.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
+ {% else %}
+ <img src='{% absstatic "ldt/img/page_eye.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
+ {% endif %}
{% else %}
<img src='{% absstatic "ldt/img/page_eye.png" %}' alt="{% trans 'open ldt' %}" title="{% trans 'open ldt' %}"/>
{% endif %}
-
</a></div></td>
{% endif %}
@@ -46,9 +53,9 @@
</td>
<td class="cellimg">
{% ifequal project.state 2 %}
- <img src='{% absstatic "ldt/img/icon-yes.gif" %}' {% if project.change %} alt="{% trans 'Project published, click to unpublish' %}" title="{% trans 'Project published, click to unpublish' %}" class="publishedproject qtiplink" {% else %} class="qtiplink" title="{% trans "You are not allowed to change this project" %}"{% endif %} id="project_{{project.ldt_id}}" /></div>
+ <img src='{% absstatic "ldt/img/icon-yes.gif" %}' {% if project.change or project.owner == user %} alt="{% trans 'Project published, click to unpublish' %}" title="{% trans 'Project published, click to unpublish' %}" class="publishedproject qtiplink" {% else %} class="qtiplink" title="{% trans "You are not allowed to change this project" %}"{% endif %} id="project_{{project.ldt_id}}" /></div>
{% else %}
- <img src='{% absstatic "ldt/img/icon-no.gif" %}' {% if project.change %} alt="{% trans 'Project not published, click to publish' %}" title="{% trans 'Project not published, click to publish' %}" class="unpublishedproject qtiplink" {% else %} class="qtiplink" title="{% trans "You are not allowed to change this project" %}"{% endif %}id="project_{{project.ldt_id}}" />
+ <img src='{% absstatic "ldt/img/icon-no.gif" %}' {% if project.change or project.owner == user %} alt="{% trans 'Project not published, click to publish' %}" title="{% trans 'Project not published, click to publish' %}" class="unpublishedproject qtiplink" {% else %} class="qtiplink" title="{% trans "You are not allowed to change this project" %}"{% endif %}id="project_{{project.ldt_id}}" />
{% endifequal %}
</td>
<td>{% thumbnail project.image "50x50" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %} {% endthumbnail %}</td>
@@ -56,7 +63,7 @@
{% if project.state == 2 %}
<span class="projecttitlelink infostooltip" data-title="{{ project.title }}" data-desc="{{ project.description|linebreaksbr }}" >{% if show_username %}{{ project.owner.username }} : {% endif %}{{ project.title }}</span>
{% else %}
- {% if project.change %}
+ {% if project.change or project.owner == user %}
<a class="projecttitlelink" href="{% url ldt.ldt_utils.views.project.update_project ldt_id=project.ldt_id %}"><span class="infostooltip" data-title="{{ project.title }}" data-desc="{{ project.description|linebreaksbr }}" >{% if show_username %}{{ project.owner.username }} : {% endif %}{{ project.title }}</span></a>
{% else %}
<a class="projecttitlelink"><span class="qtiplink" title="{% trans "You are not allowed to change this project" %}">{% if show_username %}{{ project.owner.username }} : {% endif %}{{ project.title }}</span></a>
--- a/src/ldt/ldt/ldt_utils/urls.py Wed Mar 13 18:14:24 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py Fri Mar 15 12:31:24 2013 +0100
@@ -28,11 +28,11 @@
url(r'^cljson/idcutting/(?P<id>.*)/(?P<cutting_id>.*)$', 'views.json.project_json_cutting_id'),
url(r'^rdf/id/(?P<ldt_id>.*)$', 'views.rdf.project_annotations_rdf'),
url(r'^workspace/?$', "views.workspace.home", name="root-view"),
- url(r'^filterprojects/_(?P<filter>[\w\%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)$', "views.project.projects_filter",),
- url(r'^filterprojects/_(?P<filter>[\w\%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)/(?P<id_group>.*)$', "views.project.projects_filter",),
- url(r'^filtercontents/_(?P<filter_c>[\w\%\_\-\+]*?)/$', "views.content.contents_filter",),
- url(r'^filtergroups/_(?P<filter>[\w\%\_\-\+]*?)/$', "views.group.groups_filter",),
- url(r'filtershare/_(?P<filter>[\w\%\_\-\+]*?)/(?P<use_groups>true|false)$', "views.workspace.share_filter"),
+ url(r'^filterprojects/_(?P<filter>[\w \%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)$', "views.project.projects_filter",),
+ url(r'^filterprojects/_(?P<filter>[\w \%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)/(?P<id_group>.*)$', "views.project.projects_filter",),
+ url(r'^filtercontents/_(?P<filter_c>[\w \%\_\-\+]*?)/$', "views.content.contents_filter",),
+ url(r'^filtergroups/_(?P<filter>[\w \%\_\-\+]*?)/$', "views.group.groups_filter",),
+ url(r'filtershare/_(?P<filter>[\w \%\_\-\+]*?)/(?P<use_groups>true|false)$', "views.workspace.share_filter"),
url(r'^embedpopup/?$', "views.workspace.popup_embed"),
url(r'^embediframe/?$', "views.workspace.iframe_embed", name="embediframe_page"),
url(r'^segment/(?P<project_id>.*)/(?P<content_id>.*)/(?P<ensemble_id>.*)/(?P<cutting_id>.*)/(?P<segment_id>.*)/$', 'views.lignesdetemps.index_segment'),
--- a/src/ldt/ldt/ldt_utils/views/project.py Wed Mar 13 18:14:24 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/project.py Fri Mar 15 12:31:24 2013 +0100
@@ -235,8 +235,10 @@
if id_group > 0: # Search inside a group
grp = Group.objects.get(id=id_group)
project_list = get_objects_for_group(grp, 'ldt_utils.view_project').filter(query)
+ project_list = add_change_attr(request.user, project_list)
elif id_group == -1:# Search inside projects shared with a specific user
project_list = get_objects_for_user(request.user, 'ldt_utils.view_project', use_groups=False).exclude(owner=request.user)
+ project_list = add_change_attr(request.user, project_list)
else:
# We paginate in these cases : user's project or published
if status==2:
@@ -248,8 +250,6 @@
project_list = project_list[(num_page*settings.LDT_MAX_PROJECTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_PROJECTS_PER_PAGE)] #@UndefinedVariable
show_username = False
- project_list = add_change_attr(request.user, project_list)
-
if status == 2:
url_templ = "ldt/ldt_utils/partial/publishedprojectslist.html"
else: