diff --git a/.gitignore b/.gitignore index 18c39c2e..d1788aba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ -# database -*.sqlite3 - # python *.pyc -# static files -babyblotter/static \ No newline at end of file +# database +*.sqlite3 \ No newline at end of file diff --git a/Pipfile b/Pipfile index cccf5ddf..6c028281 100644 --- a/Pipfile +++ b/Pipfile @@ -6,5 +6,3 @@ url = "https://pypi.python.org/simple" django = "*" djangorestframework = "*" django-filter = "*" -django-angular = "*" -whitenoise = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 2863213f..8d6b5c62 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "58ee3f51b748a5b05db80eda5a1885ac84e5645f540c5d67a00555a2b1156cc1" + "sha256": "a0ef885217179eed1565af7ec6a732e8b141fb42c156f152380a65feac7cb1fe" }, "requires": {}, "sources": [ @@ -15,9 +15,6 @@ "django": { "version": "==1.11.4" }, - "django-angular": { - "version": "==1.1" - }, "django-filter": { "version": "==1.0.4" }, @@ -26,9 +23,6 @@ }, "pytz": { "version": "==2017.2" - }, - "whitenoise": { - "version": "==3.3.0" } }, "develop": {} diff --git a/babyblotter/settings.py b/babyblotter/settings.py index 26de0927..c55c5be4 100644 --- a/babyblotter/settings.py +++ b/babyblotter/settings.py @@ -22,7 +22,6 @@ INSTALLED_APPS = [ 'api', 'core', - 'djng', 'rest_framework', 'django.contrib.admin', @@ -35,9 +34,6 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', - - 'whitenoise.middleware.WhiteNoiseMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -95,22 +91,8 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' - -STATICFILES_FINDERS = [ - 'django.contrib.staticfiles.finders.FileSystemFinder', - 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -] - STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'babyblotter/static') - - -# Form rendering -# https://docs.djangoproject.com/en/1.11/ref/settings/#form-renderer -FORM_RENDERER = 'djng.forms.renderers.DjangoAngularBootstrap3Templates' - # Django Rest Framework # http://www.django-rest-framework.org/# diff --git a/babyblotter/urls.py b/babyblotter/urls.py index a7249395..f048260a 100644 --- a/babyblotter/urls.py +++ b/babyblotter/urls.py @@ -4,11 +4,7 @@ from __future__ import unicode_literals from django.conf.urls import url, include from django.contrib import admin -from core import views - urlpatterns = [ - url(r'^baby/add/$', views.BabyFormView.as_view(), name='baby_add'), - url(r'^admin/', admin.site.urls), url(r'', include('api.urls')), ] diff --git a/core/forms.py b/core/forms.py deleted file mode 100644 index 07520fc7..00000000 --- a/core/forms.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.core.exceptions import ValidationError -from django.forms import widgets -from djng.forms import fields, NgModelFormMixin, NgFormValidationMixin -from djng.styling.bootstrap3.forms import Bootstrap3Form - - -class BabyForm(NgModelFormMixin, NgFormValidationMixin, Bootstrap3Form): - use_required_attribute = False - scope_prefix = 'subscribe_data' - form_name = 'baby_new' - - first_name = fields.CharField( - label='First name', - min_length=3, - max_length=20) - - last_name = fields.RegexField( - r'^[A-Z][a-z -]?', - label='Last name', - error_messages={'invalid': 'Last names shall start in upper case'}) - - birth_date = fields.DateField( - label='Date of birth', - widget=widgets.DateInput(attrs={'validate-date': '^(\d{4})-(\d{1,2})-(\d{1,2})$'}), - help_text='Allowed date format: yyyy-mm-dd') - - def clean(self): - if self.cleaned_data.get( - 'first_name') == 'John' and self.cleaned_data.get( - 'last_name') == 'Doe': - raise ValidationError( - 'The full name "John Doe" is rejected by the server.') - return super(BabyForm, self).clean() diff --git a/core/templates/baby-form.html b/core/templates/baby-form.html deleted file mode 100644 index fae8235f..00000000 --- a/core/templates/baby-form.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Add Baby Form{% endblock %} - -{% block head %} - -{% endblock %} - -{% block content %} -
- {% csrf_token %} - {{ form.as_div }} - - -
-{% endblock %} \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html deleted file mode 100644 index 51247a12..00000000 --- a/core/templates/base.html +++ /dev/null @@ -1,40 +0,0 @@ -{% load static djng_tags %} - - - - - {% block form_title %}Baby Blotter{% endblock %} - - - - - - - - - - -
-
- -
- {% block content %}{% endblock %} -
-
-
- - \ No newline at end of file diff --git a/core/views.py b/core/views.py deleted file mode 100644 index 3e404503..00000000 --- a/core/views.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import json - -from django.http import HttpResponse -from django.core.urlresolvers import reverse_lazy -from django.views.generic.edit import FormView -from django.utils.encoding import force_text - -from core.forms import BabyForm - - -class BabyFormView(FormView): - template_name = 'baby-form.html' - form_class = BabyForm - success_url = reverse_lazy('form_data_valid') - - def post(self, request, **kwargs): - if request.is_ajax(): - return self.ajax(request) - return super(BabyFormView, self).post(request, **kwargs) - - def ajax(self, request): - form = self.form_class(data=json.loads(request.body)) - response_data = {'errors': form.errors, 'success_url': force_text(self.success_url)} - return HttpResponse(json.dumps(response_data), content_type="application/json")