Skip to content

Commit

Permalink
Merge pull request #27 from Clivern/issue/dev-#26
Browse files Browse the repository at this point in the history
Issue/dev#28-Validation
  • Loading branch information
Clivern authored Apr 30, 2018
2 parents fe5342b + 17c367b commit e51f53c
Show file tree
Hide file tree
Showing 63 changed files with 5,714 additions and 280 deletions.
10 changes: 9 additions & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ MAIL_ENCRYPTION=null

ALLOWED_HOSTS=*
APP_TIMEZONE=UTC
APP_LANGUAGE=en-us
APP_LANGUAGE=en-us

DJANGO_LOGGING_HANDLERS=
DJANGO_LOGGING_LEVEL=warning
DJANGO_LOGGING_PROPAGATE=false

APP_LOGGING_HANDLERS=file
APP_LOGGING_LEVEL=warning
APP_LOGGING_PROPAGATE=true
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ MAIL_ENCRYPTION=null

ALLOWED_HOSTS=*
APP_TIMEZONE=UTC
APP_LANGUAGE=en-us
APP_LANGUAGE=en-us

DJANGO_LOGGING_HANDLERS=
DJANGO_LOGGING_LEVEL=warning
DJANGO_LOGGING_PROPAGATE=false

APP_LOGGING_HANDLERS=file
APP_LOGGING_LEVEL=warning
APP_LOGGING_PROPAGATE=true
File renamed without changes.
Empty file.
39 changes: 39 additions & 0 deletions app/controllers/api/private/v1/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Install API Endpoint
"""

from django.views import View
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from pprint import pprint

from app.modules.validation.form import Form
from app.modules.util.helpers import Helpers

@method_decorator(csrf_exempt, name='dispatch')
class Install(View):

_request = None
_request_data = {}

_helpers = None
_form = None

def __init__(self):
self._helpers = Helpers()
self._form = Form()

def post(self, request):
self._request = request
self._request_data = self._helpers.get_request_data(self._request.POST, {
"app_name" : "",
"app_email" : "",
"admin_username" : "",
"admin_email" : "",
"admin_password" : ""
})

print(self._request_data)

return JsonResponse({"status":"d"})
Empty file.
Empty file.
13 changes: 0 additions & 13 deletions app/controllers/api/v1/install.py

This file was deleted.

3 changes: 2 additions & 1 deletion app/controllers/web/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Error(View):

template_name = 'templates/500.html'

def get(self, request):
return render(request, self.template_name, {'page_title': '500'})
return render(request, self.template_name, {'page_title': _('500')}, status=500)
12 changes: 12 additions & 0 deletions app/controllers/web/forbidden.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Forbidden Access Views
"""

from django.http import JsonResponse

def csrf_failure(request, reason=""):
return JsonResponse({
"errors":[{
"message":"Access forbidden due to invalid or expired CSRF token!", "code":43
}]
}, status=403)
3 changes: 2 additions & 1 deletion app/controllers/web/forgot_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Forgot_Password(View):

template_name = 'templates/forgot_password.html'

def get(self, request):
return render(request, self.template_name, {'page_title': 'Forgot Password'})
return render(request, self.template_name, {'page_title': _('Forgot Password')})
1 change: 1 addition & 0 deletions app/controllers/web/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from app.modules.util.helpers import Helpers

class Home(View):

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/web/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _
from django.utils.translation import activate

class Install(View):

template_name = 'templates/install.html'

def get(self, request):
activate('fr')
return render(request, self.template_name, {'page_title': _('Installation')})
3 changes: 2 additions & 1 deletion app/controllers/web/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Login(View):

template_name = 'templates/login.html'

def get(self, request):
return render(request, self.template_name, {'page_title': 'Login'})
return render(request, self.template_name, {'page_title': _('Login')})
3 changes: 2 additions & 1 deletion app/controllers/web/not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Not_Found(View):

template_name = 'templates/404.html'

def get(self, request):
return render(request, self.template_name, {'page_title': '404'})
return render(request, self.template_name, {'page_title': _('404')}, status=404)
3 changes: 2 additions & 1 deletion app/controllers/web/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Register(View):

template_name = 'templates/register.html'

def get(self, request):
return render(request, self.template_name, {'page_title': 'Register'})
return render(request, self.template_name, {'page_title': _('Register')})
3 changes: 2 additions & 1 deletion app/controllers/web/reset_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _

class Reset_Password(View):

template_name = 'templates/reset_password.html'

def get(self, request, token):
return render(request, self.template_name, {'page_title': 'Reset Password'})
return render(request, self.template_name, {'page_title': _('Reset Password')})
Empty file added app/exceptions/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions app/exceptions/sanitization_rule_not_found.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Sanitization Rule Not Found
"""

class Sanitization_Rule_Not_Found(Exception):
"""Sanitization Rule Not Exist Custom Exception"""

def __init__(self, error_info):
Exception.__init__(self, "Sanitization Rule Not Found!")
self.error_info = error_info
10 changes: 10 additions & 0 deletions app/exceptions/validation_rule_not_found.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Validation Rule Not Found
"""

class Validation_Rule_Not_Found(Exception):
"""Validation Rule Not Exist Custom Exception"""

def __init__(self, error_info):
Exception.__init__(self, "Validation Rule Not Found!")
self.error_info = error_info
21 changes: 20 additions & 1 deletion app/modules/core/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@
"""

class Install():
pass

def is_db_connectd(self):
"""Check if DB Connection is Ok"""
pass

def is_db_migrated(self):
"""Check if DB Migrations Run"""
pass

def run_db_migrations(self):
"""Run DB Migrations"""
pass

def is_installed(self):
"""Check if App is Installed"""
pass

def install(data):
"""Install The Application"""
pass
17 changes: 17 additions & 0 deletions app/modules/core/upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Upgrade Module
"""

class Upgrade():

def need_upgrade(self):
"""Check if Application need upgrade"""
pass

def _get_latest_version(self):
"""Get Latest Stable Release"""
pass

def _get_current_version(self):
"""Get Current Version"""
pass
21 changes: 20 additions & 1 deletion app/modules/util/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,27 @@
"""

from django.utils.text import slugify
from django.utils.translation import activate
import logging

class Helpers():

def slugify(self, text, allow_unicode=False):
return slugify(text, allow_unicode=allow_unicode)
"""Create a slug"""
return slugify(text, allow_unicode=allow_unicode)

def get_logger(self, name = __name__):
"""Get Logger"""
return logging.getLogger(name)

def switch_language(self, language):
"""Switch to another language"""
activate(language)

def get_request_data(self, data_bag, predicted):
request_data = {}

for key, default in predicted.items():
request_data[key] = data_bag[key] if key in data_bag else default

return request_data
6 changes: 0 additions & 6 deletions app/modules/util/upgrade.py

This file was deleted.

Empty file.
3 changes: 3 additions & 0 deletions app/modules/validation/extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Validation Extensions
"""
Loading

0 comments on commit e51f53c

Please sign in to comment.