Merge branch 'master' into feat-raise-404-if-anon

This commit is contained in:
Manuel Saelices 2017-10-04 03:46:28 +02:00 committed by GitHub
commit 36d4b7ec0d
18 changed files with 208 additions and 101 deletions

View File

@ -2,15 +2,12 @@ language: python
python:
- "2.7"
- 3.4.4
- "3.4"
- "3.5"
- "3.6"
env:
- DJANGO=1.8.18
- DJANGO=1.9.13
- DJANGO=1.10.7
- DJANGO=1.11
- DJANGO=1.11.4
install:
- pip install -q Django==$DJANGO

View File

@ -13,43 +13,54 @@ https://github.com/django-helpdesk/django-helpdesk
Licensing
---------
All contributions to django-helpdesk must be under the BSD license documented in
the LICENSE file in the top-level directory of this project.
All contributions to django-helpdesk *must* be under the BSD license documented
in the LICENSE file in the top-level directory of this project.
By submitting a contribution to this project (in any way: via e-mail,
via GitHub forks, attachments, etc), you acknowledge that your contribution is
open-source and licensed under the BSD license.
via GitHub pull requests, ticket attachments, etc), you acknowledge that your
contribution is open-source and licensed under the BSD license.
If you or your organisation does not accept these license terms then we cannot
accept your contribution. Please reconsider!
Translations
------------
Ways to Contribute
------------------
Although django-helpdesk has originally been written for the English language,
there are already multiple translations to Spanish, Polish, German and Russian.
More translations are welcomed!
We're happy to include any type of contribution! This can be:
Translations are handled using the excellent Transifex service which is much
easier for most users than manually editing .po files. It also allows
collaborative translation. If you want to help translate django-helpdesk into
languages other than English, we encourage you to make use of our Transifex
project:
* back-end python/django code development
* front-end web development (HTML/Javascript, especially jQuery)
* language translations
* writing improved documentation and demos
http://www.transifex.net/projects/p/django-helpdesk/resource/core/
More details on each of theses tasks is below.
Once you have translated content via Transifex, please raise an issue on the
project Github page to let us know it's ready to import.
If you have any questions on contributing, please start a discussion on
the GitHub issue tracker at
Code changes
------------
https://github.com/django-helpdesk/django-helpdesk/issues
Please fork the project on GitHub, make your changes, and log a pull request to
get the changes pulled back into the
master branch of the django-helpdesk repository.
Back-end Python/Django
``````````````````````
Please fork the project on GitHub, make your changes, and submit a
pull request back into the appropriate branch of the
django-helpdesk repository.
In general, we use the following git branching scheme:
* `master` always refers to development for the next major release
* major releases are found in their own branches:
* `0.2.x` is the branch for the 0.2 release and any bugfix releases
* `0.1` is the branch for the legacy code; it is no longer supported
If you are submitting a patch for a 0.2 release, apply your pull request
to the `0.2.x` branch. If you are helping develop the next release,
apply your patches to the `master` branch.
Wherever possible please break git commits up into small chunks that are
specific to a single bit of functionality. For example, a commit should not
specific to a single bit of functionality. For example, a commit should *not*
contain both new functionality *and* a bugfix; the new function and the bugfix
should be separate commits wherever possible.
@ -58,16 +69,15 @@ Commit messages should also explain *what*, precisely, has been changed.
All commits should include appropriate new or updated tests; see the Tests
section below for more details.
If you have any questions, please start a discussion on the GitHub issue tracker
at
https://github.com/django-helpdesk/django-helpdesk/issues
If your changes affect the Django models for django-helpdesk, be aware
that your commits should include database schema python scripts; see the
Database Schema Changes section below for more details.
Tests
-----
.....
Currently, test coverage is very low. We're working on increasing this, and to
make life easier we are using `Travis CI` (http://travis-ci.org/) for continuous
make life easier we are using Travis CI (http://travis-ci.org/) for continuous
integration. This means that the test suite is run every time a code change is
made, so we can try and make sure we avoid basic bugs and other regressions.
@ -77,7 +87,7 @@ functionality you just added). Bugfixes should also include new unit tests to
ensure the bug has been fixed.
More significant code refactoring must also include proper integration or
validation tests, to be committed BEFORE the refactoring patches. This is to
validation tests, to be committed *BEFORE* the refactoring patches. This is to
ensure that the refactored code produces the same results as the previous code
base.
@ -93,7 +103,7 @@ start a discussion on the GitHub issue tracker at
https://github.com/django-helpdesk/django-helpdesk/issues
Database schema changes
-----------------------
.......................
As well as making your normal code changes to ``models.py``, please generate a
Django migration file and commit it with your code. You will want to use a
@ -106,3 +116,21 @@ what this migration does, such as *add_priority_options* or *add_basket_table*.
This will add a file to the ``migrations/`` folder, which must be committed to
git with your other code changes.
Translations
````````````
Although django-helpdesk has originally been written for the English language,
there are already multiple translations to Spanish, Polish, German and Russian.
More translations are welcomed!
Translations are handled using the excellent Transifex service which is much
easier for most users than manually editing .po files. It also allows
collaborative translation. If you want to help translate django-helpdesk into
languages other than English, we encourage you to make use of our Transifex
project:
http://www.transifex.net/projects/p/django-helpdesk/resource/core/
Once you have translated content via Transifex, please raise an issue on the
project Github page to let us know it's ready to import.

View File

@ -1,10 +1,13 @@
include README.rst
include CONTRIBUTING.rst
include AUTHORS
include LICENSE*
include requirements.txt
include requirements-testing.txt
recursive-include helpdesk/static/helpdesk *
recursive-include helpdesk/locale *.po *.mo
recursive-include helpdesk/templates *
recursive-include helpdesk/fixtures *.json
recursive-include docs/html *
recursive-include demo *

View File

@ -7,7 +7,7 @@ django-helpdesk - A Django powered ticket tracker for small businesses.
.. image:: https://codecov.io/gh/django-helpdesk/django-helpdesk/branch/master/graph/badge.svg
:target: https://codecov.io/gh/django-helpdesk/django-helpdesk
Copyright 2009- Ross Poulton and contributors. All Rights Reserved.
Copyright 2009-2017 Ross Poulton and django-helpdesk contributors. All Rights Reserved.
See LICENSE for details.
django-helpdesk was formerly known as Jutda Helpdesk, named after the
@ -36,50 +36,61 @@ Demo Quickstart
django-helpdesk includes a basic demo Django project so that you may easily
get started with testing or developing django-helpdesk. The demo project
resides in the demo/ top-level folder.
resides in the `demo/` top-level folder.
It's likely that you can start up a demo project server by running
only the command:
only the command::
sudo make rundemo
then pointing your web browser at localhost:8080.
then pointing your web browser at `localhost:8080`.
For more information and options, please read the demo/README.rst file.
For more information and options, please read the `demo/README.rst` file.
**NOTE REGARDING SQLITE AND SEARCHING:**
The demo project uses sqlite as its database. Sqlite does not allow
The demo project uses `sqlite` as its database. Sqlite does not allow
case-insensitive searches and so the search function may not work as
effectively as it would on other database such as PostgreSQL or MySQL
that does support case-insensitive searches.
For more information, see this note in the Django documentation:
http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching
For more information, see this note_ in the Django documentation.
When you try to do a keyword search using sqlite, a message will be displayed
When you try to do a keyword search using `sqlite`, a message will be displayed
to alert you to this shortcoming. There is no way around it, sorry.
Installation
------------
django-helpdesk requires either Python 2.7 or 3.4+, as well as Django 1.8+.
The recommended combination is Python 3.4+ with Django 1.10.
`django-helpdesk` requires:
You can quickly install the latest stable version of django-helpdesk app via pip:
* Django 1.11.x *only*
* either Python 2.7 or 3.4+
**NOTE REGARDING PYTHON VERSION:**
The recommended combination is Python 3.4+ with Django 1.11.
Support for Python 2 will end in the next versions of both `django-helpdesk`
and Django itself (Django 2.0), so users and developers are encouraged to begin
transitioning to Python 3 if have not already. New projects should definitely
use Python 3!
You can quickly install the latest stable version of `django-helpdesk`
app via `pip`::
pip install django-helpdesk
You may also check out the master branch on GitHub, and install manually:
You may also check out the `master` branch on GitHub, and install manually::
python setup.py install
Either way, you will need to add django-helpdesk to an existing Django project.
Either way, you will need to add `django-helpdesk` to an existing
Django project.
For further installation information see docs/install.html and docs/configuration.html
For further installation information see `docs/install.html`
and `docs/configuration.html`
Upgrading from previous versions
--------------------------------
If you are upgrading from a previous version of django-helpdesk that used
If you are upgrading from a previous version of `django-helpdesk` that used
migrations, get an up to date version of the code base (eg by using
`git pull` or `pip install --upgrade django-helpdesk`) then migrate the database::
@ -90,15 +101,20 @@ Lastly, restart your web server software (eg Apache) or FastCGI instance, to
ensure the latest changes are in use.
Unfortunately we are unable to assist if you are upgrading from a
version of django-helpdesk prior to migrations (ie pre-2011).
version of `django-helpdesk` prior to migrations (ie pre-2011).
You can continue to the 'Initial Configuration' area, if needed.
Contributing
------------
We're happy to include any type of contribution! This can be back-end
python/django code development, front-end web development
(HTML/Javascript, especially jQuery), or even language translations.
We're happy to include any type of contribution! This can be:
For more information on contributing, please see the CONTRIBUTING.rst file.
* back-end python/django code development
* front-end web development (HTML/Javascript, especially jQuery)
* language translations
* writing improved documentation and demos
For more information on contributing, please see the `CONTRIBUTING.rst` file.
.. _note: http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching

View File

@ -73,9 +73,11 @@ Then navigate to the site in a browser as above.
*NOTE ON DJANGO VERISON*
The demo project was also created with Django 1.10
in mind. If you are using a different version of Django,
The demo project was also created with Django 1.11
in mind. If you are using an older version of Django,
slight tweaks might be necessary to make the demo work.
Please remember that we do not currently support any
version of Django other than 1.11.
*NOTE ON ATTACHMENTS*

View File

View File

@ -207,3 +207,8 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# - This is only necessary to make the demo project work, not needed for
# your own projects unless you make your own fixtures
FIXTURE_DIRS = [os.path.join(BASE_DIR, 'fixtures')]
try:
from .local_settings import *
except ImportError:
pass

View File

@ -41,16 +41,16 @@ master_doc = 'index'
# General information about the project.
project = u'django-helpdesk'
copyright = u'2011, Ross Poulton + Contributors'
copyright = u'2011-2017, Ross Poulton + django-helpdesk Contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '0.2'
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '0.2.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -179,7 +179,7 @@ htmlhelp_basename = 'django-helpdeskdoc'
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-helpdesk.tex', u'django-helpdesk Documentation',
u'Ross Poulton + Contributors', 'manual'),
u'Ross Poulton + django-helpdesk Contributors', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -212,5 +212,5 @@ latex_documents = [
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-helpdesk', u'django-helpdesk Documentation',
[u'Ross Poulton + Contributors'], 1)
[u'Ross Poulton + django-helpdesk Contributors'], 1)
]

