templates: add in-context edition links
This commit is contained in:
		@ -113,6 +113,7 @@ Usefull context:
 | 
			
		||||
                    {% block headings %}
 | 
			
		||||
                    <div>
 | 
			
		||||
                        <h1 class="title is-1 {% block title-class %}{% endblock %}">{% block title %}{{ title|default:"" }}{% endblock %}</h1>
 | 
			
		||||
                        {% include "aircox/edit-link.html" %}
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div>
 | 
			
		||||
                        {% spaceless %}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								aircox/templates/aircox/edit-link.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								aircox/templates/aircox/edit-link.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
{% load aircox i18n %}
 | 
			
		||||
{% block user-actions-container %}
 | 
			
		||||
{% has_perm page page.program.change_permission_codename simple=True as can_edit %}
 | 
			
		||||
{% if user.is_authenticated and can_edit %}
 | 
			
		||||
{% with request.resolver_match.view_name as view_name %}
 | 
			
		||||
   
 | 
			
		||||
  {% if view_name in 'program-edit,bla' %}
 | 
			
		||||
  <!--
 | 
			
		||||
  <a href="{% url 'program-detail' page.slug %}" target="_self">
 | 
			
		||||
      <span title="{% translate 'View' %} {{ page }}">{% translate 'View' %} 👁 </span>
 | 
			
		||||
  </a>
 | 
			
		||||
  -->
 | 
			
		||||
  {% else %}
 | 
			
		||||
  <a href="{% url view_name|edit_view page.pk %}" target="_self">
 | 
			
		||||
      <span title="{% translate 'Edit' %} {{ page }}">{% translate 'Edit' %} 🖉  </span>
 | 
			
		||||
  </a>
 | 
			
		||||
  {% endif %}
 | 
			
		||||
{% endwith %}
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@ -134,3 +134,8 @@ def do_verbose_name(obj, plural=False):
 | 
			
		||||
    if isinstance(obj, str):
 | 
			
		||||
        return obj
 | 
			
		||||
    return obj._meta.verbose_name_plural if plural else obj._meta.verbose_name
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@register.filter(name="edit_view")
 | 
			
		||||
def do_edit_view(obj):
 | 
			
		||||
    return "%s-edit" % obj.split("-")[0]
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user