Compare commits
1 Commits
master
...
feat-email
Author | SHA1 | Date |
---|---|---|
Hostea dashboard | 0c52da08d6 |
|
@ -77,7 +77,9 @@ class LoginTest(TestCase):
|
||||||
Tests if login template renders
|
Tests if login template renders
|
||||||
"""
|
"""
|
||||||
resp = self.client.get(reverse("accounts.login"))
|
resp = self.client.get(reverse("accounts.login"))
|
||||||
self.assertEqual(b"A free forge ecosystem for free developers" in resp.content, True)
|
self.assertEqual(
|
||||||
|
b"A free forge ecosystem for free developers" in resp.content, True
|
||||||
|
)
|
||||||
|
|
||||||
def test_login_works(self):
|
def test_login_works(self):
|
||||||
"""
|
"""
|
||||||
|
@ -234,7 +236,9 @@ class RegistrationTest(TestCase):
|
||||||
Tests if register template renders
|
Tests if register template renders
|
||||||
"""
|
"""
|
||||||
resp = self.client.get(reverse("accounts.register"))
|
resp = self.client.get(reverse("accounts.register"))
|
||||||
self.assertEqual(b"A free forge ecosystem for free developers." in resp.content, True)
|
self.assertEqual(
|
||||||
|
b"A free forge ecosystem for free developers." in resp.content, True
|
||||||
|
)
|
||||||
|
|
||||||
def test_register_works(self):
|
def test_register_works(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -24,8 +24,6 @@ from accounts.utils import gen_secret
|
||||||
from dash.models import Instance
|
from dash.models import Instance
|
||||||
from billing.utils import generate_invoice, payment_fullfilled
|
from billing.utils import generate_invoice, payment_fullfilled
|
||||||
|
|
||||||
Application = get_application_model()
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Generate invoices, should be run from cronjob scheduled for daily execution"
|
help = "Generate invoices, should be run from cronjob scheduled for daily execution"
|
||||||
|
|
|
@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .utils import is_url, is_email
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
@ -206,7 +208,7 @@ EMAIL_USE_SSL = False
|
||||||
EMAIL_PORT = 10025
|
EMAIL_PORT = 10025
|
||||||
EMAIL_HOST_USER = "admin"
|
EMAIL_HOST_USER = "admin"
|
||||||
EMAIL_HOST_PASSWORD = "password"
|
EMAIL_HOST_PASSWORD = "password"
|
||||||
DEFAULT_FROM_EMAIL: "no-reply@hostea.org"
|
DEFAULT_FROM_EMAIL = "no-reply@hostea.org"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from dashboard.local_settings import *
|
from dashboard.local_settings import *
|
||||||
|
@ -214,3 +216,14 @@ try:
|
||||||
print("Found local_settings")
|
print("Found local_settings")
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def verifiy_settings():
|
||||||
|
assert is_url(HOSTEA["META"]["GITEA_INSTANCE"])
|
||||||
|
assert is_url(PAYMENT_HOST)
|
||||||
|
|
||||||
|
assert is_email(DEFAULT_FROM_EMAIL)
|
||||||
|
assert is_email(HOSTEA["INSTANCE_MAINTAINER_CONTACT"])
|
||||||
|
|
||||||
|
|
||||||
|
verifiy_settings()
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
from django.core.validators import URLValidator, EmailValidator
|
||||||
|
|
||||||
|
|
||||||
|
def is_url(val: str) -> bool:
|
||||||
|
"""
|
||||||
|
Validate if the given value is a URL
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
URLValidator()(val)
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def is_email(val: str) -> bool:
|
||||||
|
"""
|
||||||
|
Validate if the given value is an email
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
EmailValidator()(val)
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
Loading…
Reference in New Issue