Add help_text to gas views
	
		
			
	
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
					Details
				
			
		
	
				
					
				
			
				
	
				continuous-integration/drone/push Build is passing
				
					Details
				
			
		
	This commit is contained in:
		
							parent
							
								
									41f4329fe3
								
							
						
					
					
						commit
						93b0e5e134
					
				| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
from django.contrib.auth.views import LoginView, PasswordChangeView
 | 
			
		||||
from django.shortcuts import resolve_url
 | 
			
		||||
from django.urls import reverse_lazy
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.views.generic import TemplateView
 | 
			
		||||
 | 
			
		||||
from gas.views import GASMixin
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +18,8 @@ class GASLoginView(LoginView):
 | 
			
		|||
class GASPasswordChangeView(GASMixin, PasswordChangeView):
 | 
			
		||||
    template_name = 'gas/base_form.html'
 | 
			
		||||
    success_url = reverse_lazy('gas:index')
 | 
			
		||||
 | 
			
		||||
    title = _('Change your password')
 | 
			
		||||
    success_message = _('Password changed.')
 | 
			
		||||
 | 
			
		||||
class Index(GASMixin, TemplateView):
 | 
			
		||||
    main_menu = 'index'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ class BaseMixin:
 | 
			
		|||
class UserList(BaseMixin, gviews.GASListView):
 | 
			
		||||
    template_name = 'gas/users/user_list.html'
 | 
			
		||||
    title = _('Users')
 | 
			
		||||
    help_text = _('Manage users and set roles.')
 | 
			
		||||
    actions = [
 | 
			
		||||
        (reverse_lazy('gas:user_create'), 'fa-plus', _('New user')),
 | 
			
		||||
    ]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,6 +67,13 @@
 | 
			
		|||
                        {% endfor %}
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
 | 
			
		||||
                {% block help_text %}
 | 
			
		||||
                    {% if help_text %}
 | 
			
		||||
                        <p>{{ help_text }}</p>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endblock %}
 | 
			
		||||
 | 
			
		||||
                {% block content %}
 | 
			
		||||
                {% endblock %}
 | 
			
		||||
            </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -193,6 +193,7 @@ class GASMixinTestCase(TestCase):
 | 
			
		|||
        class SampleView(gviews.GASMixin, TemplateView):
 | 
			
		||||
            title = 'title'
 | 
			
		||||
            header_title = 'header title'
 | 
			
		||||
            help_text = 'help text'
 | 
			
		||||
            breadcrumbs = [
 | 
			
		||||
                ('url', 'label'),
 | 
			
		||||
            ]
 | 
			
		||||
| 
						 | 
				
			
			@ -204,6 +205,7 @@ class GASMixinTestCase(TestCase):
 | 
			
		|||
        response = view(request)
 | 
			
		||||
        self.assertEqual(response.context_data['title'], SampleView.title)
 | 
			
		||||
        self.assertEqual(response.context_data['header_title'], SampleView.header_title)
 | 
			
		||||
        self.assertEqual(response.context_data['help_text'], SampleView.help_text)
 | 
			
		||||
        self.assertEqual(response.context_data['base_template'], SampleView.base_template)
 | 
			
		||||
        self.assertEqual(response.context_data['breadcrumbs'], SampleView.breadcrumbs)
 | 
			
		||||
        self.assertEqual(response.context_data['gas_title'], gas_settings.TITLE)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,6 +41,7 @@ class GASMixin:
 | 
			
		|||
    continue_url = None
 | 
			
		||||
    header_title = ''
 | 
			
		||||
    title = ''
 | 
			
		||||
    help_text = ''
 | 
			
		||||
    success_message = _("Operation successful.")
 | 
			
		||||
    breadcrumbs = []
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +85,10 @@ class GASMixin:
 | 
			
		|||
        " Contents for page title. "
 | 
			
		||||
        return self.title
 | 
			
		||||
 | 
			
		||||
    def get_help_text(self):
 | 
			
		||||
        " Contents for page help. "
 | 
			
		||||
        return self.help_text
 | 
			
		||||
 | 
			
		||||
    def get_breadcrumbs(self):
 | 
			
		||||
        " Returns a list of (url, label) tuples for the breadcrumbs "
 | 
			
		||||
        return self.breadcrumbs
 | 
			
		||||
| 
						 | 
				
			
			@ -94,6 +99,7 @@ class GASMixin:
 | 
			
		|||
            'base_template': self.base_template,
 | 
			
		||||
            'header_title': self.get_header_title(),
 | 
			
		||||
            'title': self.get_title(),
 | 
			
		||||
            'help_text': self.get_help_text(),
 | 
			
		||||
            'breadcrumbs': self.get_breadcrumbs(),
 | 
			
		||||
            'gas_title': gas_settings.TITLE,
 | 
			
		||||
            'logo_static_url': gas_settings.LOGO,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue