Commit a8ce17cc authored by David Seaward's avatar David Seaward

handle user delay between subscription and registration (#58):

* delete unconverted user credit (triggers a new attempt)
* ask new registrants to refresh page after 5 mins

project tidying:

* update project links (source.puri.sm)
* update copyright bylines (just "Purism SPC")
* update README
* switch to pipfile-based dependencies and minimally update dependencies according to pipenv reports
* update references to requirements.txt (still used for regular installs)
Signed-off-by: David Seaward's avatarDavid Seaward <david.seaward@puri.sm>
parent 4d580dbe
......@@ -6,6 +6,7 @@ docs/api/
*.pid
categories.json
confusables.json
*.kdev4
### Basic template
......
# Copying notice
Services middleware <br />
<https://code.puri.sm/purist/middleware> <br />
Copyright 2017-2018 Purism SPC and contributors <br />
<https://source.puri.sm/purist/middleware> <br />
Copyright 2017-2018 Purism SPC <br />
SPDX-License-Identifier: AGPL-3.0+
This program is free software: you can redistribute it and/or modify
......
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
celery = "==4.1.0"
choicesenum = "==0.2.2"
dj-database-url = "==0.4.2"
django-agpl = "==4.0.0"
django-auth-ldap = "==1.3.0"
django-crispy-forms = "==1.7.0"
django-extensions = "==1.9.9"
django-ldapdb = "==0.9.0"
django-registration = "==2.4.1"
"jinja2-django-tags" = "==0.5"
paramiko = "==2.4.1"
"pyasn1" = "==0.4.2"
python-decouple = "==3.1"
strictyaml = "==0.11.10"
confusable_homoglyphs = "==3.0.0"
Django = "==1.11.15"
django_celery_beat = "==1.1.0"
"Jinja2" = "==2.10"
WooCommerce = "==1.2.1"
[dev-packages]
# self:
# purist_middleware = {path = ".", editable = true}
# Documentation depencencies:
# alabaster==0.7.10
# Babel==2.5.3
# certifi==2017.11.5
# chardet==3.0.4
# docutils==0.14
# idna==2.6
# imagesize==0.7.1
# Jinja2==2.10
# MarkupSafe==1.0
# Pygments==2.2.0
# pytz==2017.3
# requests==2.18.4
# six==1.11.0
# snowballstemmer==1.2.1
# Sphinx==1.6.6
# sphinxcontrib-websupport==1.0.1
# urllib3==1.22
[requires]
python_version = "3.6"
This diff is collapsed.
......@@ -8,11 +8,6 @@ including resource management and user-facing registration. Tailored for
*Purist services* as offered by Purism SPC, but ready to be modified and
deployed anywhere, by anyone.
[project]: https://code.puri.sm/purist/middleware
[code]: https://code.puri.sm/purist/middleware
[tracker]: https://code.puri.sm/purist/middleware/issues
[snippets]: https://code.puri.sm/purist/snippets/src/master/middleware
Installation
------------
......@@ -20,7 +15,7 @@ Follows an opinionated installation process (specifically expecting
one-instance-per-server), but includes a number of configuration
options.
See [SETUP.md](SETUP.md) for prerequisites and instructions.
See [SETUP.md] for prerequisites and instructions.
Usage
-----
......@@ -35,22 +30,42 @@ Usage
Models
------
![Database diagram generated by graph_models](models.png)
![Database model diagram](models.png)
(Generated with `./manage.py graph_models --all-applications --group-models --verbose-name --output models.png`)
Model diagram generated with:
./manage.py graph_models --all-applications --group-models \
--verbose-name --output models.png
Sharing and contributions
-------------------------
Services middleware <br />
<https://code.puri.sm/purist/middleware> <br />
Copyright 2017-2018 Purism SPC and contributors <br />
Services middleware
<https://source.puri.sm/purist/middleware>
Copyright 2017-2018 Purism SPC
SPDX-License-Identifier: AGPL-3.0+
Shared under AGPLv3-or-later, see [COPYING.AGPL.md](COPYING.AGPL.md)
for details. We adhere to the Contributor Covenant 1.4 without
modification, see [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details.
Contributions under the same terms are welcome.
Shared under AGPLv3-or-later. We adhere to the Contributor Covenant 1.4
without modification. Signed contributions (`git commit -s`) under the
same terms are welcome.
For details see:
Contributions and license notices from other sources are listed in
[COPYING.md](COPYING.md)
* [COPYING.AGPL.md], full license text
* [COPYING.md], additional license notices
* [CODE_OF_CONDUCT.md], full conduct text
* [CONTRIBUTING.DCO.md], full contribution text
* [CONTRIBUTING.md], additional contribution notes
<!-- Links -->
[project]: https://source.puri.sm/purist/middleware
[code]: https://source.puri.sm/purist/middleware
[tracker]: https://source.puri.sm/purist/middleware/issues
[snippets]: https://code.puri.sm/purist/snippets/src/master/middleware
[SETUP.md]: SETUP.md
[COPYING.AGPL.md]: COPYING.AGPL.md
[CODE_OF_CONDUCT.md]: CODE_OF_CONDUCT.md
[CONTRIBUTING.DCO.md]: CONTRIBUTING.DCO.md
[COPYING.md]: COPYING.md
[CONTRIBUTING.md]: CONTRIBUTING.md
......@@ -18,7 +18,7 @@ Prerequisites
* `uwsgi-emperor`
* `uwsgi-plugin-python3`
* `virtualenv`
* Python/Django dependencies: see `requires/requirements.txt`
* Python/Django dependencies: see `requirements.txt`
* External resources:
* LDAP database
* WooCommerce instance
......@@ -55,8 +55,8 @@ Setup
* Create virtualenv (`virtualenv /opt/purist/middleware_virtualenv --python=python3`)
* `cd /opt/purist/middleware`
* Activate virtualenv (`source ../account_virtualenv/bin/activate`)
* Install Python packages (`pip install --requirement requires/requirements.txt`)
* Confirm packages by comparing `pip freeze` output with `requires/requirements.txt`
* Install Python packages (`pip install --requirement requirements.txt`)
* Confirm packages by comparing `pip freeze` output with `requirements.txt`
* Deactivate virtualenv (`deactivate`)
* Complete Django settings:
* `cp ./conf/etc/config.ini /etc/opt/purist/middleware/`
......
; stored as /etc/supervisor/conf.d/purist_middleware_monitor.conf
; Copyright 2017-2018 Purism SPC and contributors
; Copyright 2017-2018 Purism SPC
; SPDX-License-Identifier: AGPL-3.0+
; Adapted from extra/supervisord/celerybeat.conf in Celery
......
......@@ -57,8 +57,8 @@ master_doc = 'index'
# General information about the project.
project = 'Services middleware'
copyright = '2017 Purism SPC and contributors'
author = 'Purism SPC and contributors'
copyright = '2017-2018 Purism SPC'
author = 'Purism SPC'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......@@ -138,7 +138,7 @@ latex_elements = {
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Servicesmiddlewaresite.tex', 'Services middleware documentation',
'Purism SPC and contributors', 'manual'),
'Purism SPC', 'manual'),
]
......
......@@ -2,8 +2,8 @@
{% load i18n %} {% load static %}
<!--
Copyright 2017-2018 Purism SPC and contributors
https://code.puri.sm/purist/middleware
Copyright 2017-2018 Purism SPC
https://source.puri.sm/purist/middleware
SPDX-License-Identifier: AGPL-3.0
-->
......@@ -59,8 +59,8 @@ SPDX-License-Identifier: AGPL-3.0
<p>
<em>Purist services</em> provided by <a href="https://puri.sm">Purism SPC</a><br/>
<em>Services middleware</em> copyright 2017-2018 Purism SPC and contributors; shared under AGPL-3.0+
(<a href="https://code.puri.sm/purist/middleware">project</a>,
<em>Services middleware</em> copyright 2017-2018 Purism SPC; shared under AGPL-3.0+
(<a href="https://source.puri.sm/purist/middleware">project</a>,
<a href="{% url 'download-zip' %}">source</a>,
<a href="{% url 'jslicense' %}" rel="jslicense">javascript</a>)
</p>
......
<!DOCTYPE html>
<!--
Copyright 2017-2018 Purism SPC and contributors
https://code.puri.sm/purist/middleware
Copyright 2017-2018 Purism SPC
https://source.puri.sm/purist/middleware
SPDX-License-Identifier: AGPL-3.0
-->
......@@ -85,13 +85,13 @@ SPDX-License-Identifier: AGPL-3.0
<ul>
{% if has_limit["TUNNEL"] %}
<li><a href="{% url 'ovpn_userfile' %}">{% trans "Tunnel certificate" %}</a></li>
<li><a href="https://code.puri.sm/purist/services/wiki/tunnel_desktop" target="_blank">{% trans "Tunnel
<li><a href="https://source.puri.sm/purist/services/wikis/tunnel-desktop" target="_blank">{% trans "Tunnel
setup instructions"
%}</a>
</li>
{% endif %}
{% if has_limit["NONE"] %}
<li>None</li>
<li>None. If you have just subscribed, please refresh after 5 mins and your downloads will appear.</li>
{% endif %}
</ul>
......@@ -131,8 +131,8 @@ SPDX-License-Identifier: AGPL-3.0
<p>
<em>{{ site_title }}</em> provided by <a href="{{ site_provider_link }}">{{ site_provider }}</a><br/>
<em>Services middleware</em> copyright 2017-2018 Purism SPC and contributors; shared under AGPL-3.0+
(<a href="https://code.puri.sm/purist/middleware">project</a>,
<em>Services middleware</em> copyright 2017-2018 Purism SPC; shared under AGPL-3.0+
(<a href="https://source.puri.sm/purist/middleware">project</a>,
<a href="{% url 'download-zip' %}">source</a>,
<a href="{% url 'jslicense' %}" rel="jslicense">javascript</a>)
</p>
......
......@@ -9,6 +9,7 @@ class Legacy(ChoicesEnum):
def create_missing_user_limits(user):
for code in settings.LM_SERVICES.MAP.keys():
is_defined = code != settings.LM_SERVICES.UNDEFINED
is_exists = Limit.objects.filter(user=user, service=code).exists()
......@@ -16,6 +17,11 @@ def create_missing_user_limits(user):
Limit(user=user, service=code).save()
def delete_unconverted_user_credits(user):
identity = user.get_identity()
ExternalCredit.objects.filter(account_name=identity, is_converted=False).delete()
class Limit(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
service = models.IntegerField(default=settings.LM_SERVICES.UNDEFINED,
......
# Copyright 2017-2018 Purism SPC and contributors
# Copyright 2017-2018 Purism SPC
# SPDX-License-Identifier: AGPL-3.0+
# Original file from Celery 4.0.2 documentation
......
<!DOCTYPE html>
<!--
Copyright 2017-2018 Purism SPC and contributors
https://code.puri.sm/purist/middleware
Copyright 2017-2018 Purism SPC
https://source.puri.sm/purist/middleware
SPDX-License-Identifier: AGPL-3.0
-->
......@@ -61,8 +61,8 @@ SPDX-License-Identifier: AGPL-3.0
<p>
<em>{{ site_title }}</em> provided by <a href="{{ site_provider_link }}">{{ site_provider }}</a><br/>
<em>Services middleware</em> copyright 2017-2018 Purism SPC and contributors; shared under AGPL-3.0+
(<a href="https://code.puri.sm/purist/middleware">project</a>,
<em>Services middleware</em> copyright 2017-2018 Purism SPC; shared under AGPL-3.0+
(<a href="https://source.puri.sm/purist/middleware">project</a>,
<a href="{% url 'download-zip' %}">source</a>,
<a href="{% url 'jslicense' %}" rel="jslicense">javascript</a>)
</p>
......
<!DOCTYPE html>
<!--
Copyright 2017-2018 Purism SPC and contributors
https://code.puri.sm/purist/middleware
Copyright 2017-2018 Purism SPC
https://source.puri.sm/purist/middleware
SPDX-License-Identifier: AGPL-3.0
-->
......
......@@ -102,6 +102,9 @@ class User(AbstractUser):
# create any missing limits
limitmonitor_models.create_missing_user_limits(self)
# delete invalid credits (they will be re-parsed)
limitmonitor_models.delete_unconverted_user_credits(self)
if settings.DEBUG_ALL_ACCESS:
ssh = limitmonitor_common.get_openvpn_ssh_connection()
......
# Requirements for a development instance
-r requires/production.txt # functional requirements and dependencies
-r requires/documentation.txt # documentation requirements
# do not modify manually
# generated with "pipenv run pip freeze > requirements.txt"
amqp==2.3.2
asn1crypto==0.24.0
bcrypt==3.1.4
billiard==3.5.0.4
celery==4.1.0
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
choicesenum==0.2.2
confusable-homoglyphs==3.0.0
cryptography==2.3
dj-database-url==0.4.2
Django==1.11.15
django-agpl==4.0.0
django-auth-ldap==1.3.0
django-celery-beat==1.1.0
django-crispy-forms==1.7.0
django-extensions==1.9.9
django-ldapdb==0.9.0
django-registration==2.4.1
ephem==3.7.6.0
idna==2.7
Jinja2==2.10
jinja2-django-tags==0.5
kombu==4.2.1
MarkupSafe==1.0
ordereddict==1.1
paramiko==2.4.1
pyasn1==0.4.2
pyasn1-modules==0.2.2
pycparser==2.18
pyldap==3.0.0.post1
PyNaCl==1.2.1
python-dateutil==2.7.3
python-decouple==3.1
python-ldap==3.1.0
pytz==2018.5
requests==2.19.1
ruamel.yaml==0.15.52
six==1.11.0
strictyaml==0.11.5
typing==3.6.4
urllib3==1.23
vine==1.1.4
WooCommerce==1.2.1
# Dependencies of the core packages in production.txt
amqp==2.2.2
asn1crypto==0.24.0
bcrypt==3.1.4
billiard==3.5.0.3
certifi==2017.11.5
cffi==1.11.4
chardet==3.0.4
cryptography==2.1.4
ephem==3.7.6.0
idna==2.6
kombu==4.1.0
MarkupSafe==1.0
ordereddict==1.1
pycparser==2.18
pyldap==2.4.45
PyNaCl==1.2.1
python-dateutil==2.6.1
pytz==2017.3
requests==2.18.4
ruamel.yaml==0.15.35
six==1.11.0
typing==3.6.2
urllib3==1.22
vine==1.1.4
# Requirements for documentation building
alabaster==0.7.10
Babel==2.5.3
certifi==2017.11.5
chardet==3.0.4
docutils==0.14
idna==2.6
imagesize==0.7.1
Jinja2==2.10
MarkupSafe==1.0
Pygments==2.2.0
pytz==2017.3
requests==2.18.4
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.6.6
sphinxcontrib-websupport==1.0.1
urllib3==1.22
# Top-level requirements for a production instance
-r dependencies.txt # dependencies of these core packages
celery==4.1.0
choicesenum==0.2.2
confusable_homoglyphs==3.0.0
dj-database-url==0.4.2
Django==1.11.12
django-agpl==4.0.0
django-auth-ldap==1.3.0
django-celery-beat==1.1.0
django-crispy-forms==1.7.0
django-extensions==1.9.9
django-ldapdb==0.9.0
django-registration==2.3
Jinja2==2.10
jinja2-django-tags==0.5
paramiko==2.4.0
pyasn1==0.4.2
python-decouple==3.1
strictyaml==0.11.5
WooCommerce==1.2.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment