mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-01-13 01:19:00 +01:00
Merge pull request #1119 from timthelion/standalone
Standalone helpdesk installation configuration
This commit is contained in:
commit
658d2b900e
27
README.rst
27
README.rst
@ -19,6 +19,7 @@ contributors reaching far beyond Jutda.
|
|||||||
Complete documentation is available in the docs/ directory,
|
Complete documentation is available in the docs/ directory,
|
||||||
or online at http://django-helpdesk.readthedocs.org/.
|
or online at http://django-helpdesk.readthedocs.org/.
|
||||||
|
|
||||||
|
|
||||||
Demo Quickstart
|
Demo Quickstart
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@ -54,25 +55,19 @@ to alert you to this shortcoming. There is no way around it, sorry.
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
`django-helpdesk` requires:
|
* |standalone_icon| For **standalone** installation, refer to `standalone documentation <./docs/standalone.rst>`_.
|
||||||
|
|
||||||
* Python 3.8+
|
* |django_icon| To **integrate** with an existing Django application, follow the guidelines in `installation documentation <./docs/install.rst>`_ and `configuration documentation <./docs/configuration.rst>`_.
|
||||||
* Django 3.2 LTS or Django 4.*
|
|
||||||
|
|
||||||
You can quickly install the latest stable version of `django-helpdesk`
|
.. |standalone_icon| image:: helpdesk/static/helpdesk/img/icon512.png
|
||||||
app via `pip`::
|
:height: 24px
|
||||||
|
:width: 24px
|
||||||
|
:align: middle
|
||||||
|
|
||||||
pip install django-helpdesk
|
.. |django_icon| image:: helpdesk/static/helpdesk/img/django-logo-positive.png
|
||||||
|
:height: 24px
|
||||||
You may also check out the `master` branch on GitHub, and install manually::
|
:width: 60px
|
||||||
|
:align: middle
|
||||||
python setup.py install
|
|
||||||
|
|
||||||
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`
|
|
||||||
|
|
||||||
Developer Environment
|
Developer Environment
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
For standalone installation, refer to the :doc:`standalone installation docs <standalone>`.
|
||||||
|
|
||||||
``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.
|
||||||
|
|
||||||
|
|
||||||
|
108
docs/standalone.rst
Normal file
108
docs/standalone.rst
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
==============================
|
||||||
|
Django-Helpdesk Standalone Installation
|
||||||
|
==============================
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
1. Clone the django-helpdesk repository:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
git clone git@github.com:django-helpdesk/django-helpdesk.git
|
||||||
|
|
||||||
|
2. Go to the standalone helpdesk installation directory:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
cd django-helpdesk/standalone
|
||||||
|
|
||||||
|
3. Execute the installation script:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
./setup.sh
|
||||||
|
|
||||||
|
4. Start the services:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
Creating an Admin User
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
1. List the running containers:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
docker ps
|
||||||
|
|
||||||
|
2. Execute into the `standalone-django-helpdesk-1` container:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
docker exec -it standalone-django-helpdesk-1 bash
|
||||||
|
|
||||||
|
3. Change directory to the application's root:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
cd /opt/django-helpdesk/standalone
|
||||||
|
|
||||||
|
4. Create a superuser:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
python3 manage.py createsuperuser
|
||||||
|
|
||||||
|
5. Visit `localhost:80` in your browser to access the server. Navigate to the `/admin` URL to set up new users. Ensure to configure the "Site" in the admin section for ticket email URLs to function correctly.
|
||||||
|
|
||||||
|
Configuration for Production Use
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
1. Update the `Caddyfile` to replace the `localhost` URL with your desired production URL.
|
||||||
|
|
||||||
|
2. Modify the `docker-compose` file to adjust the paths. By default, files are stored in `/tmp`.
|
||||||
|
|
||||||
|
3. For custom configurations, bindmount a `local_settings.py` into `/opt/django-helpdesk/standalone/config/local_settings.py`.
|
||||||
|
|
||||||
|
4. To customize the logo in the top-left corner of the helpdesk:
|
||||||
|
|
||||||
|
.. code-block:: html
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.navbar-brand {
|
||||||
|
background: url("https://www.libertyaces.com/files/liberty-logo.png") no-repeat;
|
||||||
|
background-size: auto;
|
||||||
|
width: 320px;
|
||||||
|
background-size: contain;
|
||||||
|
height: 40px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
AWS SES Email Configuration
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
An example `local_settings` configuration for utilizing AWS SES for email:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
DEFAULT_FROM_EMAIL = "support@bitswan.space"
|
||||||
|
SERVER_EMAIL = "support@bitswan.space"
|
||||||
|
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
|
||||||
|
EMAIL_BACKEND = "django_ses.SESBackend"
|
||||||
|
AWS_SES_REGION_NAME = "eu-west-1"
|
||||||
|
AWS_SES_REGION_ENDPOINT = "email.eu-west-1.amazonaws.com"
|
||||||
|
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
||||||
|
|
||||||
|
To integrate `django-ses`, bindmount a file to `/opt/extra-dependencies.txt` containing:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
django-ses
|
||||||
|
|
||||||
|
Ensure to update the `docker.env` file with your necessary secrets.
|
@ -291,6 +291,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
|
|
||||||
except DeleteIgnoredTicketException:
|
except DeleteIgnoredTicketException:
|
||||||
server.store(num, '+FLAGS', '\\Deleted')
|
server.store(num, '+FLAGS', '\\Deleted')
|
||||||
|
server.expunge()
|
||||||
logger.warn("Message %s was ignored and deleted from IMAP server" % num)
|
logger.warn("Message %s was ignored and deleted from IMAP server" % num)
|
||||||
|
|
||||||
except TypeError as te:
|
except TypeError as te:
|
||||||
@ -300,6 +301,7 @@ def imap_oauth_sync(q, logger, server):
|
|||||||
else:
|
else:
|
||||||
if ticket:
|
if ticket:
|
||||||
server.store(num, '+FLAGS', '\\Deleted')
|
server.store(num, '+FLAGS', '\\Deleted')
|
||||||
|
server.expunge()
|
||||||
logger.info(
|
logger.info(
|
||||||
"Successfully processed message %s, deleted from IMAP server" % num)
|
"Successfully processed message %s, deleted from IMAP server" % num)
|
||||||
else:
|
else:
|
||||||
|
BIN
helpdesk/static/helpdesk/img/django-logo-positive.png
Normal file
BIN
helpdesk/static/helpdesk/img/django-logo-positive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
75
helpdesk/static/helpdesk/img/icon.svg
Normal file
75
helpdesk/static/helpdesk/img/icon.svg
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
version="1"
|
||||||
|
viewBox="0 0 48 48"
|
||||||
|
enable-background="new 0 0 48 48"
|
||||||
|
id="svg80"
|
||||||
|
sodipodi:docname="icon.svg"
|
||||||
|
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||||
|
inkscape:export-filename="icon64.png"
|
||||||
|
inkscape:export-xdpi="128"
|
||||||
|
inkscape:export-ydpi="128"
|
||||||
|
width="48"
|
||||||
|
height="48"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs
|
||||||
|
id="defs84" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview82"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="14.723261"
|
||||||
|
inkscape:cx="23.975667"
|
||||||
|
inkscape:cy="21.564517"
|
||||||
|
inkscape:window-width="1918"
|
||||||
|
inkscape:window-height="1078"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg80" />
|
||||||
|
<rect
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.802;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stop-color:#000000"
|
||||||
|
id="rect1275"
|
||||||
|
width="46.454441"
|
||||||
|
height="46.285763"
|
||||||
|
x="0.82081562"
|
||||||
|
y="0.90725207"
|
||||||
|
rx="4.5999999" />
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:39.6725px;line-height:1.25;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Bold';letter-spacing:0px;word-spacing:0px;stroke-width:2.925;stroke-dasharray:none;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal"
|
||||||
|
x="2.4006474"
|
||||||
|
y="34.318501"
|
||||||
|
id="text546"
|
||||||
|
transform="scale(0.94599029,1.0570933)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan544"
|
||||||
|
x="2.4006474"
|
||||||
|
y="34.318501"
|
||||||
|
style="stroke-width:2.925;stroke-dasharray:none;-inkscape-font-specification:'Liberation Mono, Bold';font-family:'Liberation Mono';font-weight:bold;font-style:normal;font-stretch:normal;font-variant:normal;font-size:39.67250061px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">d</tspan></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-style:italic;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:44.6638px;line-height:1.25;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Bold Italic';letter-spacing:0px;word-spacing:0px;fill:#750900;fill-opacity:1;stroke-width:2.3927;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal"
|
||||||
|
x="21.424101"
|
||||||
|
y="-5.6638317"
|
||||||
|
id="text600"
|
||||||
|
transform="matrix(0.94975213,0.00239744,0.00650059,-1.0528899,0,0)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan598"
|
||||||
|
x="21.424101"
|
||||||
|
y="-5.6638317"
|
||||||
|
style="fill:#750900;fill-opacity:1;stroke-width:2.3927;-inkscape-font-specification:'Liberation Mono, Bold Italic';font-family:'Liberation Mono';font-weight:bold;font-style:italic;font-stretch:normal;font-variant:normal;font-size:44.66379929px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">?</tspan></text>
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:2.61108px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 5.9800122,40.433928 36.5608698,0.03139 v 0"
|
||||||
|
id="path651" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
BIN
helpdesk/static/helpdesk/img/icon512.png
Normal file
BIN
helpdesk/static/helpdesk/img/icon512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
helpdesk/static/helpdesk/img/icon64.png
Normal file
BIN
helpdesk/static/helpdesk/img/icon64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
@ -3,3 +3,4 @@ autopep8
|
|||||||
flake8
|
flake8
|
||||||
pycodestyle
|
pycodestyle
|
||||||
isort
|
isort
|
||||||
|
freezegun
|
||||||
|
2
standalone/.gitignore
vendored
Normal file
2
standalone/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
docker.env
|
||||||
|
db
|
3
standalone/Caddyfile
Normal file
3
standalone/Caddyfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
localhost {
|
||||||
|
reverse_proxy django-helpdesk:8000
|
||||||
|
}
|
19
standalone/Dockerfile
Normal file
19
standalone/Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM python:3.10-slim-bullseye
|
||||||
|
LABEL src=https://github.com/django-helpdesk/django-helpdesk
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -yqq \
|
||||||
|
postgresql-common \
|
||||||
|
postgresql-client \
|
||||||
|
cron
|
||||||
|
COPY requirements.txt /opt/django-helpdesk/requirements.txt
|
||||||
|
COPY standalone/extra-requirements.txt /opt/django-helpdesk/standalone/extra-requirements.txt
|
||||||
|
RUN pip3 install -r /opt/django-helpdesk/requirements.txt
|
||||||
|
RUN pip3 install -r /opt/django-helpdesk/standalone/extra-requirements.txt
|
||||||
|
COPY . /opt/django-helpdesk
|
||||||
|
WORKDIR /opt/django-helpdesk
|
||||||
|
RUN pip3 install -e .
|
||||||
|
RUN DJANGO_HELPDESK_SECRET_KEY=foo python3 standalone/manage.py collectstatic
|
||||||
|
|
||||||
|
RUN echo "* * * * * root . /etc/env && /usr/local/bin/python3 /opt/django-helpdesk/standalone/manage.py get_email >> /var/log/cron.log 2>&1" > /etc/crontab
|
||||||
|
RUN chmod 0644 /etc/crontab
|
||||||
|
ENTRYPOINT sh /opt/django-helpdesk/standalone/entrypoint.sh
|
7
standalone/README.md
Normal file
7
standalone/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Django-helpdesk standalone
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
This is a standalone installation of Django-helpdesk allowing you to run django-helpdesk as a production standalone application in docker.
|
||||||
|
|
||||||
|
For installation instructions see [the documentation](../docs/standalone.rst)
|
||||||
|
|
0
standalone/__init__.py
Normal file
0
standalone/__init__.py
Normal file
0
standalone/config/__init__.py
Normal file
0
standalone/config/__init__.py
Normal file
236
standalone/config/settings.py
Normal file
236
standalone/config/settings.py
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
"""
|
||||||
|
Django settings for django-helpdesk demodesk project.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.11/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# Read SECRET_KEY from DJANGO_HELPDESK_SECRET_KEY env var
|
||||||
|
try:
|
||||||
|
SECRET_KEY = os.environ['DJANGO_HELPDESK_SECRET_KEY']
|
||||||
|
except KeyError:
|
||||||
|
raise Exception("DJANGO_HELPDESK_SECRET_KEY environment variable is not set")
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = os.environ.get("DJANGO_HELPDESK_ALLOWED_HOSTS", "*, localhost, 0.0.0.0").split(",")
|
||||||
|
|
||||||
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
SESSION_COOKIE_SECURE = True
|
||||||
|
CSRF_COOKIE_SECURE = True
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'django.contrib.sites',
|
||||||
|
'django.contrib.humanize',
|
||||||
|
'bootstrap4form',
|
||||||
|
'account', # Required by pinax-teams
|
||||||
|
'pinax.invitations', # required by pinax-teams
|
||||||
|
'pinax.teams', # team support
|
||||||
|
'reversion', # required by pinax-teams
|
||||||
|
'helpdesk', # This is us!
|
||||||
|
'rest_framework', # required for the API
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'demo.demodesk.config.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [],
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'debug': True,
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'standalone.config.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# django-helpdesk configuration settings
|
||||||
|
# You can override django-helpdesk's defaults by redefining them here.
|
||||||
|
# To see what settings are available, see the docs/configuration.rst
|
||||||
|
# file for more information.
|
||||||
|
# Some common settings are below.
|
||||||
|
|
||||||
|
HELPDESK_DEFAULT_SETTINGS = {
|
||||||
|
'use_email_as_submitter': os.environ.get('HELPDESK_USE_EMAIL_AS_SUBMITTER', 'True') == 'True',
|
||||||
|
'email_on_ticket_assign': os.environ.get('HELPDESK_EMAIL_ON_TICKET_ASSIGN', 'True') == 'True',
|
||||||
|
'email_on_ticket_change': os.environ.get('HELPDESK_EMAIL_ON_TICKET_CHANGE', 'True') == 'True',
|
||||||
|
'login_view_ticketlist': os.environ.get('HELPDESK_LOGIN_VIEW_TICKETLIST', 'True') == 'True',
|
||||||
|
'email_on_ticket_apichange': os.environ.get('HELPDESK_EMAIL_ON_TICKET_APICHANGE', 'True') == 'True',
|
||||||
|
'preset_replies': os.environ.get('HELPDESK_PRESET_REPLIES', 'True') == 'True',
|
||||||
|
'tickets_per_page': os.environ.get('HELPDESK_TICKETS_PER_PAGE', '25'),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Should the public web portal be enabled?
|
||||||
|
HELPDESK_PUBLIC_ENABLED = os.environ.get('HELPDESK_PUBLIC_ENABLED', 'True') == 'True'
|
||||||
|
HELPDESK_VIEW_A_TICKET_PUBLIC = os.environ.get('HELPDESK_VIEW_A_TICKET_PUBLIC', 'True') == 'True'
|
||||||
|
HELPDESK_SUBMIT_A_TICKET_PUBLIC = os.environ.get('HELPDESK_SUBMIT_A_TICKET_PUBLIC', 'True') == 'True'
|
||||||
|
|
||||||
|
# Should the Knowledgebase be enabled?
|
||||||
|
HELPDESK_KB_ENABLED = os.environ.get('HELPDESK_KB_ENABLED', 'True') == 'True'
|
||||||
|
|
||||||
|
HELPDESK_TICKETS_TIMELINE_ENABLED = os.environ.get('HELPDESK_TICKETS_TIMELINE_ENABLED', 'True') == 'True'
|
||||||
|
|
||||||
|
# Allow users to change their passwords
|
||||||
|
HELPDESK_SHOW_CHANGE_PASSWORD = os.environ.get('HELPDESK_SHOW_CHANGE_PASSWORD', 'True') == 'True'
|
||||||
|
|
||||||
|
# Activate the API
|
||||||
|
HELPDESK_ACTIVATE_API_ENDPOINT = os.environ.get('HELPDESK_ACTIVATE_API_ENDPOINT', 'True') == 'True'
|
||||||
|
|
||||||
|
# Instead of showing the public web portal first,
|
||||||
|
# we can instead redirect users straight to the login page.
|
||||||
|
HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = os.environ.get('HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT', 'False') == 'True'
|
||||||
|
LOGIN_URL = 'helpdesk:login'
|
||||||
|
LOGIN_REDIRECT_URL = 'helpdesk:home'
|
||||||
|
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
# Setup postgress db with postgres as host and db name and read password from env var
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': os.environ.get('POSTGRES_DB', 'postgres'),
|
||||||
|
'USER': os.environ.get('POSTGRES_USER', 'postgres'),
|
||||||
|
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'postgres'),
|
||||||
|
'HOST': os.environ.get('POSTGRES_HOST', 'postgres'),
|
||||||
|
'PORT': os.environ.get('POSTGRES_PORT', '5432'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Sites
|
||||||
|
# - this allows hosting of more than one site from a single server,
|
||||||
|
# in practice you can probably just leave this default if you only
|
||||||
|
# host a single site, but read more in the docs:
|
||||||
|
# https://docs.djangoproject.com/en/1.11/ref/contrib/sites/
|
||||||
|
|
||||||
|
SITE_ID = 1
|
||||||
|
|
||||||
|
|
||||||
|
# Sessions
|
||||||
|
# https://docs.djangoproject.com/en/1.11/topics/http/sessions
|
||||||
|
|
||||||
|
SESSION_COOKIE_AGE = 86400 # = 1 day
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Email
|
||||||
|
# https://docs.djangoproject.com/en/1.11/topics/email/
|
||||||
|
|
||||||
|
# This demo uses the console backend, which simply prints emails to the console
|
||||||
|
# rather than actually sending them out.
|
||||||
|
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'example@example.com')
|
||||||
|
SERVER_EMAIL = os.environ.get('SERVER_EMAIL', 'example@example.com')
|
||||||
|
|
||||||
|
if os.environ.get('EMAIL_HOST', None):
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
try:
|
||||||
|
EMAIL_HOST = os.environ['EMAIL_HOST']
|
||||||
|
except KeyError:
|
||||||
|
raise ImproperlyConfigured('Please set the EMAIL_HOST environment variable.')
|
||||||
|
try:
|
||||||
|
EMAIL_PORT = os.environ['EMAIL_PORT']
|
||||||
|
except KeyError:
|
||||||
|
raise ImproperlyConfigured('Please set the EMAIL_PORT environment variable.')
|
||||||
|
else:
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
||||||
|
|
||||||
|
# By default, django-helpdesk uses en, but other languages are also available.
|
||||||
|
# The most complete translations are: es-MX, ru, zh-Hans
|
||||||
|
# Contribute to our translations via Transifex if you can!
|
||||||
|
# See CONTRIBUTING.rst for more info.
|
||||||
|
LANGUAGE_CODE = 'en-US'
|
||||||
|
|
||||||
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
||||||
|
def normpath(*args):
|
||||||
|
return os.path.normpath(os.path.abspath(os.path.join(*args)))
|
||||||
|
|
||||||
|
|
||||||
|
PROJECT_ROOT = normpath(__file__, "..", "..")
|
||||||
|
STATIC_ROOT = os.environ.get("DJANGO_HELPDESK_STATIC_ROOT", normpath(PROJECT_ROOT, "static"))
|
||||||
|
STATIC_URL = os.environ.get("DJANGO_HELPDESK_STATIC_URL", "/static/")
|
||||||
|
|
||||||
|
|
||||||
|
# MEDIA_ROOT is where media uploads are stored.
|
||||||
|
# We set this to a directory to host file attachments created
|
||||||
|
# with tickets.
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
MEDIA_ROOT = '/data/media'
|
||||||
|
|
||||||
|
# for Django 3.2+, set default for autofields:
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||||
|
|
||||||
|
try:
|
||||||
|
from .local_settings import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
32
standalone/config/urls.py
Normal file
32
standalone/config/urls.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"""django-helpdesk demodesk URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/1.10/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||||
|
Including another URLconf
|
||||||
|
1. Import the include() function: from django.conf.urls import url, include
|
||||||
|
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||||
|
"""
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import include, path
|
||||||
|
|
||||||
|
|
||||||
|
# The following uses the static() helper function,
|
||||||
|
# which only works when in development mode (using DEBUG).
|
||||||
|
# For a real deployment, you'd have to properly configure a media server.
|
||||||
|
# For more information, see:
|
||||||
|
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('', include('helpdesk.urls', namespace='helpdesk')),
|
||||||
|
path('api/auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||||
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
17
standalone/config/wsgi.py
Normal file
17
standalone/config/wsgi.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
"""
|
||||||
|
WSGI config for django-helpdesk demodesk project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "standalone.config.settings")
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
10
standalone/custom_navigation_header.html
Normal file
10
standalone/custom_navigation_header.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<style>
|
||||||
|
.navbar-brand {
|
||||||
|
background: url("https://www.libertyaces.com/files/liberty-logo.png") no-repeat;
|
||||||
|
background-size: auto;
|
||||||
|
width: 320px;
|
||||||
|
background-size: contain;
|
||||||
|
height: 40px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
30
standalone/docker-compose.yml
Normal file
30
standalone/docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
caddy:
|
||||||
|
image: caddy:2
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /tmp/data/caddy/data:/data
|
||||||
|
- /tmp/data/caddy/config:/config
|
||||||
|
- ./Caddyfile:/etc/caddy/Caddyfile:r
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
|
||||||
|
django-helpdesk:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: standalone/Dockerfile
|
||||||
|
user: root
|
||||||
|
volumes:
|
||||||
|
- /tmp/django-helpdesk-data:/data/
|
||||||
|
- ./custom_navigation_header.html:/opt/django-helpdesk/helpdesk/templates/helpdesk/custom_navigation_header.html:r
|
||||||
|
env_file: docker.env
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:12-bullseye
|
||||||
|
volumes:
|
||||||
|
- ./db:/var/lib/postgresql/data
|
||||||
|
env_file: docker.env
|
1
standalone/docker.env.template
Normal file
1
standalone/docker.env.template
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
27
standalone/entrypoint.sh
Normal file
27
standalone/entrypoint.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Install extra deps from /opt/extra-deps.txt if it exists
|
||||||
|
if [ -f /opt/extra-dependencies.txt ]; then
|
||||||
|
pip install -r /opt/extra-dependencies.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd /opt/django-helpdesk/standalone/
|
||||||
|
if python manage.py showmigrations | grep '\[ \]\|^[a-z]' | grep '[ ]' -B 1; then
|
||||||
|
python manage.py migrate --noinput # Apply database migrations
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Starting cron to check emails
|
||||||
|
printenv > /etc/env
|
||||||
|
env | awk -F= '{printf "export %s=\"%s\"\n", $1, $2}' > /etc/env
|
||||||
|
cron &&
|
||||||
|
# Start Gunicorn processes
|
||||||
|
echo Starting Gunicorn.
|
||||||
|
exec gunicorn standalone.config.wsgi:application \
|
||||||
|
--name django-helpdesk \
|
||||||
|
--bind 0.0.0.0:${GUNICORN_PORT:-"8000"} \
|
||||||
|
--workers ${GUNICORN_NUM_WORKERS:-"6"} \
|
||||||
|
--timeout ${GUNICORN_TIMEOUT:-"60"} \
|
||||||
|
--preload \
|
||||||
|
--log-level=debug \
|
||||||
|
--log-file=- \
|
||||||
|
--access-logfile=- \
|
||||||
|
"$@"
|
3
standalone/extra-requirements.txt
Normal file
3
standalone/extra-requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
whitenoise
|
||||||
|
gunicorn
|
||||||
|
psycopg2-binary
|
27
standalone/manage.py
Executable file
27
standalone/manage.py
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "standalone.config.settings")
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError:
|
||||||
|
# The above import may fail for some other reason. Ensure that the
|
||||||
|
# issue is really that Django is missing to avoid masking other
|
||||||
|
# exceptions on Python 2.
|
||||||
|
try:
|
||||||
|
import django
|
||||||
|
except ImportError:
|
||||||
|
raise ImportError(
|
||||||
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
|
"forget to activate a virtual environment?"
|
||||||
|
)
|
||||||
|
raise
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
8
standalone/setup.sh
Executable file
8
standalone/setup.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# if docker.env does not exist create it from the template
|
||||||
|
if [ ! -f docker.env ]; then
|
||||||
|
cp docker.env.template docker.env
|
||||||
|
echo "DJANGO_HELPDESK_SECRET_KEY="$(mcookie) >> docker.env
|
||||||
|
echo "POSTGRES_PASSWORD="$(mcookie) >> docker.env
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user