View File

@ -10,13 +10,13 @@ Contents
:maxdepth: 2
:glob:
license
install
configuration
settings
spam
custom_fields
contributing
license
How Does It Look?
@ -69,7 +69,7 @@ django-helpdesk is released under the BSD license, however it packages 3rd party
Dependencies
------------
1. Python 2.7+ (or 3.4+)
2. Django (1.8 or newer)
1. Python 3.4+ (or 2.7, but deprecated and support will be removed next release)
2. Django 1.11 or newer
3. An existing **working** Django project with database etc. If you cannot log into the Admin, you won't get this product working! This means you **must** run `syncdb` **before** you add ``helpdesk`` to your ``INSTALLED_APPS``.

View File

@ -1,7 +1,27 @@
Installation
============
django-helpdesk installation isn't difficult, but it requires you have a bit of existing know-how about Django.
``django-helpdesk`` installation isn't difficult, but it requires you have a bit of existing know-how about Django.
Prerequisites
-------------
Before getting started, ensure your system meets the following dependencies:
* Python 3.4+, or Python 2.7
* Django 1.11.x (Django 2.0 support is coming in a future release; older
releases such as 1.8-1.10 *may* work, but are not guaranteed. Django's
deprecation policy suggests that any project that worked with 1.8 should
be able to upgrade to 1.11 without any problems)
Ensure any extra Django modules you wish to use are compatible before continuing.
**NOTE**: Python 2.7 support is deprecated in both ``django-helpdesk`` and Django.
Future releases of ``django-helpdesk`` may remove support for Python 2.7,
and Django will no longer support Python 2.7 as of the Django 2.0 release.
It is highly recommended to start new projects using Python 3.4+, or migrate
existing projects to Python 3.4+.
Getting The Code
@ -12,10 +32,10 @@ Installing using PIP
Try using ``pip install django-helpdesk``. Go and have a beer to celebrate Python packaging.
GIT Checkout (Cutting Edge)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Checkout ``master`` from git (Cutting Edge)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you're planning on editing the code or just want to get whatever is the latest and greatest, you can clone the official Git repository with ``git clone git://github.com/django-helpdesk/django-helpdesk.git``
If you're planning on editing the code or just want to get whatever is the latest and greatest, you can clone the official Git repository with ``git clone git://github.com/django-helpdesk/django-helpdesk.git``. We use the ``master`` branch as our development branch for the next major release of ``django-helpdesk``.
Copy the ``helpdesk`` folder into your ``PYTHONPATH``.
@ -63,7 +83,7 @@ errors with trying to create User settings.
This line will have to come *after* any other lines in your urls.py such as those used by the Django admin.
Note that the `helpdesk` namespace is no longer required for Django 1.9 and you can use a different namespace.
Note that the `helpdesk` namespace is no longer required for Django 1.9+ and you can use a different namespace.
However, it is recommended to use the default namespace name for clarity.
3. Create the required database tables.
@ -124,7 +144,7 @@ Upgrading from previous versions
If you are upgrading from a previous version of django-helpdesk that used
migrations, get an up to date version of the code base (eg by using
`git pull` or `pip install --upgrade django-helpdesk`) then migrate the database::
``git pull`` or ``pip install --upgrade django-helpdesk``) then migrate the database::
python manage.py migrate helpdesk --db-dry-run # DB untouched
python manage.py migrate helpdesk

