Merge 0.2.5 bugfixes and Django 2.0 changes

This commit is contained in:
Garret Wassermann 2017-12-28 07:43:10 -05:00
commit 523329eab5
13 changed files with 59 additions and 37 deletions

View File

@ -194,6 +194,8 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
# static root needs to be defined in order to use collectstatic
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# MEDIA_ROOT is where media uploads are stored.
# We set this to a directory to host file attachments created

View File

@ -13,7 +13,7 @@ project_root = os.path.dirname(here)
NAME = 'django-helpdesk-demodesk'
DESCRIPTION = 'A demo Django project using django-helpdesk'
README = open(os.path.join(here, 'README.rst')).read()
VERSION = '0.2.3'
VERSION = '0.2.5'
#VERSION = open(os.path.join(project_root, 'VERSION')).read().strip()
AUTHOR = 'django-helpdesk team'
URL = 'https://github.com/django-helpdesk/django-helpdesk'

View File

@ -26,9 +26,9 @@ def protect_view(view_func):
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
if not request.user.is_authenticated and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
return HttpResponseRedirect(reverse('helpdesk:login'))
elif not request.user.is_authenticated() and helpdesk_settings.HELPDESK_ANON_ACCESS_RAISES_404:
elif not request.user.is_authenticated and helpdesk_settings.HELPDESK_ANON_ACCESS_RAISES_404:
raise Http404
return view_func(request, *args, **kwargs)

View File

@ -374,7 +374,10 @@ def ticket_from_message(message, queue, logger):
non_b64_err = TypeError
try:
logger.debug("Try to base64 decode the attachment payload")
payloadToWrite = base64.decodestring(payload)
if six.PY2:
payloadToWrite = base64.decodestring(payload)
else:
payloadToWrite = base64.decodebytes(payload)
except non_b64_err:
logger.debug("Payload was not base64 encoded, using raw bytes")
payloadToWrite = payload

View File

