diff --git a/app/api/tasks.py b/app/api/tasks.py index 4e4da2da6..bb2d4a7cb 100644 --- a/app/api/tasks.py +++ b/app/api/tasks.py @@ -184,6 +184,7 @@ def commit(self, request, pk=None, project_pk=None): if task.images_count < 1: raise exceptions.ValidationError(detail=_("You need to upload at least 1 file before commit")) + task.update_size() task.save() worker_tasks.process_task.delay(task.id) diff --git a/app/templates/app/dashboard.html b/app/templates/app/dashboard.html index 668af63e4..344981ad2 100644 --- a/app/templates/app/dashboard.html +++ b/app/templates/app/dashboard.html @@ -13,6 +13,8 @@ {% if no_processingnodes %} + {% include "quota.html" %} +

{% trans 'Welcome!' %} ☺

{% trans 'Add a Processing Node' as add_processing_node %} {% with nodeodm_link='NodeODM' api_link='API' %} @@ -39,15 +41,8 @@

{% trans 'Welcome!' %} ☺

{% endif %} - - {% if user.profile.has_exceeded_quota_cached %} - {% with total=user.profile.quota|disk_size used=user.profile.used_quota_cached|disk_size %} - {% quota_exceeded_grace_period as when %} -
- {% blocktrans %}The disk quota is being exceeded ({{ used }} of {{ total }} used). The most recent tasks will be automatically deleted {{ when }}, until usage falls below {{ total }}.{% endblocktrans %} -
- {% endwith %} - {% endif %} + + {% include "quota.html" %}
diff --git a/app/templates/app/logged_in_base.html b/app/templates/app/logged_in_base.html index 8ba8d36f6..914cb4b07 100644 --- a/app/templates/app/logged_in_base.html +++ b/app/templates/app/logged_in_base.html @@ -19,7 +19,7 @@ {% if user.profile.has_quota %}
  • - + {% with tot_quota=user.profile.quota used_quota=user.profile.used_quota_cached %} {% percentage used_quota tot_quota as perc_quota %} {% percentage used_quota tot_quota 100 as bar_width %} diff --git a/app/templates/app/quota.html b/app/templates/app/quota.html new file mode 100644 index 000000000..c52df023a --- /dev/null +++ b/app/templates/app/quota.html @@ -0,0 +1,11 @@ +{% load i18n %} +{% load settings %} + +{% if user.profile.has_exceeded_quota_cached %} + {% with total=user.profile.quota|disk_size used=user.profile.used_quota_cached|disk_size %} + {% quota_exceeded_grace_period as when %} +
    + {% blocktrans %}The disk quota is being exceeded ({{ used }} of {{ total }} used). The most recent tasks will be automatically deleted {{ when }}, until usage falls below {{ total }}.{% endblocktrans %} +
    + {% endwith %} +{% endif %} \ No newline at end of file diff --git a/app/templatetags/settings.py b/app/templatetags/settings.py index 96efd0e21..b0962cbd2 100644 --- a/app/templatetags/settings.py +++ b/app/templatetags/settings.py @@ -46,11 +46,11 @@ def quota_exceeded_grace_period(context): deadline = now + settings.QUOTA_EXCEEDED_GRACE_PERIOD * 60 * 60 diff = max(0, deadline - now) if diff >= 60*60*24*2: - return _("within %(num)s days") % {"num": math.ceil(diff / (60*60*24))} - elif diff >= 60*60: - return _("within %(num)s hours") % {"num": math.ceil(diff / (60*60))} + return _("in %(num)s days") % {"num": math.floor(diff / (60*60*24))} + elif diff >= 60*60*2: + return _("in %(num)s hours") % {"num": math.floor(diff / (60*60))} elif diff > 1: - return _("within %(num)s minutes") % {"num": math.ceil(diff / 60)} + return _("in %(num)s minutes") % {"num": math.floor(diff / 60)} else: return _("very soon") diff --git a/app/tests/test_api_admin.py b/app/tests/test_api_admin.py index 7a0d1f7f0..a2c46b385 100644 --- a/app/tests/test_api_admin.py +++ b/app/tests/test_api_admin.py @@ -246,6 +246,8 @@ def test_profile(self): # Update quota deadlines + self.assertTrue(user.profile.get_quota_deadline() is None) + # Miss parameters res = client.post('/api/admin/profiles/%s/update_quota_deadline/' % user.id) self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/app/tests/test_login.py b/app/tests/test_login.py new file mode 100644 index 000000000..57f25a15c --- /dev/null +++ b/app/tests/test_login.py @@ -0,0 +1,34 @@ +import os +from django.test import Client +from webodm import settings +from .classes import BootTestCase + +class TestLogin(BootTestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_reset_password_render(self): + c = Client() + c.login(username="testuser", password="test1234") + + settings.RESET_PASSWORD_LINK = '' + + res = c.get('/login/', follow=True) + body = res.content.decode("utf-8") + + # The reset password link should show instructions + self.assertTrue("You can reset the administrator password" in body) + + settings.RESET_PASSWORD_LINK = 'http://0.0.0.0/reset_test' + + res = c.get('/login/', follow=True) + body = res.content.decode("utf-8") + + # The reset password link should show instructions + self.assertTrue('