View File

@ -9,18 +9,24 @@ lib.py - Common functions (eg multipart e-mail)
import logging
import mimetypes
import os
from smtplib import SMTPException
try:
# Python 2 support
from base64 import urlsafe_b64encode as b64encode
except ImportError:
from base64 import encodestring as b64encode
# Python 3 support
from base64 import encodebytes as b64encode
try:
# Python 2 support
from base64 import urlsafe_b64decode as b64decode
except ImportError:
from base64 import decodestring as b64decode
# Python 3 support
from base64 import decodebytes as b64decode
from django.conf import settings
from django.db.models import Q
from django.utils import six
from django.utils.encoding import smart_text
from django.utils.safestring import mark_safe
@ -119,15 +125,26 @@ def send_templated_mail(template_name,
for filename, filefield in files:
mime = mimetypes.guess_type(filename)
if mime[0] is not None and mime[0] == "text/plain":
with open(filefield.path, 'r') as file:
content = file.read()
with open(filefield.path, 'r') as attachedfile:
content = attachedfile.read()
msg.attach(filename, content)
else:
with open(filefield.path, 'rb') as file:
content = file.read()
msg.attach(filename, content)
if six.PY3:
msg.attach_file(filefield.path)
else:
with open(filefield.path, 'rb') as attachedfile:
content = attachedfile.read()
msg.attach(filename, content)
return msg.send(fail_silently)
logger.debug('Sending email to: {!r}'.format(recipients))
try:
return msg.send()
except SMTPException:
logger.exception('SMTPException raised while sending email to {}'.format(recipients))
if not fail_silently:
raise e
return 0
def query_to_dict(results, descriptions):

View File

@ -195,7 +195,10 @@ def process_queue(q, logger):
settings.QUEUE_EMAIL_BOX_PASSWORD)
server.select(q.email_box_imap_folder)
status, data = server.search(None, 'NOT', 'DELETED')
try:
status, data = server.search(None, 'NOT', 'DELETED')
except imaplib.IMAP4.error:
logger.error("IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?" % q.email_box_imap_folder)
if data:
msgnums = data[0].split()
logger.info("Received %d messages from IMAP server" % len(msgnums))
@ -338,15 +341,17 @@ def ticket_from_message(message, queue, logger):
ext = mimetypes.guess_extension(part.get_content_type())
name = "part-%i%s" % (counter, ext)
payload = part.get_payload()
if isinstance(payload, list):
payload = payload.pop().as_string()
payloadToWrite = payload
try:
logger.debug("Try to base64 decode the attachment payload")
payloadToWrite = base64.decodestring(payload)
except binascii.Error:
except (binascii.Error, TypeError):
logger.debug("Payload was not base64 encoded, using raw bytes")
payloadToWrite = payload
files.append(SimpleUploadedFile(name, encoding.smart_bytes(payloadToWrite), part.get_content_type()))
logger.info("Found MIME attachment %s" % name)
files.append(SimpleUploadedFile(name, part.get_payload(decode=True), mimetypes.guess_type(name)[0]))
logger.debug("Found MIME attachment %s" % name)
counter += 1
@ -388,9 +393,10 @@ def ticket_from_message(message, queue, logger):
if cc:
# get list of currently CC'd emails
current_cc = TicketCC.objects.filter(ticket=ticket)
current_cc_emails = [x.email for x in current_cc]
# get emails of any Users CC'd to email
current_cc_users = [x.user.email for x in current_cc]
current_cc_emails = [x.email for x in current_cc if x.email]
# get emails of any Users CC'd to email, if defined
# (some Users may not have an associated email, e.g, when using LDAP)
current_cc_users = [x.user.email for x in current_cc if x.user and x.user.email]
# ensure submitter, assigned user, queue email not added
other_emails = [queue.email_address]
if t.submitter_email:
@ -445,7 +451,7 @@ def ticket_from_message(message, queue, logger):
attached = process_attachments(f, files)
for att_file in attached:
logger.info("Attachment '%s' successfully added to ticket from email." % att_file[0])
logger.info("Attachment '%s' (with size %s) successfully added to ticket from email." % (att_file[0], att_file[1].size))
context = safe_template_context(t)