@ -140,7 +140,7 @@ class Migration(migrations.Migration):
('votes', models.IntegerField(verbose_name='Votes', default=0, help_text='Total number of votes cast for this item')),
('recommendations', models.IntegerField(verbose_name='Positive Votes', default=0, help_text='Number of votes for this item which were POSITIVE.')),
('last_updated', models.DateTimeField(verbose_name='Last Updated', blank=True, help_text='The date on which this question was most recently changed.')),
('category', models.ForeignKey(verbose_name='Category', to='helpdesk.KBCategory')),
('category', models.ForeignKey(verbose_name='Category', to='helpdesk.KBCategory', on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Knowledge base items',
@ -203,7 +203,7 @@ class Migration(migrations.Migration):
('title', models.CharField(verbose_name='Query Name', help_text='User-provided name for this query', max_length=100)),
('shared', models.BooleanField(verbose_name='Shared With Other Users?', default=False, help_text='Should other users see this query?')),
('query', models.TextField(verbose_name='Search Query', help_text='Pickled query object. Be wary changing this.')),
('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Saved searches',
@ -226,8 +226,8 @@ class Migration(migrations.Migration):
('priority', models.IntegerField(verbose_name='Priority', help_text='1 = Highest Priority, 5 = Low Priority', blank=3, default=3, choices=[(1, '1. Critical'), (2, '2. High'), (3, '3. Normal'), (4, '4. Low'), (5, '5. Very Low')])),
('due_date', models.DateTimeField(null=True, verbose_name='Due on', blank=True)),
('last_escalation', models.DateTimeField(editable=False, null=True, blank=True, help_text='The date this ticket was last escalated - updated automatically by management/commands/escalate_tickets.py.')),
('assigned_to', models.ForeignKey(null=True, verbose_name='Assigned to', blank=True, related_name='assigned_to', to=settings.AUTH_USER_MODEL)),
('queue', models.ForeignKey(verbose_name='Queue', to='helpdesk.Queue')),
('assigned_to', models.ForeignKey(null=True, verbose_name='Assigned to', blank=True, related_name='assigned_to', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('queue', models.ForeignKey(verbose_name='Queue', to='helpdesk.Queue', on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Tickets',
@ -244,8 +244,8 @@ class Migration(migrations.Migration):
('email', models.EmailField(null=True, verbose_name='E-Mail Address', help_text='For non-user followers, enter their e-mail address', blank=True, max_length=75)),
('can_view', models.BooleanField(verbose_name='Can View Ticket?', default=False, help_text='Can this CC login to view the ticket details?')),
('can_update', models.BooleanField(verbose_name='Can Update Ticket?', default=False, help_text='Can this CC login and update the ticket?')),
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket')),
('user', models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, help_text='User who wishes to receive updates for this ticket.')),
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
('user', models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, help_text='User who wishes to receive updates for this ticket.', on_delete=models.CASCADE)),
],
options={
},
@ -258,7 +258,7 @@ class Migration(migrations.Migration):
('field', models.CharField(verbose_name='Field', max_length=100)),
('old_value', models.TextField(null=True, verbose_name='Old Value', blank=True)),
('new_value', models.TextField(null=True, verbose_name='New Value', blank=True)),
('followup', models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp')),
('followup', models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp', on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Ticket changes',
@ -271,8 +271,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
('value', models.TextField(null=True, blank=True)),
('field', models.ForeignKey(verbose_name='Field', to='helpdesk.CustomField')),
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket')),
('field', models.ForeignKey(verbose_name='Field', to='helpdesk.CustomField', on_delete=models.CASCADE)),
('ticket', models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Ticket custom field values',
@ -284,8 +284,8 @@ class Migration(migrations.Migration):
name='TicketDependency',
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
('depends_on', models.ForeignKey(related_name='depends_on', verbose_name='Depends On Ticket', to='helpdesk.Ticket')),
('ticket', models.ForeignKey(related_name='ticketdependency', verbose_name='Ticket', to='helpdesk.Ticket')),
('depends_on', models.ForeignKey(related_name='depends_on', verbose_name='Depends On Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
('ticket', models.ForeignKey(related_name='ticketdependency', verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'Ticket dependencies',
@ -298,7 +298,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
('settings_pickled', models.TextField(null=True, verbose_name='Settings Dictionary', blank=True, help_text='This is a base64-encoded representation of a pickled Python dictionary. Do not change this field via the admin.')),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name_plural': 'User Settings',
@ -325,13 +325,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='followup',
name='ticket',
field=models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket'),
field=models.ForeignKey(verbose_name='Ticket', to='helpdesk.Ticket', on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
model_name='followup',
name='user',
field=models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL),
field=models.ForeignKey(null=True, verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
preserve_default=True,
),
migrations.AddField(
@ -343,7 +343,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='attachment',
name='followup',
field=models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp'),
field=models.ForeignKey(verbose_name='Follow-up', to='helpdesk.FollowUp', on_delete=models.CASCADE),
preserve_default=True,
),
]

View File

@ -18,7 +18,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('queues', models.ManyToManyField(to='helpdesk.Queue', verbose_name='Authorized Queues')),
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Queue Membership',

View File

@ -15,6 +15,8 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='usersettings',
name='user',
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='usersettings_helpdesk'),
field=models.OneToOneField(to=settings.AUTH_USER_MODEL,
related_name='usersettings_helpdesk',
on_delete=models.CASCADE),
),
]

View File

@ -256,11 +256,11 @@ class Queue(models.Model):
default_owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
related_name='default_owner',
blank=True,
null=True,
verbose_name=_('Default owner'),
on_delete=models.SET_NULL,
)
def __str__(self):
@ -388,6 +388,7 @@ class Ticket(models.Model):
queue = models.ForeignKey(
Queue,
on_delete=models.CASCADE,
verbose_name=_('Queue'),
)
@ -413,6 +414,7 @@ class Ticket(models.Model):
assigned_to = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='assigned_to',
blank=True,
null=True,
@ -629,6 +631,7 @@ class FollowUp(models.Model):
ticket = models.ForeignKey(
Ticket,
on_delete=models.CASCADE,
verbose_name=_('Ticket'),
)
@ -660,6 +663,7 @@ class FollowUp(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
blank=True,
null=True,
verbose_name=_('User'),
@ -702,6 +706,7 @@ class TicketChange(models.Model):
followup = models.ForeignKey(
FollowUp,
on_delete=models.CASCADE,
verbose_name=_('Follow-up'),
)
@ -764,6 +769,7 @@ class Attachment(models.Model):
followup = models.ForeignKey(
FollowUp,
on_delete=models.CASCADE,
verbose_name=_('Follow-up'),
)
@ -977,6 +983,7 @@ class KBItem(models.Model):
"""
category = models.ForeignKey(
KBCategory,
on_delete=models.CASCADE,
verbose_name=_('Category'),
)
@ -1050,6 +1057,7 @@ class SavedSearch(models.Model):
"""
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
verbose_name=_('User'),
)
@ -1094,6 +1102,7 @@ class UserSettings(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="usersettings_helpdesk")
settings_pickled = models.TextField(
@ -1255,11 +1264,13 @@ class TicketCC(models.Model):
ticket = models.ForeignKey(
Ticket,
on_delete=models.CASCADE,
verbose_name=_('Ticket'),
)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
blank=True,
null=True,
help_text=_('User who wishes to receive updates for this ticket.'),
@ -1429,11 +1440,13 @@ class CustomField(models.Model):
class TicketCustomFieldValue(models.Model):
ticket = models.ForeignKey(
Ticket,
on_delete=models.CASCADE,
verbose_name=_('Ticket'),
)
field = models.ForeignKey(
CustomField,
on_delete=models.CASCADE,
verbose_name=_('Field'),
)
@ -1462,12 +1475,14 @@ class TicketDependency(models.Model):
ticket = models.ForeignKey(
Ticket,
on_delete=models.CASCADE,
verbose_name=_('Ticket'),
related_name='ticketdependency',
)
depends_on = models.ForeignKey(
Ticket,
on_delete=models.CASCADE,
verbose_name=_('Depends On Ticket'),
related_name='depends_on',
)

View File

@ -1,7 +1,6 @@
/*! jQuery UI - v1.12.1 - 2016-09-14
* http://jqueryui.com
* Includes: core.css, accordion.css, autocomplete.css, menu.css, button.css, controlgroup.css, checkboxradio.css, datepicker.css, dialog.css, draggable.css, resizable.css, progressbar.css, selectable.css, selectmenu.css, slider.css, sortable.css, spinner.css, tabs.css, tooltip.css, theme.css
* To view and modify this theme, visit http://jqueryui.com/themeroller/?bgShadowXPos=&bgOverlayXPos=&bgErrorXPos=&bgHighlightXPos=&bgContentXPos=&bgHeaderXPos=&bgActiveXPos=&bgHoverXPos=&bgDefaultXPos=&bgShadowYPos=&bgOverlayYPos=&bgErrorYPos=&bgHighlightYPos=&bgContentYPos=&bgHeaderYPos=&bgActiveYPos=&bgHoverYPos=&bgDefaultYPos=&bgShadowRepeat=&bgOverlayRepeat=&bgErrorRepeat=&bgHighlightRepeat=&bgContentRepeat=&bgHeaderRepeat=&bgActiveRepeat=&bgHoverRepeat=&bgDefaultRepeat=&iconsHover=url(%22images%2Fui-icons_555555_256x240.png%22)&iconsHighlight=url(%22images%2Fui-icons_777620_256x240.png%22)&iconsHeader=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsError=url(%22images%2Fui-icons_cc0000_256x240.png%22)&iconsDefault=url(%22images%2Fui-icons_777777_256x240.png%22)&iconsContent=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsActive=url(%22images%2Fui-icons_ffffff_256x240.png%22)&bgImgUrlShadow=&bgImgUrlOverlay=&bgImgUrlHover=&bgImgUrlHighlight=&bgImgUrlHeader=&bgImgUrlError=&bgImgUrlDefault=&bgImgUrlContent=&bgImgUrlActive=&opacityFilterShadow=Alpha(Opacity%3D30)&opacityFilterOverlay=Alpha(Opacity%3D30)&opacityShadowPerc=30&opacityOverlayPerc=30&iconColorHover=%23555555&iconColorHighlight=%23777620&iconColorHeader=%23444444&iconColorError=%23cc0000&iconColorDefault=%23777777&iconColorContent=%23444444&iconColorActive=%23ffffff&bgImgOpacityShadow=0&bgImgOpacityOverlay=0&bgImgOpacityError=95&bgImgOpacityHighlight=55&bgImgOpacityContent=75&bgImgOpacityHeader=75&bgImgOpacityActive=65&bgImgOpacityHover=75&bgImgOpacityDefault=75&bgTextureShadow=flat&bgTextureOverlay=flat&bgTextureError=flat&bgTextureHighlight=flat&bgTextureContent=flat&bgTextureHeader=flat&bgTextureActive=flat&bgTextureHover=flat&bgTextureDefault=flat&cornerRadius=3px&fwDefault=normal&ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&cornerRadiusShadow=8px&thicknessShadow=5px&offsetLeftShadow=0px&offsetTopShadow=0px&opacityShadow=.3&bgColorShadow=%23666666&opacityOverlay=.3&bgColorOverlay=%23aaaaaa&fcError=%235f3f3f&borderColorError=%23f1a899&bgColorError=%23fddfdf&fcHighlight=%23777620&borderColorHighlight=%23dad55e&bgColorHighlight=%23fffa90&fcContent=%23333333&borderColorContent=%23dddddd&bgColorContent=%23ffffff&fcHeader=%23333333&borderColorHeader=%23dddddd&bgColorHeader=%23e9e9e9&fcActive=%23ffffff&borderColorActive=%23003eff&bgColorActive=%23007fff&fcHover=%232b2b2b&borderColorHover=%23cccccc&bgColorHover=%23ededed&fcDefault=%23454545&borderColorDefault=%23c5c5c5&bgColorDefault=%23f6f6f6
* Copyright jQuery Foundation and other contributors; Licensed MIT */
/* Layout helpers

View File

@ -92,7 +92,7 @@ class GetEmailParametricTemplate(object):
if self.socks:
from socks import ProxyConnectionError
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
call_command('get_email')
else:
@ -165,7 +165,7 @@ class GetEmailParametricTemplate(object):
if self.socks:
from socks import ProxyConnectionError
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
call_command('get_email')
else:
@ -278,7 +278,7 @@ class GetEmailParametricTemplate(object):
if self.socks:
from socks import ProxyConnectionError
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
call_command('get_email')
else:
@ -525,7 +525,7 @@ a9eiiQ+3V1v+7wWHXCzq
if self.socks:
from socks import ProxyConnectionError
with self.assertRaisesRegexp(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
with self.assertRaisesRegex(ProxyConnectionError, '%s:%s' % (unrouted_socks_server, unused_port)):
call_command('get_email')
else:

View File

@ -22,11 +22,11 @@ from helpdesk.models import Ticket, Queue, UserSettings, KBCategory
@protect_view
def homepage(request):
if not request.user.is_authenticated() and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
if not request.user.is_authenticated and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
return HttpResponseRedirect(reverse('login'))
if is_helpdesk_staff(request.user) or \
(request.user.is_authenticated() and
(request.user.is_authenticated and
helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE):
try:
if request.user.usersettings_helpdesk.settings.get('login_view_ticketlist', False):
@ -64,7 +64,7 @@ def homepage(request):
if queue:
initial_data['queue'] = queue.id
if request.user.is_authenticated() and request.user.email:
if request.user.is_authenticated and request.user.email:
initial_data['submitter_email'] = request.user.email
form = PublicTicketForm(initial=initial_data)

View File

@ -49,14 +49,14 @@ User = get_user_model()
if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
# treat 'normal' users like 'staff'
staff_member_required = user_passes_test(
lambda u: u.is_authenticated() and u.is_active)
lambda u: u.is_authenticated and u.is_active)
else:
staff_member_required = user_passes_test(
lambda u: u.is_authenticated() and u.is_active and u.is_staff)
lambda u: u.is_authenticated and u.is_active and u.is_staff)
superuser_required = user_passes_test(
lambda u: u.is_authenticated() and u.is_active and u.is_superuser)
lambda u: u.is_authenticated and u.is_active and u.is_superuser)
def _get_user_queues(user):
@ -395,7 +395,7 @@ def subscribe_staff_member_to_ticket(ticket, user):
def update_ticket(request, ticket_id, public=False):
if not (public or (
request.user.is_authenticated() and
request.user.is_authenticated and
request.user.is_active and (
is_helpdesk_staff(request.user) or
helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))):
@ -655,7 +655,7 @@ def update_ticket(request, ticket_id, public=False):
ticket.save()
# auto subscribe user if enabled
if helpdesk_settings.HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE and request.user.is_authenticated():
if helpdesk_settings.HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE and request.user.is_authenticated:
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
if SHOW_SUBSCRIBE:
subscribe_staff_member_to_ticket(ticket, request.user)

View File

@ -30,7 +30,8 @@ class QuickDjangoTest(object):
'markdown_deux',
'bootstrapform',
)
MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@ -81,7 +82,7 @@ class QuickDjangoTest(object):
}
},
INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
MIDDLEWARE_CLASSES=self.MIDDLEWARE_CLASSES,
MIDDLEWARE=self.MIDDLEWARE,
ROOT_URLCONF='helpdesk.tests.urls',
STATIC_URL='/static/',
TEMPLATES=self.TEMPLATES