Compare commits
59 Commits
0.1.a2
...
b3db6643b9
Author | SHA1 | Date | |
---|---|---|---|
b3db6643b9 | |||
cea3a909b5 | |||
b52d96a55e | |||
1fb71a172e | |||
27520c7ca4 | |||
af14cce3f8 | |||
75bcc91037 | |||
c78ff60231 | |||
09eb8794b8 | |||
470e54da8d | |||
19299598c3 | |||
f1c51ab8a7 | |||
b77c5d1d7f | |||
05481fc0c8 | |||
6b00452830 | |||
7e4c5dcf24 | |||
c0f30e56f7 | |||
9852646fff | |||
c2d678847e | |||
e77edf18ac | |||
3780aa6cf1 | |||
21124ec2ad | |||
0ee5fc59d3 | |||
b8dfef691e | |||
a1886b0b60 | |||
e1002b5315 | |||
fed90d4f7b | |||
dcfb329c5a | |||
b8a21a8baa | |||
7f73035b02 | |||
317437fedc | |||
26286984c2 | |||
9ae31c0146 | |||
87fd8fa96f | |||
c3401e732f | |||
4ee7373b3f | |||
64c0c5f8e6 | |||
18a597c726 | |||
|
baca596603 | ||
d993387216 | |||
aed2856df3 | |||
c78858c152 | |||
f49581259e | |||
f5bf642cd6 | |||
7687acb366 | |||
e655e1598a | |||
64ed38332f | |||
d438303aec | |||
38b3736951 | |||
6be060ea40 | |||
5c5756150f | |||
6e6f4ced7b | |||
b806f7f9e3 | |||
98c5ddad65 | |||
654cd87006 | |||
533efb328c | |||
5b1b23d3e6 | |||
bcd003a685 | |||
c4adc3f434 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -95,3 +95,6 @@ venv.bak/
|
||||
|
||||
# Editors
|
||||
.vscode
|
||||
|
||||
# twine / pypi
|
||||
.pypirc
|
@@ -1,5 +1,5 @@
|
||||
include LICENSE
|
||||
include README.rst
|
||||
include Readme.rst
|
||||
include Pipfile
|
||||
recursive-include lostplaces_app/static *
|
||||
recursive-include lostplaces_app/templates *
|
9
Pipfile
9
Pipfile
@@ -8,6 +8,10 @@ pylint = "*"
|
||||
coverage = "*"
|
||||
autopep8 = "*"
|
||||
pipenv = "*"
|
||||
wheel = "*"
|
||||
twine = "*"
|
||||
pandoc ="*"
|
||||
pylint-django ="*"
|
||||
|
||||
[packages]
|
||||
django = "*"
|
||||
@@ -15,6 +19,7 @@ easy-thumbnails = "*"
|
||||
image = "*"
|
||||
django-widget-tweaks = "*"
|
||||
django-taggit = "*"
|
||||
|
||||
# Commented out to not explicitly specify Python 3 subversion.
|
||||
# [requires]
|
||||
# python_version = "3.8"
|
||||
[requires]
|
||||
python_version = "3.7"
|
||||
|
69
Readme.md
69
Readme.md
@@ -4,18 +4,21 @@ lostplaces-backend is a django (3.x) based webproject. It once wants to become a
|
||||
|
||||
The software is currently in early development status, neither scope, datalmodel(s) nor features are finalized yet. Therefore we would not recommend to download or install this piece of software anywhere - except your local django dev server.
|
||||
|
||||
We value privacy as a whole, all ressources the frontend requires will be shipped with lostplace's distribution. We also try to minimze the use of JavaScript as far as we can and try to offer JS-less alternatives where we can.
|
||||
|
||||
## Features
|
||||
- manage lost places with lots of usefull information
|
||||
- sensitive information is not accesiable for anonymous (not logged in) users
|
||||
- user self registration using a voucher system, only people you invite can join your instance
|
||||
- collaboration, every user can add informations like tags, photos and external links to your place
|
||||
- Manage lost places with lots of usefull information.
|
||||
- OSM-Maps
|
||||
- Sensitive information is not accesiable for anonymous (not logged in) users.
|
||||
- User self registration using a voucher system, only people you invite can join your instance.
|
||||
- Collaboration, every user can add informations like tags, photos and external links to your place.
|
||||
|
||||
## Dependencies
|
||||
Right now it depends on the following non-core Python 3 libraries. These can be installed using the package manager of your distribution or into the venv locally.
|
||||
|
||||
* [django](https://www.djangoproject.com/) django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
|
||||
* [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) A powerful, yet easy to implement thumbnailing application for Django 1.11+
|
||||
* [image](https://github.com/francescortiz/image) Image cropping for django
|
||||
* [django](https://www.djangoproject.com/) is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
|
||||
* [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) A powerful, yet easy to implement thumbnailing application for Django 1.11+.
|
||||
* [image](https://github.com/francescortiz/image) Image cropping for django.
|
||||
* [django-widget-tweaks](https://github.com/jazzband/django-widget-tweaks) Tweak the form field rendering in templates, not in python-level form definitions.
|
||||
* [django-taggit](https://github.com/jazzband/django-taggit) A simpler approach to tagging with Django.
|
||||
|
||||
@@ -48,42 +51,44 @@ $ pipenv shell
|
||||
```
|
||||
|
||||
Visit: [admin](http://localhost:8000/admin) for administrative backend or
|
||||
[frontend](http://localhost:8000/)
|
||||
[frontend](http://localhost:8000/).
|
||||
|
||||
Happy developing ;-)
|
||||
|
||||
# Installing a productive instance
|
||||
|
||||
Currently there are two ways to deploy the lostplaces project:
|
||||
1. Cloning this repository, including the configured django instance
|
||||
2. Install the package and setup the django instance your self
|
||||
1. Cloning this repository, including the configured django instance.
|
||||
2. Install the package and setup the django instance yourself.
|
||||
|
||||
## Cloning the repository
|
||||
|
||||
Essently, this is the same as installing an development instance, but without the development server (manage.py runserver) and something powerfull (Apache, NGINX) instead. You have to configure the webserve to work with the *SGI Api respectivly, reference [django's guide for deployment](https://docs.djangoproject.com/en/3.1/howto/deployment/) for further information.
|
||||
Essentially, this is the same as installing a development instance, but without the development server (manage.py runserver) and something powerfull (Apache, NGINX) instead. You have to configure the webserve to work with the *SGI Api respectivly, reference [django's guide for deployment](https://docs.djangoproject.com/en/3.1/howto/deployment/) for further information.
|
||||
|
||||
You also should setup an dedicated database server, the build in SQLite file is not recommened for production use. Reference [django's guide for databases](https://docs.djangoproject.com/en/3.1/ref/databases/) for further information.
|
||||
You also should setup a dedicated database server, the built-in SQLite file is not recommened for production use. Reference [django's guide for databases](https://docs.djangoproject.com/en/3.1/ref/databases/) for further information.
|
||||
|
||||
Before making the django instance public, you should tweak the config `settings.py`:
|
||||
1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64))
|
||||
2. Turn off debug mode by setting `DEBUG = False`
|
||||
3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/)
|
||||
1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)).
|
||||
2. Turn off debug mode by setting `DEBUG = False`.
|
||||
3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/).
|
||||
|
||||
Run `lostplaces/managy.py collectstatic` you should be ready to go.
|
||||
Run `lostplaces/managy.py collectstatic` and you should be ready to go.
|
||||
|
||||
|
||||
## Installing the lostplaces_app to an existing django instance
|
||||
|
||||
### Installing django and the lostplaces app
|
||||
|
||||
If you haven't already setup an django instance, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/install/).
|
||||
If you haven't already setup a django instance, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/install/).
|
||||
|
||||
After that, download the desired release (probably the latest one) [from the realeases page](https://git.mowoe.com/reverend/lostplaces-backend/releases) and install it using `pip install --user name-of-the-file.tar.gz`.
|
||||
After that, download the desired release (probably the latest one) [from the realeases page](https://git.mowoe.com/reverend/lostplaces-backend/releases) and install it using `pip install --user name-of-the-file.tar.gz`
|
||||
|
||||
*Note: You can run pip install without the --user flag, which will require root privileges and introduces potential security issues*
|
||||
*Note: You can run pip install without the --user flag, which will require root privileges and introduces potential security issues.*
|
||||
|
||||
### Configuring the django instance
|
||||
|
||||
Now configure your `settings.py` as follows:
|
||||
1. Add the following apps to the django project
|
||||
1. Add the following apps to the django project.
|
||||
|
||||
```python
|
||||
INSTALLED_APPS = [
|
||||
@@ -95,7 +100,7 @@ INSTALLED_APPS = [
|
||||
]
|
||||
```
|
||||
|
||||
2. Set the URL's and Root-directories for file handling, for example
|
||||
2. Set the URL's and Root-directories for file handling, for example:
|
||||
|
||||
```python
|
||||
STATIC_URL = '/static/'
|
||||
@@ -105,13 +110,13 @@ MEDIA_URL = '/uploads/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
|
||||
```
|
||||
|
||||
3. Set the user model (this will be changed in the next release)
|
||||
3. Set the user model (this will be changed in the next release):
|
||||
|
||||
```python
|
||||
AUTH_USER_MODEL = 'lostplaces_app.Explorer'
|
||||
```
|
||||
|
||||
4. Set the URL's for login, for example
|
||||
4. Set the URL's for login, for example:
|
||||
|
||||
```python
|
||||
LOGIN_URL = reverse_lazy('login')
|
||||
@@ -120,21 +125,19 @@ LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||
```
|
||||
|
||||
### Configuring the URL's
|
||||
In the `urls.py` configure the `urlpatter` like this
|
||||
In the `urls.py` configure the `urlpatter` like this:
|
||||
```python
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('signup/', SignUpView.as_view(), name='signup'), # If you want to use lostplaces sign up view
|
||||
path('explorers/', include('django.contrib.auth.urls')), # You can change the 'explorers/' to whatever you desire
|
||||
path('', include('lostplaces_app.urls')), # In this configuration lostplaces will be at the top level of you website, change '' to 'lostplaces/', if you don't want this
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # So django can deliver user uploaded files
|
||||
path('signup/', SignUpView.as_view(), name='signup'), # If you want to use lostplaces' sign up view.
|
||||
path('explorers/', include('django.contrib.auth.urls')), # You can change the 'explorers/' to whatever you desire.
|
||||
path('', include('lostplaces_app.urls')), # In this configuration lostplaces will be at the top level of you website, change '' to 'lostplaces/', if you don't want this.
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # So django can deliver user uploaded files.
|
||||
```
|
||||
|
||||
Before making the django instance public, you should tweak the config `settings.py`:
|
||||
1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64))
|
||||
2. Turn off debug mode by setting `DEBUG = False`
|
||||
3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/)
|
||||
1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)).
|
||||
2. Turn off debug mode by setting `DEBUG = False`.
|
||||
3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/).
|
||||
|
||||
Run `lostplaces/managy.py collectstatic` you should be ready to go.
|
||||
|
||||
Happy developing ;-)
|
||||
|
199
Readme.rst
199
Readme.rst
@@ -1,199 +0,0 @@
|
||||
lostplaces-backend
|
||||
==================
|
||||
|
||||
lostplaces-backend is a django (3.x) based webproject. It once wants to
|
||||
become a software which allows a group of urban explorers to manage,
|
||||
document and share the locations of lost places while not exposing too
|
||||
much / any information to the public.
|
||||
|
||||
The software is currently in early development status, neither scope,
|
||||
datalmodel(s) nor features are finalized yet. Therefore we would not
|
||||
recommend to download or install this piece of software anywhere -
|
||||
except your local django dev server.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- manage lost places with lots of usefull information
|
||||
- sensitive information is not accesiable for anonymous (not logged in)
|
||||
users
|
||||
- user self registration using a voucher system, only people you invite
|
||||
can join your instance
|
||||
- collaboration, every user can add informations like tags, photos and
|
||||
external links to your place
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
Right now it depends on the following non-core Python 3 libraries. These
|
||||
can be installed using the package manager of your distribution or into
|
||||
the venv locally.
|
||||
|
||||
- `django <https://www.djangoproject.com/>`__ django is a high-level
|
||||
Python Web framework that encourages rapid development and clean,
|
||||
pragmatic design.
|
||||
- `easy-thumbnails <https://github.com/SmileyChris/easy-thumbnails>`__
|
||||
A powerful, yet easy to implement thumbnailing application for Django
|
||||
1.11+
|
||||
- `image <https://github.com/francescortiz/image>`__ Image cropping for
|
||||
django
|
||||
- `django-widget-tweaks <https://github.com/jazzband/django-widget-tweaks>`__
|
||||
Tweak the form field rendering in templates, not in python-level form
|
||||
definitions.
|
||||
- `django-taggit <https://github.com/jazzband/django-taggit>`__ A
|
||||
simpler approach to tagging with Django.
|
||||
|
||||
Installing a development instance
|
||||
=================================
|
||||
|
||||
Clone the repository
|
||||
--------------------
|
||||
|
||||
``git clone https://git.mowoe.com/reverend/lostplaces-backend.git`` ##
|
||||
Setting up a (pipenv) virtual environment for development
|
||||
|
||||
After having obtained the repository contents (either via .zip download
|
||||
or git clone), you can easily setup a
|
||||
`pipenv <https://docs.pipenv.org/>`__ virtual environment. The repo
|
||||
provides a Pipfile for easy dependency management that does not mess
|
||||
with your system.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
$ cd lostplaces-backend
|
||||
$ pipenv install
|
||||
$ pipenv shell
|
||||
(lostplaces-backend) $ lostplaces/manage.py makemigrations
|
||||
(lostplaces-backend) $ lostplaces/manage.py migrate
|
||||
(lostplaces-backend) $ lostplaces/manage.py createsuperuser
|
||||
(lostplaces-backend) $ lostplaces/manage.py runserver --ipv6
|
||||
|
||||
Returning to the venv
|
||||
---------------------
|
||||
|
||||
.. code:: shell
|
||||
|
||||
$ cd lostplaces-backend
|
||||
$ pipenv shell
|
||||
(lostplaces-backend) $ pipenv update # If dependencies changed, or updates available
|
||||
(lostplaces-backend) $ lostplaces/manage.py makemigrations # If datamodels changed
|
||||
(lostplaces-backend) $ lostplaces/manage.py migrate # If datamodels changed
|
||||
(lostplaces-backend) $ lostplaces/manage.py runserver --ipv6
|
||||
|
||||
Visit: `admin <http://localhost:8000/admin>`__ for administrative
|
||||
backend or `frontend <http://localhost:8000/>`__
|
||||
|
||||
Installing a productive instance
|
||||
================================
|
||||
|
||||
Currently there are two ways to deploy the lostplaces project: 1.
|
||||
Cloning this repository, including the configured django instance 2.
|
||||
Install the package and setup the django instance your self
|
||||
|
||||
Cloning the repository
|
||||
----------------------
|
||||
|
||||
Essently, this is the same as installing an development instance, but
|
||||
without the development server (manage.py runserver) and something
|
||||
powerfull (Apache, NGINX) instead. You have to configure the webserve to
|
||||
work with the \*SGI Api respectivly, reference `django's guide for
|
||||
deployment <https://docs.djangoproject.com/en/3.1/howto/deployment/>`__
|
||||
for further information.
|
||||
|
||||
You also should setup an dedicated database server, the build in SQLite
|
||||
file is not recommened for production use. Reference `django's guide for
|
||||
databases <https://docs.djangoproject.com/en/3.1/ref/databases/>`__ for
|
||||
further information.
|
||||
|
||||
Before making the django instance public, you should tweak the config
|
||||
``settings.py``: 1. Change the secret key, the one found in the config
|
||||
is already public. Choose something secure (i.e.
|
||||
`this <https://duckduckgo.com/?q=password+generator+64>`__) 2. Turn off
|
||||
debug mode by setting ``DEBUG = False`` 3. Tune the localization
|
||||
settings, see `django's
|
||||
documentation <https://docs.djangoproject.com/en/3.1/topics/i18n/>`__
|
||||
|
||||
Run ``lostplaces/managy.py collectstatic`` you should be ready to go.
|
||||
|
||||
Installing the lostplaces\_app to an existing django instance
|
||||
-------------------------------------------------------------
|
||||
|
||||
Installing django and the lostplaces app
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you haven't already setup an django instance, see `django's
|
||||
documentation <https://docs.djangoproject.com/en/3.1/topics/install/>`__.
|
||||
|
||||
After that, download the desired release (probably the latest one) `from
|
||||
the realeases
|
||||
page <https://git.mowoe.com/reverend/lostplaces-backend/releases>`__ and
|
||||
install it using ``pip install --user name-of-the-file.tar.gz``.
|
||||
|
||||
*Note: You can run pip install without the --user flag, which will
|
||||
require root privileges and introduces potential security issues*
|
||||
|
||||
Configuring the django instance
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now configure your ``settings.py`` as follows: 1. Add the following apps
|
||||
to the django project
|
||||
|
||||
.. code:: python
|
||||
|
||||
INSTALLED_APPS = [
|
||||
...
|
||||
'lostplaces_app',
|
||||
'easy_thumbnails',
|
||||
'widget_tweaks',
|
||||
'django_taggit'
|
||||
]
|
||||
|
||||
2. Set the URL's and Root-directories for file handling, for example
|
||||
|
||||
.. code:: python
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
||||
|
||||
MEDIA_URL = '/uploads/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
|
||||
|
||||
3. Set the user model (this will be changed in the next release)
|
||||
|
||||
.. code:: python
|
||||
|
||||
AUTH_USER_MODEL = 'lostplaces_app.Explorer'
|
||||
|
||||
4. Set the URL's for login, for example
|
||||
|
||||
.. code:: python
|
||||
|
||||
LOGIN_URL = reverse_lazy('login')
|
||||
LOGIN_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||
LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||
|
||||
Configuring the URL's
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In the ``urls.py`` configure the ``urlpatter`` like this
|
||||
|
||||
.. code:: python
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('signup/', SignUpView.as_view(), name='signup'), # If you want to use lostplaces sign up view
|
||||
path('explorers/', include('django.contrib.auth.urls')), # You can change the 'explorers/' to whatever you desire
|
||||
path('', include('lostplaces_app.urls')), # In this configuration lostplaces will be at the top level of you website, change '' to 'lostplaces/', if you don't want this
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # So django can deliver user uploaded files
|
||||
|
||||
Before making the django instance public, you should tweak the config
|
||||
``settings.py``: 1. Change the secret key, the one found in the config
|
||||
is already public. Choose something secure (i.e.
|
||||
`this <https://duckduckgo.com/?q=password+generator+64>`__) 2. Turn off
|
||||
debug mode by setting ``DEBUG = False`` 3. Tune the localization
|
||||
settings, see `django's
|
||||
documentation <https://docs.djangoproject.com/en/3.1/topics/i18n/>`__
|
||||
|
||||
Run ``lostplaces/managy.py collectstatic`` you should be ready to go.
|
||||
|
||||
Happy developing ;-)
|
@@ -4,13 +4,16 @@
|
||||
"""
|
||||
Django settings for lostplaces project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.0.8.
|
||||
!!! Instead of changing this file, you can override settings in !!!
|
||||
!!! local_settings.py. That way it won't cause merge conflicts on pull. !!!
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.1.8.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/topics/settings/
|
||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.0/ref/settings/
|
||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -21,7 +24,7 @@ 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/3.0/howto/deployment/checklist/
|
||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'n$(bx8(^)*wz1ygn@-ekt7rl^1km*!_c+fwwjiua8m@-x_rpl0'
|
||||
@@ -79,7 +82,7 @@ WSGI_APPLICATION = 'lostplaces.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
@@ -90,7 +93,7 @@ DATABASES = {
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
@@ -109,7 +112,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.0/topics/i18n/
|
||||
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
@@ -123,7 +126,7 @@ USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
||||
@@ -131,10 +134,15 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
||||
MEDIA_URL = '/uploads/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
|
||||
|
||||
# Use custom user model
|
||||
AUTH_USER_MODEL = 'lostplaces_app.Explorer'
|
||||
|
||||
# Templates to use for authentication
|
||||
LOGIN_URL = reverse_lazy('login')
|
||||
LOGIN_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||
LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||
|
||||
|
||||
# Load and override settings from local_settings.py and don't fail on errors.
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
@@ -6,23 +6,17 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from .models import *
|
||||
from lostplaces_app.models import *
|
||||
|
||||
from .forms import ExplorerCreationForm, ExplorerChangeForm
|
||||
from lostplaces_app.forms import ExplorerCreationForm, ExplorerChangeForm
|
||||
|
||||
# Register your models here.
|
||||
|
||||
class ExplorerAdmin(UserAdmin):
|
||||
add_form = ExplorerCreationForm
|
||||
form = ExplorerChangeForm
|
||||
model = Explorer
|
||||
list_display = ['email', 'username',]
|
||||
|
||||
class VoucherAdmin(admin.ModelAdmin):
|
||||
fields = ['code', 'expires', 'created']
|
||||
readonly_fields = ['created']
|
||||
fields = ['code', 'expires_when', 'created_when']
|
||||
readonly_fields = ['created_when']
|
||||
|
||||
admin.site.register(Explorer, ExplorerAdmin)
|
||||
admin.site.register(Explorer)
|
||||
admin.site.register(Voucher, VoucherAdmin)
|
||||
admin.site.register(Place)
|
||||
admin.site.register(PlaceImage)
|
||||
|
@@ -5,11 +5,12 @@
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
||||
from .models import Explorer, Place, PlaceImage, Voucher
|
||||
from django.contrib.auth.models import User
|
||||
from lostplaces_app.models import Place, PlaceImage, Voucher
|
||||
|
||||
class ExplorerCreationForm(UserCreationForm):
|
||||
class Meta:
|
||||
model = Explorer
|
||||
model = User
|
||||
fields = ('username', 'email')
|
||||
voucher = forms.CharField(
|
||||
max_length=30,
|
||||
@@ -30,7 +31,7 @@ class ExplorerCreationForm(UserCreationForm):
|
||||
|
||||
class ExplorerChangeForm(UserChangeForm):
|
||||
class Meta:
|
||||
model = Explorer
|
||||
model = User
|
||||
fields = ('username', 'email')
|
||||
|
||||
class PlaceForm(forms.ModelForm):
|
||||
|
@@ -9,54 +9,60 @@ database.
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from django.urls import reverse
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from easy_thumbnails.fields import ThumbnailerImageField
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Explorer(AbstractUser):
|
||||
class Explorer(models.Model):
|
||||
"""
|
||||
Custom user model
|
||||
Addtional fields wbd
|
||||
Profile that is linked to the a User.
|
||||
Every user has a profile.
|
||||
"""
|
||||
|
||||
user = models.OneToOneField(
|
||||
User,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='explorer'
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
return self.user.username
|
||||
|
||||
class Voucher(models.Model):
|
||||
"""
|
||||
Vouchers are authorization tokens to allow the registration of new users.
|
||||
A voucher has a code, a creation and a deletion date, which are all
|
||||
positional. Creation date is being set automatically during voucher
|
||||
creation.
|
||||
"""
|
||||
@receiver(post_save, sender=User)
|
||||
def create_user_profile(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
Explorer.objects.create(user=instance)
|
||||
|
||||
code = models.CharField(unique=True, max_length=30)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
expires = models.DateField()
|
||||
@receiver(post_save, sender=User)
|
||||
def save_user_profile(sender, instance, **kwargs):
|
||||
instance.explorer.save()
|
||||
|
||||
def __str__(self):
|
||||
return "Voucher " + str(self.pk)
|
||||
class Taggable(models.Model):
|
||||
'''
|
||||
This abstract model represtens an object that is taggalble
|
||||
using django-taggit
|
||||
'''
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class Place (models.Model):
|
||||
"""
|
||||
Place defines a lost place (location, name, description etc.).
|
||||
"""
|
||||
tags = TaggableManager(blank=True)
|
||||
|
||||
class MapablePoint(models.Model):
|
||||
'''
|
||||
This abstract model class represents an object that can be
|
||||
displayed on a map.
|
||||
'''
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
name = models.CharField(max_length=50)
|
||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||
submitted_by = models.ForeignKey(
|
||||
Explorer,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='places'
|
||||
)
|
||||
location = models.CharField(max_length=50)
|
||||
latitude = models.FloatField(
|
||||
validators=[
|
||||
MinValueValidator(-90),
|
||||
@@ -69,12 +75,55 @@ class Place (models.Model):
|
||||
MaxValueValidator(180)
|
||||
]
|
||||
)
|
||||
|
||||
class Submittable(models.Model):
|
||||
'''
|
||||
This abstract model class represents an object that can be submitted by
|
||||
an explorer.
|
||||
'''
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||
submitted_by = models.ForeignKey(
|
||||
Explorer,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='%(class)s'
|
||||
)
|
||||
|
||||
class Voucher(models.Model):
|
||||
"""
|
||||
Vouchers are authorization tokens to allow the registration of new users.
|
||||
A voucher has a code, a creation and a deletion date, which are all
|
||||
positional. Creation date is being set automatically during voucher
|
||||
creation.
|
||||
"""
|
||||
|
||||
code = models.CharField(unique=True, max_length=30)
|
||||
created_when = models.DateTimeField(auto_now_add=True)
|
||||
expires_when = models.DateTimeField()
|
||||
|
||||
def __str__(self):
|
||||
return "Voucher " + str(self.code)
|
||||
|
||||
|
||||
class Place(Submittable, Taggable, MapablePoint):
|
||||
"""
|
||||
Place defines a lost place (location, name, description etc.).
|
||||
"""
|
||||
|
||||
location = models.CharField(max_length=50)
|
||||
description = models.TextField()
|
||||
|
||||
tags = TaggableManager(blank=True)
|
||||
def get_absolute_url(self):
|
||||
return reverse('place_detail', kwargs={'pk': self.pk})
|
||||
|
||||
|
||||
@classmethod
|
||||
# Get center position of LP-geocoordinates.
|
||||
def average_latlon(place_list):
|
||||
def average_latlon(cls, place_list):
|
||||
amount = len(place_list)
|
||||
# Init fill values to prevent None
|
||||
longitude = 0
|
||||
@@ -84,13 +133,14 @@ class Place (models.Model):
|
||||
for place in place_list:
|
||||
longitude += place.longitude
|
||||
latitude += place.latitude
|
||||
return (latitude / amount, longitude / amount)
|
||||
return {'latitude':latitude / amount, 'longitude': longitude / amount}
|
||||
|
||||
return (latitude, longitude)
|
||||
return {'latitude': latitude, 'longitude': longitude}
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
def generate_image_upload_path(instance, filename):
|
||||
"""
|
||||
Callback for generating path for uploaded images.
|
||||
@@ -98,7 +148,8 @@ def generate_image_upload_path(instance, filename):
|
||||
|
||||
return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1]
|
||||
|
||||
class PlaceImage (models.Model):
|
||||
|
||||
class PlaceImage (Submittable):
|
||||
"""
|
||||
PlaceImage defines an image file object that points to a file in uploads/.
|
||||
Intermediate image sizes are generated as defined in SIZES.
|
||||
@@ -110,15 +161,7 @@ class PlaceImage (models.Model):
|
||||
place = models.ForeignKey(
|
||||
Place,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='images'
|
||||
)
|
||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||
submitted_by = models.ForeignKey(
|
||||
Explorer,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='images'
|
||||
related_name='placeimages'
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
@@ -130,6 +173,8 @@ class PlaceImage (models.Model):
|
||||
return ' '.join([self.place.name, str(self.pk)])
|
||||
|
||||
# These two auto-delete files from filesystem when they are unneeded:
|
||||
|
||||
|
||||
@receiver(models.signals.post_delete, sender=PlaceImage)
|
||||
def auto_delete_file_on_delete(sender, instance, **kwargs):
|
||||
"""
|
||||
@@ -140,6 +185,7 @@ def auto_delete_file_on_delete(sender, instance, **kwargs):
|
||||
if os.path.isfile(instance.filename.path):
|
||||
os.remove(instance.filename.path)
|
||||
|
||||
|
||||
@receiver(models.signals.pre_save, sender=PlaceImage)
|
||||
def auto_delete_file_on_change(sender, instance, **kwargs):
|
||||
"""
|
||||
@@ -160,6 +206,7 @@ def auto_delete_file_on_change(sender, instance, **kwargs):
|
||||
if os.path.isfile(old_file.path):
|
||||
os.remove(old_file.path)
|
||||
|
||||
|
||||
class ExternalLink(models.Model):
|
||||
url = models.URLField(max_length=200)
|
||||
label = models.CharField(max_length=100)
|
||||
@@ -172,6 +219,7 @@ class ExternalLink(models.Model):
|
||||
)
|
||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
|
||||
class PhotoAlbum(ExternalLink):
|
||||
place = models.ForeignKey(
|
||||
Place,
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
{% load static %}
|
||||
{% block additional_head %}
|
||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||
<script src="{% static 'maps/ol.js' %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||
<script src="{% static 'maps/ol.js' %}"></script>
|
||||
{% endblock additional_head %}
|
||||
|
||||
# {% block title %}Start{% endblock %}
|
||||
@@ -14,7 +14,7 @@
|
||||
<article class="LP-TextSection">
|
||||
</article>
|
||||
|
||||
{% include 'partials/osm_map.html' %}
|
||||
{% include 'partials/osm_map.html' with config=map_config %}
|
||||
<div class="LP-PlaceGrid">
|
||||
<h1 class="LP-Headline LP-Headline">Explore the latest locations</h1>
|
||||
<ul class="LP-PlaceGrid__Grid">
|
||||
@@ -23,7 +23,7 @@
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
<article class="LP-PlaceTeaser">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url}}" />
|
||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
||||
</div>
|
||||
<div class="LP-PlaceTeaser__Meta">
|
||||
<div class="LP-PlaceTeaser__Info">
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
<article class="LP-PlaceTeaser">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url}}" />
|
||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
||||
</div>
|
||||
<div class="LP-PlaceTeaser__Meta">
|
||||
<div class="LP-PlaceTeaser__Info">
|
||||
|
@@ -11,20 +11,20 @@
|
||||
}),
|
||||
],
|
||||
view: new ol.View({
|
||||
center: ol.proj.fromLonLat([{{place_map_center|last}}, {{place_map_center|first}}]),
|
||||
center: ol.proj.fromLonLat([{{config.map_center.longitude}}, {{config.map_center.latitude}}]),
|
||||
zoom: 9
|
||||
})
|
||||
});
|
||||
|
||||
var vectorSource = new ol.source.Vector({
|
||||
features: [
|
||||
{% for place in place_list %}
|
||||
{% for point in config.point_list %}
|
||||
new ol.Feature({
|
||||
geometry: new ol.geom.Point(
|
||||
ol.proj.fromLonLat([{{place.longitude}},{{place.latitude}}])
|
||||
ol.proj.fromLonLat([{{point.longitude}},{{point.latitude}}])
|
||||
),
|
||||
url: '{% url 'place_detail' pk=place.pk %}',
|
||||
name: '{{place.name}}'
|
||||
url: '{{point.get_absolute_url}}',
|
||||
name: ' {{point.name}}'
|
||||
}),
|
||||
{% endfor %}
|
||||
]
|
||||
|
@@ -1,12 +1,12 @@
|
||||
<div class="LP-TagList">
|
||||
<ul class="LP-TagList__List">
|
||||
{% for tag in tag_list %}
|
||||
{% for tag in config.tagged_item.tags.all %}
|
||||
<li class="LP-TagList__Item">
|
||||
<div class="LP-Tag">
|
||||
<a href="#" class="LP-Link">
|
||||
<span class="LP-Link__Text">{{tag}}</span>
|
||||
</a>
|
||||
{% if request.user and request.user == config.tagged_item.submitted_by %}
|
||||
{% if request.user and request.user.explorer == config.tagged_item.submitted_by %}
|
||||
<a href="{% url config.delete_url_name tagged_id=config.tagged_item.id tag_id=tag.id %}" class="LP-Link">
|
||||
<span class="LP-Tag__Remove RV-Iconized__Container RV-Iconized__Container--extraSmall">
|
||||
<svg class="RV-Iconized__Icon" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -23,7 +23,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{{config.submit_url}}">
|
||||
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{% url config.submit_url_name tagged_id=config.tagged_item.id%}">
|
||||
<fieldset class="LP-Form__Fieldset">
|
||||
<legend class="LP-Form__Legend">Tags hinzufügen</legend>
|
||||
{% csrf_token %}
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
const tagify = new Tagify(input, {
|
||||
'whitelist': [
|
||||
{% for tag in all_tags %}
|
||||
{% for tag in config.tagged_item.tags.all %}
|
||||
'{{tag}}',
|
||||
{% endfor %}
|
||||
]
|
||||
|
@@ -23,9 +23,9 @@
|
||||
|
||||
<header class="LP-PlaceDetail__Header">
|
||||
<h1 class="LP-Headline">{{ place.name }}</h1>
|
||||
{% if place.images.first.filename.hero.url %}
|
||||
{% if place.placeimages.first.filename.hero.url %}
|
||||
<figure class="LP-PlaceDetail__Image">
|
||||
<img src="{{ place.images.first.filename.hero.url }}" class="LP-Image" />
|
||||
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
|
||||
</figure>
|
||||
{% endif %}
|
||||
</header>
|
||||
@@ -37,13 +37,13 @@
|
||||
<section class="LP-Section">
|
||||
|
||||
{% url 'place_tag_submit' place_id=place.id as tag_submit_url%}
|
||||
{% include 'partials/tagging.html' with tag_list=place.tags.all config=tagging_config all_tags=all_tags %}
|
||||
{% include 'partials/tagging.html' with config=tagging_config %}
|
||||
|
||||
</section>
|
||||
|
||||
<section class="LP-Section">
|
||||
<h1 class="LP-Headline">Map-Links</h1>
|
||||
{% include 'partials/osm_map.html' %}
|
||||
{% include 'partials/osm_map.html' with config=map_config%}
|
||||
<div class="LP-LinkList">
|
||||
<ul class="LP-LinkList__Container">
|
||||
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude}},{{place.longitude}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li>
|
||||
@@ -62,7 +62,7 @@
|
||||
<a target="_blank" href="{{photo_album.url}}" class="LP-Link">
|
||||
<span class="LP-Text">{{photo_album.label}}</span>
|
||||
</a>
|
||||
{% if user == photo_album.submitted_by or user == place.submitted_by %}
|
||||
{% if user.explorer == photo_album.submitted_by or user.explorer == place.submitted_by %}
|
||||
<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album">
|
||||
<div class="RV-Iconized__Container RV-Iconized__Container--small">
|
||||
{% icon 'trash' className="RV-Iconized__Icon" %}
|
||||
@@ -92,7 +92,7 @@
|
||||
<h1 class="LP-Headline">Bilder</h1>
|
||||
<div class="LP-ImageGrid">
|
||||
<ul class="LP-ImageGrid__Container">
|
||||
{% for place_image in place.images.all %}
|
||||
{% for place_image in place.placeimages.all %}
|
||||
<li class="LP-ImageGrid__Item">
|
||||
<a href="{{ place_image.filename.large.url }}" class="LP-Link"><img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}"></a>
|
||||
</li>
|
||||
|
@@ -2,15 +2,15 @@
|
||||
{% load static %}
|
||||
|
||||
{% block additional_head %}
|
||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||
<script src="{% static 'maps/ol.js' %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||
<script src="{% static 'maps/ol.js' %}"></script>
|
||||
{% endblock additional_head %}
|
||||
|
||||
{% block title %}Lost Places{% endblock %}
|
||||
|
||||
{% block maincontent %}
|
||||
|
||||
{% include 'partials/osm_map.html' %}
|
||||
{% include 'partials/osm_map.html' with config=map_config %}
|
||||
<div class="LP-PlaceList">
|
||||
<h1 class="LP-Headline">Listing our places</h1>
|
||||
<ul class="LP-PlaceList__List">
|
||||
@@ -19,7 +19,7 @@
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
<article class="LP-PlaceTeaser LP-PlaceTeaser--extended">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url }}" />
|
||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url }}" />
|
||||
</div>
|
||||
<div class="LP-PlaceTeaser__Meta">
|
||||
<div class="LP-PlaceTeaser__Info">
|
||||
|
@@ -1,13 +1,2 @@
|
||||
from django.db import models as django_models
|
||||
from lostplaces_app.models import Explorer
|
||||
|
||||
|
||||
def mock_user():
|
||||
explorer_list = Explorer.objects.all()
|
||||
if len(explorer_list) <= 0:
|
||||
return Explorer.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
else:
|
||||
return explorer_list[0]
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
@@ -1,58 +1,101 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from django.test import TestCase
|
||||
|
||||
class TestModel:
|
||||
'''
|
||||
Base class for Lostplaces models
|
||||
'''
|
||||
model_name = None
|
||||
# Creating a test user
|
||||
|
||||
def _test_field(self, field_name, field_class):
|
||||
class ModelTestCase(TestCase):
|
||||
'''
|
||||
Base class for ModelTests.
|
||||
Parameters:
|
||||
- model : Class to test
|
||||
'''
|
||||
model = None
|
||||
|
||||
def assertField(self, field_name, field_class, must_have={}, must_not_have={}):
|
||||
'''
|
||||
Tests if a field exists under the given name and
|
||||
if the field is of the right type
|
||||
if the field is of the right type.
|
||||
Also checks if the field has the given must_have attributes
|
||||
and does not have any of the must_not_have attributes. If you
|
||||
dont care about the value of the attribute you can just set it to
|
||||
something that fullfills value == False (i.e. '' or 0)
|
||||
'''
|
||||
field = self.object._meta.get_field(field_name)
|
||||
self.assertTrue(
|
||||
field,
|
||||
msg="%s has no field named '%s'" % (
|
||||
self.model_name,
|
||||
try:
|
||||
field = self.model._meta.get_field(field_name)
|
||||
except FieldDoesNotExist:
|
||||
self.fail(
|
||||
'Expecting %s to have a field named \'%s\'' % (
|
||||
self.model.__name__,
|
||||
field_name
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
type(field), field_class,
|
||||
msg='%s.%s name field is no CharField' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
msg='Expecting type of %s to be %s' % (
|
||||
str(field),
|
||||
field_class.__name__
|
||||
)
|
||||
)
|
||||
|
||||
for key, value in must_have.items():
|
||||
if value:
|
||||
self.assertEqual(
|
||||
getattr(field, key), value,
|
||||
msg='Expeting the value of %s %s to be \'%s\'' % (
|
||||
str(field),
|
||||
key,
|
||||
value
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.assertTrue(
|
||||
hasattr(field, key),
|
||||
msg='Expeting %s to have \'%s\'' % (
|
||||
str(field),
|
||||
key
|
||||
)
|
||||
)
|
||||
|
||||
for key, value in must_not_have.items():
|
||||
if value:
|
||||
self.assertTrue(
|
||||
getattr(field, key) != value,
|
||||
msg='Expeting the value of %s %s to not be \'%s\'' % (
|
||||
str(field),
|
||||
key,
|
||||
value
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.assertFalse(
|
||||
hasattr(field, value),
|
||||
msg='Expeting %s to not have \'%s\'' % (
|
||||
str(field),
|
||||
key
|
||||
)
|
||||
)
|
||||
|
||||
return field
|
||||
|
||||
|
||||
def _test_char_field(self, field_name, min_length, max_length):
|
||||
def assertCharField(self, field_name, min_length, max_length, must_have={}, must_hot_have={}):
|
||||
'''
|
||||
Tests if the given field is a char field and if its max_length
|
||||
is in min_length and max_legth
|
||||
'''
|
||||
field = self._test_field(field_name, models.CharField)
|
||||
self.assertEqual(
|
||||
type(field), models.CharField,
|
||||
msg='%s.%s name field is no CharField' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
)
|
||||
)
|
||||
field = self.assertField(
|
||||
field_name, models.CharField, must_have, must_hot_have)
|
||||
self.assertTrue(
|
||||
field.max_length in range(min_length, max_length),
|
||||
msg='%s.%s field max_length not in range of %d and %d' % (
|
||||
self.model_name,
|
||||
field_name,
|
||||
msg='Expeting %s max_length to be in the range of %d and %d' % (
|
||||
str(field),
|
||||
min_length,
|
||||
max_length
|
||||
)
|
||||
)
|
||||
|
||||
def _test_float_field(self, field_name, min_value=None, max_value=None):
|
||||
def assertFloatField(self, field_name, min_value=None, max_value=None, must_have={}, must_hot_have={}):
|
||||
'''
|
||||
Tests if the field is a floatfield. If min_value and/or max_value are passed,
|
||||
the validators of the field are also checked. The validator list of the field should
|
||||
@@ -61,21 +104,21 @@ class TestModel:
|
||||
[MinValueValidator] if only min_value is passed,
|
||||
[MaxValueValidator] if only max_value is passed
|
||||
'''
|
||||
field = self._test_field(field_name, models.FloatField)
|
||||
field = self.assertField(
|
||||
field_name, models.FloatField, must_have, must_hot_have)
|
||||
if min_value:
|
||||
self.assertTrue(
|
||||
len(field.validators) >= 1,
|
||||
msg='%s.%s first validator should check minimum' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
msg='Expecting the first valiator of %s to check the minimum' % (
|
||||
str(field)
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
field.validators[0].limit_value,
|
||||
min_value,
|
||||
msg='%s.%s min value missmatch' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
msg='Expecting the min value of %s min to be at least %d' % (
|
||||
str(field),
|
||||
min_value
|
||||
)
|
||||
)
|
||||
if max_value:
|
||||
@@ -84,38 +127,15 @@ class TestModel:
|
||||
index += 1
|
||||
self.assertTrue(
|
||||
len(field.validators) >= index+1,
|
||||
msg='%s.%s second validator should check maximum' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
msg='Expecting the second valiator of %s to check the maximum' % (
|
||||
str(field)
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
field.validators[1].limit_value,
|
||||
max_value,
|
||||
msg='%s.%s max value missmatch' % (
|
||||
self.model_name,
|
||||
field_name
|
||||
msg='Expecting the max value of %s min to be at most %d' % (
|
||||
str(field),
|
||||
max_value
|
||||
)
|
||||
)
|
||||
|
||||
class TestSubmittable(TestModel):
|
||||
model_name='<Class>'
|
||||
related_name = None
|
||||
nullable = False
|
||||
|
||||
def test_submitted_when(self):
|
||||
submitted_when = self._test_field('submitted_when', models.DateTimeField)
|
||||
self.assertTrue(submitted_when.auto_now_add,
|
||||
msg='%s.submitted_when should be auto_now_add' % (
|
||||
self.model_name
|
||||
)
|
||||
)
|
||||
|
||||
def test_submitted_by(self):
|
||||
submitted_by = self._test_field('submitted_by',models.ForeignKey)
|
||||
if self.related_name:
|
||||
self.assertEqual(submitted_by.remote_field.related_name, self.related_name)
|
||||
if self.nullable:
|
||||
self.assertTrue(submitted_by.null,)
|
||||
self.assertTrue(submitted_by.blank)
|
||||
self.assertEqual(submitted_by.remote_field.on_delete, models.SET_NULL)
|
||||
|
BIN
lostplaces/lostplaces_app/tests/models/im_a_image.jpeg
Normal file
BIN
lostplaces/lostplaces_app/tests/models/im_a_image.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
@@ -0,0 +1,92 @@
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from lostplaces_app.models import (
|
||||
Taggable,
|
||||
MapablePoint,
|
||||
Submittable
|
||||
)
|
||||
from lostplaces_app.tests.models import ModelTestCase
|
||||
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
|
||||
class TaggableTestCase(ModelTestCase):
|
||||
|
||||
model = Taggable
|
||||
|
||||
def test_tags(self):
|
||||
self.assertField('tags', TaggableManager)
|
||||
|
||||
|
||||
class MapablePointTestCase(ModelTestCase):
|
||||
|
||||
model = MapablePoint
|
||||
|
||||
def test_name(self):
|
||||
self.assertCharField(
|
||||
field_name='name',
|
||||
min_length=10,
|
||||
max_length=100
|
||||
)
|
||||
|
||||
def test_latitude(self):
|
||||
self.assertFloatField(
|
||||
field_name='latitude',
|
||||
min_value=-90,
|
||||
max_value=90
|
||||
)
|
||||
|
||||
def test_longitude(self):
|
||||
self.assertFloatField(
|
||||
field_name='longitude',
|
||||
min_value=-180,
|
||||
max_value=180
|
||||
)
|
||||
|
||||
class SubmittableTestCase(ModelTestCase):
|
||||
model = Submittable
|
||||
|
||||
def test_submitted_when(self):
|
||||
self.assertField(
|
||||
field_name='submitted_when',
|
||||
field_class=models.DateTimeField,
|
||||
must_have={'auto_now_add': True}
|
||||
)
|
||||
|
||||
def test_submitted_by(self):
|
||||
submitted_by = self.assertField(
|
||||
field_name='submitted_by',
|
||||
field_class=models.ForeignKey
|
||||
)
|
||||
self.assertEqual(
|
||||
submitted_by.remote_field.related_name,
|
||||
'%(class)s',
|
||||
msg='Expecting the related_name of %s to be \'%%(class)s\', got %s' % (
|
||||
str(submitted_by),
|
||||
submitted_by.remote_field.related_name
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
submitted_by.null,
|
||||
msg='Expecting %s to has null=True' % (
|
||||
str(submitted_by)
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
submitted_by.blank,
|
||||
msg='Expecting %s to has blank=True' % (
|
||||
str(submitted_by)
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
submitted_by.remote_field.on_delete,
|
||||
models.SET_NULL,
|
||||
msg='Expecting %s to be null when reference is delete (models.SET_NULL)' % (
|
||||
str(submitted_by)
|
||||
)
|
||||
)
|
||||
|
@@ -0,0 +1,58 @@
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from lostplaces_app.models import Explorer
|
||||
|
||||
class ExplorerTestCase(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
def test_epxlorer_creation(self):
|
||||
'''
|
||||
Tests if the explorer profile will be automticly
|
||||
created when a user is created
|
||||
'''
|
||||
|
||||
user = User.objects.get(id=1)
|
||||
explorer_list = Explorer.objects.all()
|
||||
self.assertTrue(len(explorer_list) > 0,
|
||||
msg='Expecting at least one Exlorer object, none found'
|
||||
)
|
||||
self.assertTrue(hasattr(user, 'explorer'),
|
||||
msg='''Expecting the User instance to have an \'explorer\' attribute.
|
||||
Check the Explorer model and the related name.'''
|
||||
)
|
||||
|
||||
explorer = Explorer.objects.get(id=1)
|
||||
self.assertEqual(explorer, user.explorer,
|
||||
msg='''The Explorer object of the User did not match.
|
||||
Expecting User with id 1 to have Explorer with id 1'''
|
||||
)
|
||||
|
||||
explorer = Explorer.objects.get(id=1)
|
||||
self.assertEqual(explorer.user, user,
|
||||
msg='''The User object of the Explorer did not match.
|
||||
Expecting Explorer with id 1 to have User with id 1'''
|
||||
)
|
||||
|
||||
def test_explorer_deletion(self):
|
||||
'''
|
||||
Tests if the Explorer objects get's deleted when the User instance is deleted
|
||||
'''
|
||||
|
||||
user = User.objects.get(username='testpeter')
|
||||
explorer_id = user.explorer.id
|
||||
user.delete()
|
||||
with self.assertRaises(models.ObjectDoesNotExist,
|
||||
msg='Expecting explorer objec to be deleted when the corresponding User object is deleted'
|
||||
):
|
||||
Explorer.objects.get(id=explorer_id)
|
||||
|
||||
|
||||
|
@@ -1,55 +1,108 @@
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
from unittest import mock
|
||||
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
from django.core.files import File
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from lostplaces_app.models import PlaceImage
|
||||
from lostplaces_app.tests.models import TestSubmittable
|
||||
from lostplaces_app.tests import mock_user
|
||||
from lostplaces_app.tests.models import TestModel
|
||||
from lostplaces_app.tests.models.test_place_model import mock_place
|
||||
from lostplaces_app.models import PlaceImage, Place
|
||||
from lostplaces_app.tests.models import ModelTestCase
|
||||
|
||||
from easy_thumbnails.fields import ThumbnailerImageField
|
||||
|
||||
def mock_place_image():
|
||||
return PlaceImage(
|
||||
description='Im a description',
|
||||
filename=mock.MagicMock(spec=File, name='FileMock'),
|
||||
place=mock_place(),
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=mock_user()
|
||||
class PlaceImageTestCase(ModelTestCase):
|
||||
model = PlaceImage
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
class TestPlaceImage(TestSubmittable, TestCase):
|
||||
model_name = 'PlaceImage'
|
||||
place = Place.objects.create(
|
||||
name='Im a place',
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=User.objects.get(username='testpeter').explorer,
|
||||
location='Testtown',
|
||||
latitude=50.5,
|
||||
longitude=7.0,
|
||||
description='This is just a test, do not worry'
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
|
||||
if not os.path.isdir(settings.MEDIA_ROOT):
|
||||
os.mkdir(settings.MEDIA_ROOT)
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
if not os.path.isfile(os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg')):
|
||||
shutil.copyfile(
|
||||
os.path.join(current_dir, 'im_a_image.jpeg'),
|
||||
os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg')
|
||||
)
|
||||
|
||||
shutil.copyfile(
|
||||
os.path.join(current_dir, 'im_a_image.jpeg'),
|
||||
os.path.join(settings.MEDIA_ROOT, 'im_a_image_changed.jpeg')
|
||||
)
|
||||
|
||||
PlaceImage.objects.create(
|
||||
description='Im a description',
|
||||
filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'),
|
||||
place=place,
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=user.explorer
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.object = mock_place_image()
|
||||
self.place_image = PlaceImage.objects.get(id=1)
|
||||
|
||||
def test_description(self):
|
||||
self._test_field('description', models.TextField)
|
||||
self.assertField('description', models.TextField)
|
||||
|
||||
def test_filename(self):
|
||||
self._test_field('filename',ThumbnailerImageField)
|
||||
self.assertField('filename',ThumbnailerImageField)
|
||||
|
||||
def test_place(self):
|
||||
field = self._test_field('place', models.ForeignKey)
|
||||
field = self.assertField('place', models.ForeignKey)
|
||||
self.assertEqual(field.remote_field.on_delete, models.CASCADE,
|
||||
msg='%s.%s deleting of %s should be cascadinf' % (
|
||||
self.model_name,
|
||||
'place',
|
||||
self.model_name
|
||||
msg='Expecting the deletion of %s to be cascading' % (
|
||||
str(field)
|
||||
)
|
||||
)
|
||||
self.assertEqual(field.remote_field.related_name, 'images',
|
||||
msg='%s.%s related name should be images' % (
|
||||
self.model_name,
|
||||
'place'
|
||||
expected_related_name = 'placeimages'
|
||||
self.assertEqual(field.remote_field.related_name, expected_related_name,
|
||||
msg='Expecting the related name of %s to be %s' % (
|
||||
str(field),
|
||||
expected_related_name
|
||||
)
|
||||
)
|
||||
|
||||
def test_str(self):
|
||||
place_image = mock_place_image()
|
||||
self.assertEqual(str(place_image), ' '.join([place_image.place.name, str(place_image.pk)]))
|
||||
self.assertTrue(self.place_image.place.name.lower() in str(self.place_image).lower(),
|
||||
msg='Expecting %s.__str__ to contain the name of the place' % (
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
|
||||
def test_change_filename(self):
|
||||
path = self.place_image.filename.path
|
||||
self.place_image.filename = os.path.join(settings.MEDIA_ROOT, 'im_a_image_changed.jpeg')
|
||||
self.place_image.save()
|
||||
self.assertFalse(
|
||||
os.path.isfile(path),
|
||||
msg='Expecting the old file of an place_image to be deleteed when an place_image file is changed'
|
||||
)
|
||||
|
||||
def test_deletion(self):
|
||||
path = self.place_image.filename.path
|
||||
self.place_image.delete()
|
||||
self.assertFalse(
|
||||
os.path.isfile(path),
|
||||
msg='Expecting the file of an place_image to be deleteed when an place_image is deleted'
|
||||
)
|
@@ -3,69 +3,48 @@ import datetime
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from lostplaces_app.models import Place
|
||||
from lostplaces_app.tests.models import TestSubmittable
|
||||
from lostplaces_app.tests import mock_user
|
||||
from lostplaces_app.tests.models import TestModel
|
||||
from lostplaces_app.tests.models import ModelTestCase
|
||||
|
||||
from taggit.managers import TaggableManager
|
||||
class PlaceTestCase(ModelTestCase):
|
||||
model = Place
|
||||
related_name = 'places'
|
||||
nullable = True
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
def mock_place():
|
||||
place = Place.objects.create(
|
||||
name='Im a place',
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=mock_user(),
|
||||
submitted_by=user.explorer,
|
||||
location='Testtown',
|
||||
latitude=50.5,
|
||||
longitude=7.0,
|
||||
description='This is just a test, do not worry'
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
|
||||
return place
|
||||
|
||||
class PlaceTestCase(TestSubmittable, TestCase):
|
||||
model_name = 'Place'
|
||||
related_name = 'places'
|
||||
nullable = True
|
||||
|
||||
def setUp(self):
|
||||
self.place = mock_place()
|
||||
self.object = self.place
|
||||
|
||||
def test_name_field(self):
|
||||
self._test_char_field(
|
||||
field_name='name',
|
||||
min_length=10,
|
||||
max_length=100
|
||||
)
|
||||
self.place = Place.objects.get(id=1)
|
||||
|
||||
def test_location(self):
|
||||
self._test_char_field(
|
||||
self.assertCharField(
|
||||
field_name='location',
|
||||
min_length=10,
|
||||
max_length=100
|
||||
)
|
||||
|
||||
def test_latitude(self):
|
||||
self._test_float_field(
|
||||
field_name='latitude',
|
||||
min_value=-90,
|
||||
max_value=90
|
||||
)
|
||||
|
||||
def test_longitude(self):
|
||||
self._test_float_field(
|
||||
field_name='longitude',
|
||||
min_value=-180,
|
||||
max_value=180
|
||||
)
|
||||
|
||||
def test_decsription(self):
|
||||
self._test_field('description', models.TextField)
|
||||
|
||||
def test_tags(self):
|
||||
self._test_field('tags', TaggableManager)
|
||||
self.assertField('description', models.TextField)
|
||||
|
||||
def test_average_latlon(self):
|
||||
'''
|
||||
@@ -74,20 +53,30 @@ class PlaceTestCase(TestSubmittable, TestCase):
|
||||
'''
|
||||
place_list = []
|
||||
for i in range(10):
|
||||
place = mock_place()
|
||||
place = Place.objects.get(id=1)
|
||||
place.id = None
|
||||
place.latitude = i+1
|
||||
place.longitude = i+10
|
||||
place.save()
|
||||
place_list.append(place)
|
||||
|
||||
avg_latlon = Place.average_latlon(place_list)
|
||||
self.assertEqual(avg_latlon[0], 5.5,
|
||||
|
||||
self.assertTrue('latitude' in avg_latlon,
|
||||
msg='Expecting avg_latlon dict to have an \'latitude\' key'
|
||||
)
|
||||
self.assertTrue('longitude' in avg_latlon,
|
||||
msg='Expecting avg_latlon dict to have an \'longitude\' key'
|
||||
)
|
||||
|
||||
self.assertEqual(avg_latlon['latitude'], 5.5,
|
||||
msg='%s: average latitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
self.assertEqual(avg_latlon[1], 14.5,
|
||||
self.assertEqual(avg_latlon['longitude'], 14.5,
|
||||
msg='%s: average longitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
|
||||
@@ -96,16 +85,16 @@ class PlaceTestCase(TestSubmittable, TestCase):
|
||||
Tests the average latitude/longitude calculation of a list
|
||||
of one place
|
||||
'''
|
||||
place = mock_place()
|
||||
place = Place.objects.get(id=1)
|
||||
avg_latlon = Place.average_latlon([place])
|
||||
self.assertEqual(avg_latlon[0], place.latitude,
|
||||
self.assertEqual(avg_latlon['latitude'], place.latitude,
|
||||
msg='%s:(one place) average latitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
self.assertEqual(avg_latlon[1], place.longitude,
|
||||
self.assertEqual(avg_latlon['longitude'], place.longitude,
|
||||
msg='%s: (one place) average longitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
|
||||
@@ -115,22 +104,21 @@ class PlaceTestCase(TestSubmittable, TestCase):
|
||||
an empty list
|
||||
'''
|
||||
avg_latlon = Place.average_latlon([])
|
||||
self.assertEqual(avg_latlon[0], 0,
|
||||
self.assertEqual(avg_latlon['latitude'], 0,
|
||||
msg='%s: (no places) average latitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
self.assertEqual(avg_latlon[1], 0,
|
||||
self.assertEqual(avg_latlon['longitude'], 0,
|
||||
msg='%s: a(no places) verage longitude missmatch' % (
|
||||
self.model_name
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
||||
|
||||
def test_str(self):
|
||||
place = mock_place()
|
||||
self.assertEqual(str(place), place.name,
|
||||
msg='%s __str__ should return the name' % (
|
||||
self.model_name
|
||||
place = self.place
|
||||
self.assertTrue(place.name.lower() in str(place).lower(),
|
||||
msg='Expecting %s.__str__ to contain the name' % (
|
||||
self.model.__name__
|
||||
)
|
||||
|
||||
)
|
||||
|
52
lostplaces/lostplaces_app/tests/models/test_voucher_model.py
Normal file
52
lostplaces/lostplaces_app/tests/models/test_voucher_model.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
from lostplaces_app.models import Voucher
|
||||
from lostplaces_app.tests.models import ModelTestCase
|
||||
|
||||
|
||||
class VoucheTestCase(ModelTestCase):
|
||||
model = Voucher
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
Voucher.objects.create(
|
||||
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
||||
expires_when=timezone.now() + datetime.timedelta(days=1)
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.voucher = Voucher.objects.get(id=1)
|
||||
|
||||
def test_voucher_code(self):
|
||||
self.assertCharField(
|
||||
field_name='code',
|
||||
min_length=10,
|
||||
max_length=100,
|
||||
must_have={'unique': True}
|
||||
)
|
||||
|
||||
def test_voucher_created(self):
|
||||
self.assertField(
|
||||
field_name='created_when',
|
||||
field_class=models.DateTimeField,
|
||||
must_have={'auto_now_add': True}
|
||||
)
|
||||
|
||||
def test_voucher_expires(self):
|
||||
self.assertField(
|
||||
field_name='expires_when',
|
||||
field_class=models.DateTimeField,
|
||||
must_not_have={'auto_now_add': True}
|
||||
)
|
||||
|
||||
def test_str(self):
|
||||
self.assertTrue(
|
||||
self.voucher.code.lower() in str(self.voucher).lower(),
|
||||
msg='Expecting %s.__str__ to contain the voucher code' % (
|
||||
self.model.__name__
|
||||
)
|
||||
)
|
@@ -0,0 +1,108 @@
|
||||
from django.test import TestCase
|
||||
|
||||
class ViewTestCase(TestCase):
|
||||
'''
|
||||
This is a mixni for testing views. It provides functionality to
|
||||
test the context, forms and HTTP Response of responses.
|
||||
All methods take responses, so this base class can be used
|
||||
with django's RequestFactory and Test-Client
|
||||
'''
|
||||
view = None
|
||||
|
||||
def assertContext(self, response, key, value=None):
|
||||
'''
|
||||
Checks weather the response's context has the given key
|
||||
and, if passed, checks the value
|
||||
'''
|
||||
self.assertTrue(
|
||||
key in response.context,
|
||||
msg='Expecting the context of %s to have an attribute \'%s\'' % (
|
||||
self.view.__name__,
|
||||
key
|
||||
)
|
||||
)
|
||||
|
||||
if value:
|
||||
self.assertEqual(
|
||||
value,
|
||||
response.context[key],
|
||||
msg='Expecting the context of %s to have %s set to \'%s\'' % (
|
||||
self.view.__name__,
|
||||
key,
|
||||
str(value)
|
||||
)
|
||||
)
|
||||
|
||||
def assertHasForm(self, response, key, form_class):
|
||||
'''
|
||||
Checks if response has a form under the given key and if
|
||||
the forms class matches.
|
||||
'''
|
||||
self.assertContext(response, key)
|
||||
self.assertEqual(
|
||||
type(response.context[key]),
|
||||
form_class,
|
||||
msg='Expecting %s\'s context.%s to be of the type %s' % (
|
||||
self.view.__name__,
|
||||
key,
|
||||
form_class.__name__
|
||||
)
|
||||
)
|
||||
|
||||
def assertHttpCode(self, response, code):
|
||||
'''
|
||||
Checks if the response has the given status code
|
||||
'''
|
||||
self.assertEqual(
|
||||
response.status_code, code,
|
||||
"Expected an HTTP %s response, but got HTTP %s" % (
|
||||
code,
|
||||
response.status_code
|
||||
)
|
||||
)
|
||||
|
||||
def assertHttpRedirect(self, response, redirect_to=None):
|
||||
'''
|
||||
Checks weather the response redirected, and if passed,
|
||||
if it redirected to the expected loaction
|
||||
'''
|
||||
|
||||
self.assertTrue(
|
||||
300 <= response.status_code < 400,
|
||||
'Expected an HTTP 3XX (redirect) response, but got HTTP %s' %
|
||||
response.status_code
|
||||
)
|
||||
self.assertTrue(
|
||||
'location' in response,
|
||||
msg='Expecting a redirect to have an location, got none'
|
||||
)
|
||||
if redirect_to:
|
||||
self.assertEqual(
|
||||
response['location'],
|
||||
redirect_to,
|
||||
msg='Expecing the response to redirect to %s, where redirected to %s instea' % (
|
||||
str(redirect_to),
|
||||
str(response['location'])
|
||||
)
|
||||
)
|
||||
|
||||
def assertHttpOK(self, response):
|
||||
self.assertHttpCode(response, 200)
|
||||
|
||||
def assertHttpCreated(self, response):
|
||||
self.assertHttpCode(response, 201)
|
||||
|
||||
def assertHttpBadRequest(self, response):
|
||||
self.assertHttpCode(response, 400)
|
||||
|
||||
def assertHttpUnauthorized(self, response):
|
||||
self.assertHttpCode(response, 401)
|
||||
|
||||
def assertHttpForbidden(self, response):
|
||||
self.assertHttpCode(response, 403)
|
||||
|
||||
def assertHttpNotFound(self, response):
|
||||
self.assertHttpCode(response, 404)
|
||||
|
||||
def assertHttpMethodNotAllowed(self, response):
|
||||
self.assertHttpCode(response, 405)
|
@@ -1,45 +1,74 @@
|
||||
from django.test import TestCase, Client
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase, RequestFactory, Client
|
||||
from django.urls import reverse_lazy
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.contrib.messages.storage.fallback import FallbackStorage
|
||||
|
||||
from lostplaces_app.models import Place
|
||||
from lostplaces_app.views import IsAuthenticatedMixin
|
||||
from lostplaces_app.tests.views import ViewTestCase
|
||||
|
||||
from lostplaces_app.models import Explorer
|
||||
from lostplaces_app.tests.models.test_place_model import mock_place
|
||||
from lostplaces_app.tests import mock_user
|
||||
class TestIsAuthenticated(ViewTestCase):
|
||||
view = IsAuthenticatedMixin
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
class TestIsAuthenticated(TestCase):
|
||||
def setUp(self):
|
||||
self. client = Client()
|
||||
mock_place()
|
||||
mock_user()
|
||||
self.client = Client()
|
||||
|
||||
def test_logged_in(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.get(reverse_lazy('place_detail', kwargs={'pk': 1}))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
request = RequestFactory().get('/')
|
||||
request.user = User.objects.get(id=1)
|
||||
|
||||
response = IsAuthenticatedMixin.as_view()(request)
|
||||
# Expecting a 405 because IsAuthenticatedMixin has no 'get' method
|
||||
self.assertHttpMethodNotAllowed(response)
|
||||
|
||||
def test_not_logged_in(self):
|
||||
url = reverse_lazy('place_detail', kwargs={'pk': 1})
|
||||
response = self.client.get(url, follow=True)
|
||||
self.assertRedirects(
|
||||
response=response,
|
||||
expected_url='?'.join([str(reverse_lazy('login')), 'redirect_to=/place/1/']),
|
||||
status_code=302,
|
||||
target_status_code=200,
|
||||
msg_prefix='''Accesing an IsAuthenticated view while not logged should
|
||||
redirect to login page with redirect params
|
||||
''',
|
||||
fetch_redirect_response=True
|
||||
)
|
||||
self.assertTrue(response.context['messages'])
|
||||
self.assertTrue(len(response.context['messages']) > 0)
|
||||
request = RequestFactory().get('/someurl1234')
|
||||
request.user = AnonymousUser()
|
||||
request.session = 'session'
|
||||
messages = FallbackStorage(request)
|
||||
request._messages = messages
|
||||
|
||||
class TestIsPlaceSubmitter(TestCase):
|
||||
response = IsAuthenticatedMixin.as_view()(request)
|
||||
self.assertHttpRedirect(response, '?'.join([str(reverse_lazy('login')), 'next=/someurl1234']))
|
||||
|
||||
response = self.client.get(response['Location'])
|
||||
self.assertTrue(len(messages) > 0)
|
||||
|
||||
class TestIsPlaceSubmitterMixin(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
place = Place.objects.create(
|
||||
name='Im a place',
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=user.explorer,
|
||||
location='Testtown',
|
||||
latitude=50.5,
|
||||
longitude=7.0,
|
||||
description='This is just a test, do not worry'
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def setUp(self):
|
||||
self. client = Client()
|
||||
mock_place()
|
||||
mock_user()
|
||||
|
||||
def test_is_submitter(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
@@ -47,7 +76,7 @@ class TestIsPlaceSubmitter(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_is_no_submitter(self):
|
||||
Explorer.objects.create_user(
|
||||
User.objects.create_user(
|
||||
username='manfred',
|
||||
password='Develop123'
|
||||
)
|
||||
|
@@ -1,35 +1,82 @@
|
||||
import datetime
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.urls import reverse_lazy
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from lostplaces_app.models import Place
|
||||
from lostplaces_app.views import (
|
||||
PlaceCreateView,
|
||||
PlaceListView
|
||||
)
|
||||
from lostplaces_app.forms import PlaceImageCreateForm, PlaceForm
|
||||
from lostplaces_app.tests.views import ViewTestCase
|
||||
|
||||
from lostplaces_app.tests.models.test_place_model import mock_place
|
||||
from lostplaces_app.tests import mock_user
|
||||
class TestPlaceCreateView(ViewTestCase):
|
||||
view = PlaceCreateView
|
||||
|
||||
class TestPlaceCreateView(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self. client = Client()
|
||||
mock_place()
|
||||
mock_user()
|
||||
|
||||
def test_url_logged_in(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.get(reverse_lazy('place_detail', kwargs={'pk': 1}))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_url_not_logged_in(self):
|
||||
url = reverse_lazy('place_detail', kwargs={'pk': 1})
|
||||
response = self.client.get(url)
|
||||
self.assertRedirects(
|
||||
response=response,
|
||||
expected_url='?'.join([str(reverse_lazy('login')), 'redirect_to=/place/1/']),
|
||||
status_code=302,
|
||||
target_status_code=200,
|
||||
msg_prefix='''Accesing PlaceDetailView while not logged should
|
||||
redirect to login page with redirect params
|
||||
''',
|
||||
fetch_redirect_response=True
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
place = Place.objects.create(
|
||||
name='Im a place',
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=user.explorer,
|
||||
location='Testtown',
|
||||
latitude=50.5,
|
||||
longitude=7.0,
|
||||
description='This is just a test, do not worry'
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def test_has_forms(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.get(reverse_lazy('place_create'))
|
||||
|
||||
self.assertHasForm(response, 'place_image_form', PlaceImageCreateForm)
|
||||
self.assertHasForm(response, 'place_form', PlaceForm)
|
||||
|
||||
class TestPlaceListView(ViewTestCase):
|
||||
view = PlaceListView
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
user = User.objects.create_user(
|
||||
username='testpeter',
|
||||
password='Develop123'
|
||||
)
|
||||
|
||||
place = Place.objects.create(
|
||||
name='Im a place',
|
||||
submitted_when=datetime.datetime.now(),
|
||||
submitted_by=user.explorer,
|
||||
location='Testtown',
|
||||
latitude=50.5,
|
||||
longitude=7.0,
|
||||
description='This is just a test, do not worry'
|
||||
)
|
||||
place.tags.add('I a tag', 'testlocation')
|
||||
place.save()
|
||||
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def test_list_view(self):
|
||||
self.client.login(username='testpeter', password='Develop123')
|
||||
response = self.client.get(reverse_lazy('place_list'))
|
||||
|
||||
self.assertContext(response, 'map_config')
|
||||
|
||||
def test_test(self):
|
||||
response = self.client.get(reverse_lazy('place_list'))
|
||||
print(response['location'])
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from django.urls import path
|
||||
from .views import (
|
||||
from lostplaces_app.views import (
|
||||
HomeView,
|
||||
PlaceDetailView,
|
||||
PlaceListView,
|
||||
@@ -25,6 +25,6 @@ urlpatterns = [
|
||||
path('flat/<slug:slug>/', FlatView, name='flatpage'),
|
||||
|
||||
# POST-only URLs for tag submission
|
||||
path('place/tag/<int:place_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
||||
path('place/tag/<int:tagged_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
||||
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete')
|
||||
]
|
||||
|
@@ -11,7 +11,7 @@ from django.urls import reverse_lazy
|
||||
|
||||
from lostplaces_app.models import Place
|
||||
|
||||
class IsAuthenticated(LoginRequiredMixin, View):
|
||||
class IsAuthenticatedMixin(LoginRequiredMixin, View):
|
||||
'''
|
||||
A view mixin that checks wether a user is loged in or not.
|
||||
If the user is not logged in, he gets redirected to
|
||||
@@ -24,7 +24,7 @@ class IsAuthenticated(LoginRequiredMixin, View):
|
||||
messages.error(self.request, self.permission_denied_message)
|
||||
return super().handle_no_permission()
|
||||
|
||||
class IsPlaceSubmitter(UserPassesTestMixin, View):
|
||||
class IsPlaceSubmitterMixin(UserPassesTestMixin, View):
|
||||
'''
|
||||
A view mixin that checks wethe a user is the submitter
|
||||
of a place Throws 403 if the user is not. The subclass
|
||||
@@ -48,14 +48,14 @@ class IsPlaceSubmitter(UserPassesTestMixin, View):
|
||||
# Check if currently logged in user was the submitter
|
||||
place_obj = self.get_place()
|
||||
|
||||
if place_obj and hasattr(place_obj, 'submitted_by') and self.request.user == place_obj.submitted_by:
|
||||
if place_obj and hasattr(place_obj, 'submitted_by') and self.request.user.explorer == place_obj.submitted_by:
|
||||
return True
|
||||
|
||||
if self.place_submitter_error_message:
|
||||
messages.error(self.request, self.place_submitter_error_message)
|
||||
return False
|
||||
|
||||
class PlaceAssetCreateView(IsAuthenticated, SuccessMessageMixin, CreateView):
|
||||
class PlaceAssetCreateView(IsAuthenticatedMixin, SuccessMessageMixin, CreateView):
|
||||
model = None
|
||||
fields = []
|
||||
template_name = ''
|
||||
@@ -69,7 +69,7 @@ class PlaceAssetCreateView(IsAuthenticated, SuccessMessageMixin, CreateView):
|
||||
self.place = Place.objects.get(pk=place_id)
|
||||
response = super().post(request, *args, **kwargs)
|
||||
self.object.place = self.place
|
||||
self.object.submitted_by = request.user
|
||||
self.object.submitted_by = request.user.explorer
|
||||
self.object.save()
|
||||
return response
|
||||
|
||||
@@ -81,7 +81,7 @@ class PlaceAssetCreateView(IsAuthenticated, SuccessMessageMixin, CreateView):
|
||||
def get_success_url(self):
|
||||
return reverse_lazy('place_detail', kwargs={'pk': self.place.id})
|
||||
|
||||
class PlaceAssetDeleteView(IsAuthenticated, IsPlaceSubmitter, SingleObjectMixin, View):
|
||||
class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SingleObjectMixin, View):
|
||||
model = None
|
||||
success_message = ''
|
||||
permission_denied_message = ''
|
||||
@@ -95,7 +95,7 @@ class PlaceAssetDeleteView(IsAuthenticated, IsPlaceSubmitter, SingleObjectMixin,
|
||||
if can_edit_place:
|
||||
return True
|
||||
|
||||
if self.get_object().submitted_by == self.request.user:
|
||||
if self.get_object().submitted_by == self.request.user.explorer:
|
||||
return True
|
||||
|
||||
messages.error(self.request, self.permission_denied_message)
|
||||
|
@@ -10,12 +10,12 @@ from django.shortcuts import render, redirect
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from lostplaces_app.models import Place, PlaceImage
|
||||
from lostplaces_app.views import IsAuthenticated, IsPlaceSubmitter
|
||||
from lostplaces_app.views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
|
||||
from lostplaces_app.forms import PlaceForm, PlaceImageCreateForm, TagSubmitForm
|
||||
|
||||
from taggit.models import Tag
|
||||
|
||||
class PlaceListView(IsAuthenticated, ListView):
|
||||
class PlaceListView(IsAuthenticatedMixin, ListView):
|
||||
paginate_by = 5
|
||||
model = Place
|
||||
template_name = 'place/place_list.html'
|
||||
@@ -23,27 +23,32 @@ class PlaceListView(IsAuthenticated, ListView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['place_map_center'] = Place.average_latlon(context['place_list'])
|
||||
context['map_config'] = {
|
||||
'point_list': context['place_list'],
|
||||
'map_center': Place.average_latlon(context['place_list'])
|
||||
}
|
||||
return context
|
||||
|
||||
class PlaceDetailView(IsAuthenticated, View):
|
||||
class PlaceDetailView(IsAuthenticatedMixin, View):
|
||||
def get(self, request, pk):
|
||||
place = Place.objects.get(pk=pk)
|
||||
context = {
|
||||
'place': place,
|
||||
'place_list': [ place ],
|
||||
'place_map_center': [ place.latitude, place.longitude ],
|
||||
'all_tags': Tag.objects.all(),
|
||||
'map_config': {
|
||||
'point_list': [ place ],
|
||||
'map_center': {'latitude': place.latitude, 'longitude': place.longitude},
|
||||
},
|
||||
'tagging_config': {
|
||||
'submit_url': reverse_lazy('place_tag_submit', kwargs={'place_id': place.id}),
|
||||
'all_tags': Tag.objects.all(),
|
||||
'submit_form': TagSubmitForm(),
|
||||
'tagged_item': place,
|
||||
'submit_url_name': 'place_tag_submit',
|
||||
'delete_url_name': 'place_tag_delete'
|
||||
}
|
||||
}
|
||||
return render(request, 'place/place_detail.html', context)
|
||||
|
||||
class PlaceUpdateView(IsAuthenticated, IsPlaceSubmitter, SuccessMessageMixin, UpdateView):
|
||||
class PlaceUpdateView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SuccessMessageMixin, UpdateView):
|
||||
template_name = 'place/place_update.html'
|
||||
model = Place
|
||||
form_class = PlaceForm
|
||||
@@ -56,7 +61,7 @@ class PlaceUpdateView(IsAuthenticated, IsPlaceSubmitter, SuccessMessageMixin, Up
|
||||
def get_place(self):
|
||||
return self.get_object()
|
||||
|
||||
class PlaceCreateView(IsAuthenticated, View):
|
||||
class PlaceCreateView(IsAuthenticatedMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
place_image_form = PlaceImageCreateForm()
|
||||
@@ -72,7 +77,7 @@ class PlaceCreateView(IsAuthenticated, View):
|
||||
place_form = PlaceForm(request.POST)
|
||||
|
||||
if place_form.is_valid():
|
||||
submitter = request.user
|
||||
submitter = request.user.explorer
|
||||
place = place_form.save(commit=False)
|
||||
# Save logged in user as "submitted_by"
|
||||
place.submitted_by = submitter
|
||||
@@ -112,7 +117,7 @@ class PlaceCreateView(IsAuthenticated, View):
|
||||
)
|
||||
place_image.save()
|
||||
|
||||
class PlaceDeleteView(IsAuthenticated, IsPlaceSubmitter, DeleteView):
|
||||
class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
|
||||
template_name = 'place/place_delete.html'
|
||||
model = Place
|
||||
success_message = 'Successfully deleted place.'
|
||||
|
@@ -9,7 +9,7 @@ from django.http import HttpResponseForbidden
|
||||
|
||||
from lostplaces_app.forms import ExplorerCreationForm, TagSubmitForm
|
||||
from lostplaces_app.models import Place, PhotoAlbum
|
||||
from lostplaces_app.views.base_views import IsAuthenticated
|
||||
from lostplaces_app.views.base_views import IsAuthenticatedMixin
|
||||
|
||||
from lostplaces_app.views.base_views import (
|
||||
PlaceAssetCreateView,
|
||||
@@ -24,13 +24,15 @@ class SignUpView(SuccessMessageMixin, CreateView):
|
||||
template_name = 'signup.html'
|
||||
success_message = 'User created.'
|
||||
|
||||
class HomeView(IsAuthenticated, View):
|
||||
class HomeView(IsAuthenticatedMixin, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
place_list = Place.objects.all().order_by('-submitted_when')[:10]
|
||||
place_map_center = Place.average_latlon(place_list)
|
||||
context = {
|
||||
'place_list': place_list,
|
||||
'place_map_center': place_map_center
|
||||
'map_config': {
|
||||
'point_list': place_list,
|
||||
'map_center': Place.average_latlon(place_list)
|
||||
}
|
||||
}
|
||||
return render(request, 'home.html', context)
|
||||
|
||||
@@ -53,9 +55,9 @@ class PhotoAlbumDeleteView(PlaceAssetDeleteView):
|
||||
success_message = 'Photo Album deleted'
|
||||
permission_denied_messsage = 'You do not have permissions to alter this photo album'
|
||||
|
||||
class PlaceTagSubmitView(IsAuthenticated, View):
|
||||
def post(self, request, place_id, *args, **kwargs):
|
||||
place = Place.objects.get(pk=place_id)
|
||||
class PlaceTagSubmitView(IsAuthenticatedMixin, View):
|
||||
def post(self, request, tagged_id, *args, **kwargs):
|
||||
place = Place.objects.get(pk=tagged_id)
|
||||
form = TagSubmitForm(request.POST)
|
||||
if form.is_valid():
|
||||
tag_list_raw = form.cleaned_data['tag_list']
|
||||
@@ -68,7 +70,7 @@ class PlaceTagSubmitView(IsAuthenticated, View):
|
||||
|
||||
return redirect(reverse_lazy('place_detail', kwargs={'pk': place.id}))
|
||||
|
||||
class PlaceTagDeleteView(IsAuthenticated, View):
|
||||
class PlaceTagDeleteView(IsAuthenticatedMixin, View):
|
||||
def get(self, request, tagged_id, tag_id, *args, **kwargs):
|
||||
place = Place.objects.get(pk=tagged_id)
|
||||
tag = Tag.objects.get(pk=tag_id)
|
||||
|
15
setup.py
15
setup.py
@@ -1,20 +1,25 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
with open('Readme.md') as f:
|
||||
readme = f.read()
|
||||
|
||||
setup(
|
||||
name='django-lostplaces',
|
||||
version='0.1.a2',
|
||||
version='0.1.a5',
|
||||
description='A django app to manage lost places',
|
||||
author='Reverend :: Commander1024',
|
||||
author_email='reverend@reverend2048.de :: commander@commander1024.de',
|
||||
author='Reverend',
|
||||
author_email='reverend@reverend2048.de',
|
||||
url='https://git.mowoe.com/reverend/lostplaces-backend',
|
||||
packages=find_packages(exclude=['lostplaces']),
|
||||
long_description=readme,
|
||||
long_description_content_type='text/markdown',
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Web Environment',
|
||||
'Intended Audience :: Explorer :: Photographers :: Proper People',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 3.7'
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Framework :: Django'
|
||||
],
|
||||
install_requires=[
|
||||
'django',
|
||||
|
Reference in New Issue
Block a user