View File

@ -259,6 +259,7 @@ class Queue(models.Model):
blank=True,
null=True,
verbose_name=_('Default owner'),
on_delete=models.SET_NULL,
)
def __str__(self):
@ -339,6 +340,7 @@ class Queue(models.Model):
pass
@python_2_unicode_compatible
class Ticket(models.Model):
"""
To allow a ticket to be entered as quickly as possible, only the

View File

@ -50,7 +50,10 @@ Bootstrap overrides
#searchtabs {margin-bottom: 20px;}
.row_tablehead, table.table caption {background-color: #dbd5d9;}
table.table caption {height: 2em; line-height: 2em; font-weight: bold;}
table.table caption {
padding-left: 2em;
line-height: 2em; font-weight: bold;
}
table.ticket-stats caption {color: #fbff00; font-style: italic;}
table.ticket-stats tbody th, table.ticket-stats tbody tr {padding-left: 20px}

View File

@ -1,4 +1,4 @@
{% load i18n humanize %}
{% load i18n humanize ticket_to_link %}
{% load static from staticfiles %}
<div class="row">

View File

@ -24,6 +24,8 @@ from django.utils.html import escape
from django import forms
from django.utils import timezone
from django.utils import six
from helpdesk.forms import (
TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm,
TicketCCEmailForm, TicketCCUserForm, EditFollowUpForm, TicketDependencyForm
@ -815,7 +817,10 @@ def ticket_list(request):
import json
from helpdesk.lib import b64decode
try:
query_params = json.loads(b64decode(str(saved_query.query)))
if six.PY3:
query_params = json.loads(b64decode(str(saved_query.query)).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)))
except ValueError:
# Query deserialization failed. (E.g. was a pickled query)
return HttpResponseRedirect(reverse('helpdesk:list'))
@ -1112,7 +1117,10 @@ def run_report(request, report):
import json
from helpdesk.lib import b64decode
try:
query_params = json.loads(b64decode(str(saved_query.query)))
if six.PY3:
query_params = json.loads(b64decode(str(saved_query.query)).decode())
else:
query_params = json.loads(b64decode(str(saved_query.query)))
except:
return HttpResponseRedirect(reverse('helpdesk:report_index'))

View File

@ -1,6 +1,7 @@
Django>=1.8
django-bootstrap-form>=3.1,<4
Django>=1.11,<2
django-bootstrap-form>=3.3,<4
email-reply-parser
django-markdown-deux
simplejson
pytz
six

View File

@ -6,7 +6,7 @@ from distutils.util import convert_path
from fnmatch import fnmatchcase
from setuptools import setup, find_packages
version = '0.2.0.2'
version = '0.3.0.1'
# Provided as an attribute, so you can append to these instead
# of replicating them:
@ -128,14 +128,13 @@ setup(
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Framework :: Django",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10",
"Framework :: Django :: 1.11",
"Environment :: Web Environment",
"Operating System :: OS Independent",
@ -150,8 +149,8 @@ setup(
'cases', 'bugs', 'track', 'support'],
author='Ross Poulton',
author_email='ross@rossp.org',
maintainer='Jonathan Barratt',
maintainer_email='jonathan@the-im.com',
maintainer='Garret Wassermann',
maintainer_email='gwasser@gmail.com',
url='https://github.com/django-helpdesk/django-helpdesk',
license='BSD',
packages=find_packages(),