From 44dbc58f8bfa82ac0de4ad0bb0a837d6513aea4a Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Tue, 5 Jan 2016 21:47:24 +0100 Subject: [PATCH] move server in another git repository --- server/__init__.py | 0 server/api/__init__.py | 0 server/api/admin.py | 0 server/api/apps.py | 5 -- server/api/migrations/0001_initial.py | 35 ----------- server/api/migrations/__init__.py | 0 server/api/models.py | 18 ------ server/api/permissions.py | 6 -- server/api/serializers.py | 9 --- server/api/tests/__init__.py | 0 server/api/tests/factories.py | 30 --------- server/api/tests/tests_site.py | 46 -------------- server/api/urls.py | 11 ---- server/api/views.py | 13 ---- server/config/config.ini | 3 - server/lesspass/__init__.py | 0 server/lesspass/settings.py | 111 ---------------------------------- server/lesspass/urls.py | 7 --- server/lesspass/wsgi.py | 7 --- server/manage.py | 10 --- server/requirements.dev.txt | 2 - server/requirements.txt | 3 - 22 files changed, 316 deletions(-) delete mode 100644 server/__init__.py delete mode 100644 server/api/__init__.py delete mode 100644 server/api/admin.py delete mode 100644 server/api/apps.py delete mode 100644 server/api/migrations/0001_initial.py delete mode 100644 server/api/migrations/__init__.py delete mode 100644 server/api/models.py delete mode 100644 server/api/permissions.py delete mode 100644 server/api/serializers.py delete mode 100644 server/api/tests/__init__.py delete mode 100644 server/api/tests/factories.py delete mode 100644 server/api/tests/tests_site.py delete mode 100644 server/api/urls.py delete mode 100644 server/api/views.py delete mode 100644 server/config/config.ini delete mode 100644 server/lesspass/__init__.py delete mode 100644 server/lesspass/settings.py delete mode 100644 server/lesspass/urls.py delete mode 100644 server/lesspass/wsgi.py delete mode 100644 server/manage.py delete mode 100644 server/requirements.dev.txt delete mode 100644 server/requirements.txt diff --git a/server/__init__.py b/server/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/api/__init__.py b/server/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/api/admin.py b/server/api/admin.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/api/apps.py b/server/api/apps.py deleted file mode 100644 index d87006d..0000000 --- a/server/api/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class ApiConfig(AppConfig): - name = 'api' diff --git a/server/api/migrations/0001_initial.py b/server/api/migrations/0001_initial.py deleted file mode 100644 index f17f3e7..0000000 --- a/server/api/migrations/0001_initial.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9 on 2015-12-18 09:18 -from __future__ import unicode_literals - -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), - ] - - operations = [ - migrations.CreateModel( - name='Site', - fields=[ - ('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(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'abstract': False, - }, - ), - ] diff --git a/server/api/migrations/__init__.py b/server/api/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/api/models.py b/server/api/models.py deleted file mode 100644 index e916d5d..0000000 --- a/server/api/models.py +++ /dev/null @@ -1,18 +0,0 @@ -from django.db import models -from django.contrib.auth.models import User - - -class DateMixin(models.Model): - created = models.DateTimeField(auto_now_add=True, verbose_name='created') - modified = models.DateTimeField(auto_now=True, verbose_name='modified') - - class Meta: - abstract = True - - -class Site(DateMixin): - user = models.ForeignKey(User, on_delete=models.CASCADE) - name = models.CharField(max_length=255) - password_length = models.IntegerField() - password_type = models.CharField(max_length=255) - counter = models.IntegerField(default=1) diff --git a/server/api/permissions.py b/server/api/permissions.py deleted file mode 100644 index e792667..0000000 --- a/server/api/permissions.py +++ /dev/null @@ -1,6 +0,0 @@ -from rest_framework import permissions - - -class IsOwner(permissions.IsAuthenticated): - def has_object_permission(self, request, view, obj): - return obj.user == request.user diff --git a/server/api/serializers.py b/server/api/serializers.py deleted file mode 100644 index 95abe86..0000000 --- a/server/api/serializers.py +++ /dev/null @@ -1,9 +0,0 @@ -from rest_framework import serializers - -from api.models import Site - - -class SiteSerializer(serializers.ModelSerializer): - class Meta: - model = Site - fields = ('user', 'name', 'password_length', 'password_type', 'counter', 'created', 'modified') diff --git a/server/api/tests/__init__.py b/server/api/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/api/tests/factories.py b/server/api/tests/factories.py deleted file mode 100644 index 064a9fc..0000000 --- a/server/api/tests/factories.py +++ /dev/null @@ -1,30 +0,0 @@ -import factory - -from api import models - - -class UserFactory(factory.DjangoModelFactory): - class Meta: - model = models.User - - username = factory.Sequence(lambda n: 'username{0}'.format(n)) - first_name = factory.Faker('first_name') - last_name = factory.Faker('last_name') - email = factory.LazyAttribute(lambda a: '{0}.{1}@oslab.fr'.format(a.first_name, a.last_name).lower()) - password = factory.PostGenerationMethodCall('set_password', 'password') - is_staff = False - - -class AdminFactory(UserFactory): - is_staff = True - - -class SiteFactory(factory.DjangoModelFactory): - class Meta: - model = models.Site - - user = factory.SubFactory(UserFactory) - name = 'facebook' - password_length = 12 - password_type = 'strong' - counter = 1 diff --git a/server/api/tests/tests_site.py b/server/api/tests/tests_site.py deleted file mode 100644 index 4a69d7e..0000000 --- a/server/api/tests/tests_site.py +++ /dev/null @@ -1,46 +0,0 @@ -from rest_framework.test import APITestCase, APIClient - -from api import models -from api.tests import factories - - -class LogoutApiTestCase(APITestCase): - def test_get_sites_403(self): - response = self.client.get('/api/sites/') - self.assertEqual(403, response.status_code) - - -class LoginApiTestCase(APITestCase): - def setUp(self): - self.user = factories.UserFactory() - self.client = APIClient() - self.client.force_authenticate(user=self.user) - - def test_get_empty_sites(self): - request = self.client.get('/api/sites/') - self.assertEqual(0, len(request.data['results'])) - - def test_retrieve_its_own_sites(self): - site = factories.SiteFactory(user=self.user) - request = self.client.get('/api/sites/') - self.assertEqual(1, len(request.data['results'])) - self.assertEqual(site.name, request.data['results'][0]['name']) - - def test_cant_retrieve_other_sites(self): - not_my_site = factories.SiteFactory(user=factories.UserFactory()) - request = self.client.get('/api/sites/%s/' % not_my_site.id) - self.assertEqual(404, request.status_code) - - def test_delete_its_own_sites(self): - site = factories.SiteFactory(user=self.user) - self.assertEqual(1, models.Site.objects.all().count()) - request = self.client.delete('/api/sites/%s/' % site.id) - self.assertEqual(204, request.status_code) - self.assertEqual(0, models.Site.objects.all().count()) - - def test_cant_delete_other_site(self): - not_my_site = factories.SiteFactory(user=factories.UserFactory()) - self.assertEqual(1, models.Site.objects.all().count()) - request = self.client.delete('/api/sites/%s/' % not_my_site.id) - self.assertEqual(404, request.status_code) - self.assertEqual(1, models.Site.objects.all().count()) diff --git a/server/api/urls.py b/server/api/urls.py deleted file mode 100644 index 12dc1b0..0000000 --- a/server/api/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -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, base_name='sites') - -urlpatterns = [ - url(r'^', include(router.urls)), -] diff --git a/server/api/views.py b/server/api/views.py deleted file mode 100644 index 098a45f..0000000 --- a/server/api/views.py +++ /dev/null @@ -1,13 +0,0 @@ -from rest_framework import viewsets - -from api import models -from api.permissions import IsOwner -from api.serializers import SiteSerializer - - -class SiteViewSet(viewsets.ModelViewSet): - serializer_class = SiteSerializer - permission_classes = (IsOwner,) - - def get_queryset(self): - return models.Site.objects.filter(user=self.request.user) diff --git a/server/config/config.ini b/server/config/config.ini deleted file mode 100644 index 69296c2..0000000 --- a/server/config/config.ini +++ /dev/null @@ -1,3 +0,0 @@ -[DJANGO] -secret_key = 4f(fn@)x_512yrs_yc063fw12&bg7h83gehxkg@9*bvk8g^zmf - diff --git a/server/lesspass/__init__.py b/server/lesspass/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/server/lesspass/settings.py b/server/lesspass/settings.py deleted file mode 100644 index 33f4f26..0000000 --- a/server/lesspass/settings.py +++ /dev/null @@ -1,111 +0,0 @@ -import os -from smartconfigparser import Config - -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -CONFIG_PATH = os.path.join(BASE_DIR, 'config') -if not os.path.exists(CONFIG_PATH): - os.makedirs(CONFIG_PATH) - -CONFIG_FILE = os.path.join(CONFIG_PATH, 'config.ini') -config = Config() -config.read(CONFIG_FILE) - -try: - SECRET_KEY = config.get('DJANGO', 'SECRET_KEY') -except: - print('SECRET_KEY not found! Generating a new one...') - import random - - SECRET_KEY = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$^&*(-_=+)") for i in range(50)]) - if not config.has_section('DJANGO'): - config.add_section('DJANGO') - config.set('DJANGO', 'SECRET_KEY', SECRET_KEY) - with open(CONFIG_FILE, 'wt') as f: - config.write(f) - -DEBUG = config.getboolean('DJANGO', 'DEBUG', False) - -ALLOWED_HOSTS = config.getlist('DJANGO', 'ALLOWED_HOSTS', ['localhost', '127.0.0.1', '*.oslab.fr']) - -INSTALLED_APPS = [ - 'api.apps.ApiConfig', - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'rest_framework' -] - -MIDDLEWARE_CLASSES = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'lesspass.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'lesspass.wsgi.application' - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - -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' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - -STATIC_URL = '/static/' - -REST_FRAMEWORK = { - 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',), - 'PAGE_SIZE': 100, - 'TEST_REQUEST_DEFAULT_FORMAT': 'json' -} diff --git a/server/lesspass/urls.py b/server/lesspass/urls.py deleted file mode 100644 index 3220c19..0000000 --- a/server/lesspass/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -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/server/lesspass/wsgi.py b/server/lesspass/wsgi.py deleted file mode 100644 index bc4d7c4..0000000 --- a/server/lesspass/wsgi.py +++ /dev/null @@ -1,7 +0,0 @@ -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/server/manage.py deleted file mode 100644 index 1571b63..0000000 --- a/server/manage.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lesspass.settings") - - from django.core.management import execute_from_command_line - - execute_from_command_line(sys.argv) diff --git a/server/requirements.dev.txt b/server/requirements.dev.txt deleted file mode 100644 index 9083937..0000000 --- a/server/requirements.dev.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements.txt -factory-boy==2.6.0 \ No newline at end of file diff --git a/server/requirements.txt b/server/requirements.txt deleted file mode 100644 index 960cd83..0000000 --- a/server/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Django==1.9 -djangorestframework==3.3.2 -smartconfigparser==0.1.1 \ No newline at end of file