diff --git a/.gitignore b/.gitignore index b59ca0b..e9d841f 100644 --- a/.gitignore +++ b/.gitignore @@ -85,5 +85,5 @@ docs/_build/ # PyBuilder target/ -/server/config -/server/db.sqlite3 +/lesspass/config +/lesspass/db.sqlite3 diff --git a/server/api/__init__.py b/lesspass/__init__.py similarity index 100% rename from server/api/__init__.py rename to lesspass/__init__.py diff --git a/server/api/migrations/__init__.py b/lesspass/api/__init__.py similarity index 100% rename from server/api/migrations/__init__.py rename to lesspass/api/__init__.py diff --git a/server/api/admin.py b/lesspass/api/admin.py similarity index 100% rename from server/api/admin.py rename to lesspass/api/admin.py diff --git a/lesspass/api/apps.py b/lesspass/api/apps.py new file mode 100644 index 0000000..d87006d --- /dev/null +++ b/lesspass/api/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + name = 'api' diff --git a/server/api/migrations/0001_initial.py b/lesspass/api/migrations/0001_initial.py similarity index 73% rename from server/api/migrations/0001_initial.py rename to lesspass/api/migrations/0001_initial.py index c787360..f17f3e7 100644 --- a/server/api/migrations/0001_initial.py +++ b/lesspass/api/migrations/0001_initial.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-18 09:18 from __future__ import unicode_literals -from django.db import migrations, models from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion class Migration(migrations.Migration): + initial = True + dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] @@ -15,14 +19,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Site', fields=[ - ('id', models.AutoField(auto_created=True, serialize=False, primary_key=True, verbose_name='ID')), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateTimeField(auto_now_add=True, verbose_name='created')), ('modified', models.DateTimeField(auto_now=True, verbose_name='modified')), ('name', models.CharField(max_length=255)), ('password_length', models.IntegerField()), ('password_type', models.CharField(max_length=255)), ('counter', models.IntegerField(default=1)), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'abstract': False, diff --git a/server/lesspass/__init__.py b/lesspass/api/migrations/__init__.py similarity index 100% rename from server/lesspass/__init__.py rename to lesspass/api/migrations/__init__.py diff --git a/server/api/models.py b/lesspass/api/models.py similarity index 100% rename from server/api/models.py rename to lesspass/api/models.py diff --git a/server/api/serializers.py b/lesspass/api/serializers.py similarity index 99% rename from server/api/serializers.py rename to lesspass/api/serializers.py index ac773d5..95abe86 100644 --- a/server/api/serializers.py +++ b/lesspass/api/serializers.py @@ -1,6 +1,7 @@ -from api.models import Site from rest_framework import serializers +from api.models import Site + class SiteSerializer(serializers.ModelSerializer): class Meta: diff --git a/server/api/tests.py b/lesspass/api/tests.py similarity index 100% rename from server/api/tests.py rename to lesspass/api/tests.py diff --git a/lesspass/api/urls.py b/lesspass/api/urls.py new file mode 100644 index 0000000..daaa03e --- /dev/null +++ b/lesspass/api/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls import include, url +from rest_framework import routers + +from api import views + +router = routers.DefaultRouter() +router.register(r'sites', views.SiteViewSet) + +urlpatterns = [ + url(r'^', include(router.urls)), +] diff --git a/server/api/views.py b/lesspass/api/views.py similarity index 71% rename from server/api/views.py rename to lesspass/api/views.py index 1f4877a..d32918e 100644 --- a/server/api/views.py +++ b/lesspass/api/views.py @@ -1,8 +1,9 @@ -from api.models import Site -from api.serializers import SiteSerializer from rest_framework import viewsets +from api import models +from api.serializers import SiteSerializer + class SiteViewSet(viewsets.ModelViewSet): - queryset = Site.objects.all() + queryset = models.Site.objects.all() serializer_class = SiteSerializer diff --git a/lesspass/lesspass/__init__.py b/lesspass/lesspass/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/lesspass/settings.py b/lesspass/lesspass/settings.py similarity index 81% rename from server/lesspass/settings.py rename to lesspass/lesspass/settings.py index 2a689ea..c342fec 100644 --- a/server/lesspass/settings.py +++ b/lesspass/lesspass/settings.py @@ -1,9 +1,10 @@ import os -from smartconfigparser import Config - +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +from smartconfigparser import Config + CONFIG_PATH = os.path.join(BASE_DIR, 'config') if not os.path.exists(CONFIG_PATH): os.makedirs(CONFIG_PATH) @@ -29,18 +30,19 @@ DEBUG = config.getboolean('DJANGO', 'DEBUG', False) ALLOWED_HOSTS = config.getlist('DJANGO', 'ALLOWED_HOSTS', ['localhost', '127.0.0.1', '*.oslab.fr']) -INSTALLED_APPS = ( +INSTALLED_APPS = [ + 'api.apps.ApiConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'api', - 'rest_framework', -) + 'rest_framework' +] -MIDDLEWARE_CLASSES = ( +MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -48,8 +50,7 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.security.SecurityMiddleware', -) +] ROOT_URLCONF = 'lesspass.urls' @@ -71,7 +72,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'lesspass.wsgi.application' - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -79,6 +79,21 @@ DATABASES = { } } +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' @@ -94,4 +109,4 @@ STATIC_URL = '/static/' REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',), 'PAGE_SIZE': 10 -} \ No newline at end of file +} diff --git a/lesspass/lesspass/urls.py b/lesspass/lesspass/urls.py new file mode 100644 index 0000000..3220c19 --- /dev/null +++ b/lesspass/lesspass/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import include, url +from django.contrib import admin + +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^api/', include('api.urls')), +] diff --git a/lesspass/lesspass/wsgi.py b/lesspass/lesspass/wsgi.py new file mode 100644 index 0000000..bc4d7c4 --- /dev/null +++ b/lesspass/lesspass/wsgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lesspass.settings") + +application = get_wsgi_application() diff --git a/server/manage.py b/lesspass/manage.py old mode 100755 new mode 100644 similarity index 100% rename from server/manage.py rename to lesspass/manage.py diff --git a/lesspass/requirements.txt b/lesspass/requirements.txt new file mode 100644 index 0000000..960cd83 --- /dev/null +++ b/lesspass/requirements.txt @@ -0,0 +1,3 @@ +Django==1.9 +djangorestframework==3.3.2 +smartconfigparser==0.1.1 \ No newline at end of file diff --git a/server/lesspass/urls.py b/server/lesspass/urls.py deleted file mode 100644 index 2444ad1..0000000 --- a/server/lesspass/urls.py +++ /dev/null @@ -1,12 +0,0 @@ -from api import views -from django.conf.urls import include, url -from django.contrib import admin -from rest_framework import routers - -router = routers.DefaultRouter() -router.register(r'users', views.SiteViewSet) - -urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), - url(r'^api/', include('rest_framework.urls', namespace='rest_framework')) -] diff --git a/server/lesspass/wsgi.py b/server/lesspass/wsgi.py deleted file mode 100644 index b8941f4..0000000 --- a/server/lesspass/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for lesspass project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lesspass.settings") - -application = get_wsgi_application() diff --git a/server/requirements.txt b/server/requirements.txt deleted file mode 100644 index 6d25f09..0000000 --- a/server/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Django==1.8.7 -djangorestframework==3.3.2 -smartconfigparser==0.1.1 \ No newline at end of file