forked from extern/django-helpdesk
Merge 0.2.17 release into develop
This commit is contained in:
commit
7f27eb9428
@ -23,7 +23,8 @@ CLASSIFIERS = ['Development Status :: 4 - Beta',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Framework :: Django :: 2.0',
|
||||
'Framework :: Django :: 2.1']
|
||||
'Framework :: Django :: 2.1',
|
||||
'Framework :: Django :: 2.2']
|
||||
KEYWORDS = []
|
||||
PACKAGES = ['demodesk']
|
||||
REQUIREMENTS = [
|
||||
|
@ -5,4 +5,4 @@ django-helpdesk supports custom fields on the ``Ticket`` model. These fields are
|
||||
|
||||
The demo at http://django-helpdesk-demo.herokuapp.com contains an example of each type of custom field, including a mix of mandatory and optional fields.
|
||||
|
||||
Custom fields are relatively inefficient, and you cannot search by them. They can be useful for tracking extra information that your organisation needs but that isn't supported out of the box.
|
||||
Custom fields are relatively inefficient; you can search them, but this might degrade performance of your installation if you make use of custom fields. They can be useful for tracking extra information that your organisation needs but that isn't supported out of the box.
|
||||
|
@ -7,9 +7,9 @@ Installation
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
Before getting started, ensure your system meets the following dependencies:
|
||||
Before getting started, ensure your system meets the following recommended dependencies:
|
||||
|
||||
* Python 3.5+
|
||||
* Python 3.6+
|
||||
* Django 2.x
|
||||
|
||||
Ensure any extra Django modules you wish to use are compatible before continuing.
|
||||
|
@ -87,7 +87,8 @@ def apply_query(queryset, params):
|
||||
Q(title__icontains=search) |
|
||||
Q(description__icontains=search) |
|
||||
Q(resolution__icontains=search) |
|
||||
Q(submitter_email__icontains=search)
|
||||
Q(submitter_email__icontains=search) |
|
||||
Q(ticketcustomfieldvalue__value__icontains=search)
|
||||
)
|
||||
|
||||
queryset = queryset.filter(qset)
|
||||
|
45
helpdesk/tests/test_login.py
Normal file
45
helpdesk/tests/test_login.py
Normal file
@ -0,0 +1,45 @@
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class TestLoginRedirect(TestCase):
|
||||
|
||||
@override_settings(LOGIN_URL='/custom/login/')
|
||||
def test_custom_login_view_with_url(self):
|
||||
"""Test login redirect when LOGIN_URL is set to custom url"""
|
||||
response = self.client.get(reverse('helpdesk:login'))
|
||||
# We expect that that helpdesk:home url is passed as next parameter in
|
||||
# the redirect url, so that the custom login can redirect the browser
|
||||
# back to helpdesk after the login.
|
||||
home_url = reverse('helpdesk:home')
|
||||
expected = '/custom/login/?next={}'.format(home_url)
|
||||
self.assertRedirects(response, expected, fetch_redirect_response=False)
|
||||
|
||||
@override_settings(LOGIN_URL='/custom/login/')
|
||||
def test_custom_login_next_param(self):
|
||||
"""Test that the next url parameter is correctly relayed to custom login"""
|
||||
next_param = "/redirect/back"
|
||||
url = reverse('helpdesk:login') + "?next=" + next_param
|
||||
response = self.client.get(url)
|
||||
expected = '/custom/login/?next={}'.format(next_param)
|
||||
self.assertRedirects(response, expected, fetch_redirect_response=False)
|
||||
|
||||
@override_settings(LOGIN_URL='helpdesk:login', SITE_ID=1)
|
||||
def test_default_login_view(self):
|
||||
"""Test that default login is used when LOGIN_URL is helpdesk:login"""
|
||||
response = self.client.get(reverse('helpdesk:login'))
|
||||
self.assertTemplateUsed(response, 'helpdesk/registration/login.html')
|
||||
|
||||
@override_settings(LOGIN_URL=None, SITE_ID=1)
|
||||
def test_login_url_none(self):
|
||||
"""Test that default login is used when LOGIN_URL is None"""
|
||||
response = self.client.get(reverse('helpdesk:login'))
|
||||
self.assertTemplateUsed(response, 'helpdesk/registration/login.html')
|
||||
|
||||
@override_settings(LOGIN_URL='admin:login', SITE_ID=1)
|
||||
def test_custom_login_view_with_name(self):
|
||||
"""Test that LOGIN_URL can be a view name"""
|
||||
response = self.client.get(reverse('helpdesk:login'))
|
||||
home_url = reverse('helpdesk:home')
|
||||
expected = reverse('admin:login') + "?next=" + home_url
|
||||
self.assertRedirects(response, expected)
|
@ -1,5 +1,7 @@
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^helpdesk/', include('helpdesk.urls', namespace='helpdesk')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
|
@ -14,7 +14,7 @@ from django.views.generic import TemplateView
|
||||
|
||||
from helpdesk.decorators import helpdesk_staff_member_required, protect_view
|
||||
from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.views import feeds, staff, public, kb
|
||||
from helpdesk.views import feeds, staff, public, kb, login
|
||||
try:
|
||||
import helpdesk.tasks
|
||||
except ImportError:
|
||||
@ -194,8 +194,7 @@ urlpatterns += [
|
||||
|
||||
urlpatterns += [
|
||||
url(r'^login/$',
|
||||
auth_views.LoginView.as_view(
|
||||
template_name='helpdesk/registration/login.html'),
|
||||
login.login,
|
||||
name='login'),
|
||||
|
||||
url(r'^logout/$',
|
||||
|
21
helpdesk/views/login.py
Normal file
21
helpdesk/views/login.py
Normal file
@ -0,0 +1,21 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.shortcuts import resolve_url
|
||||
|
||||
|
||||
default_login_view = auth_views.LoginView.as_view(
|
||||
template_name='helpdesk/registration/login.html')
|
||||
|
||||
|
||||
def login(request):
|
||||
login_url = settings.LOGIN_URL
|
||||
# Prevent redirect loop by checking that LOGIN_URL is not this view's name
|
||||
if login_url and login_url != request.resolver_match.view_name:
|
||||
if 'next' in request.GET:
|
||||
return_to = request.GET['next']
|
||||
else:
|
||||
return_to = resolve_url('helpdesk:home')
|
||||
return redirect_to_login(return_to, login_url)
|
||||
else:
|
||||
return default_login_view(request)
|
Loading…
Reference in New Issue
Block a user