--- a/src/hdalab/templates/profile_home.html Fri Sep 05 12:43:52 2014 +0200
+++ b/src/hdalab/templates/profile_home.html Fri Sep 05 17:05:48 2014 +0200
@@ -45,7 +45,8 @@
<td>{% thumbnail r.image 100x100 as thumb %}<img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" /></td>
<td>{{ hr.state|state_to_str }}</td>
<td>
- <a title="Edit renkan" href="{% url 'renkan_edit' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-pencil"></span></a>
+ {% if hr.state == 1 %}<a title="Edit renkan" href="{% url 'renkan_edit' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-pencil"></span></a>
+ {% else %}<span class="ui-icon ui-icon-blank renkan-basic-action"></span>{% endif %}
<a title="View renkan" href="{% url 'renkan_view' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-eye"></span></a>
<a title="Copy renkan" href="{% url 'renkan_copy' rk_id=r.rk_id %}?next={% url 'profile_home' %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to copy this renkan ?" %}');" ><span class="ui-icon ui-icon-copy"></span></a>
<a title="Remove renkan" href="{% url 'renkan_delete' rk_id=r.rk_id %}?next={% url 'profile_home' %}" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to delete this renkan ? You cannot undo this action." %}');" ><span class="ui-icon ui-icon-trash"></span></a>
--- a/src/hdalab/views/profile.py Fri Sep 05 12:43:52 2014 +0200
+++ b/src/hdalab/views/profile.py Fri Sep 05 17:05:48 2014 +0200
@@ -89,8 +89,8 @@
# If a renkan id is set
rk_id = self.request.GET.get("rk_id", "")
if rk_id!="":
- rk = get_object_or_404(Renkan, rk_id=rk_id)
- if rk.owner!=self.request.user:
+ hr = get_object_or_404(HdalabRenkan.objects.select_related("renkan", "renkan__owner"), renkan__rk_id=rk_id) #.get(=rk_id)
+ if hr.renkan.owner!=self.request.user or hr.state!=HdalabRenkan.EDITION:
raise Exception("You are not allowed to edit this renkan")
form = AuthenticationForm(self.request)
@@ -466,7 +466,12 @@
class HdalabRenkanDelete(View):
def get(self, request, rk_id):
+ try:
+ hr = HdalabRenkan.objects.get(renkan__rk_id=rk_id)
+ except:
+ raise Http404('Renkan not found')
renkan_deleter(request.user, rk_id)
+ hr.delete()
if "next" in request.GET:
return redirect(request.GET["next"])
return redirect(reverse('profile_home'))