From 65319047b82bd0a75f74352e4051ea8f4605e5d5 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 5 Nov 2020 16:49:05 +0200 Subject: [PATCH] Remove leftover files from EteSync 1.0. No idea how they got here. --- etesync-server.ini.example | 15 --- etesync_server/__init__.py | 14 --- etesync_server/settings.py | 185 ------------------------------------- etesync_server/urls.py | 70 -------------- etesync_server/utils.py | 25 ----- etesync_server/wsgi.py | 16 ---- 6 files changed, 325 deletions(-) delete mode 100644 etesync-server.ini.example delete mode 100644 etesync_server/__init__.py delete mode 100644 etesync_server/settings.py delete mode 100644 etesync_server/urls.py delete mode 100644 etesync_server/utils.py delete mode 100644 etesync_server/wsgi.py diff --git a/etesync-server.ini.example b/etesync-server.ini.example deleted file mode 100644 index 424a26d..0000000 --- a/etesync-server.ini.example +++ /dev/null @@ -1,15 +0,0 @@ -[global] -secret_file = secret.txt -debug = false -;Advanced options, only uncomment if you know what you're doing: -;static_root = /path/to/static -;static_url = /static/ -;language_code = en-us -;time_zone = UTC - -[allowed_hosts] -allowed_host1 = example.com - -[database] -engine = django.db.backends.sqlite3 -name = db.sqlite3 diff --git a/etesync_server/__init__.py b/etesync_server/__init__.py deleted file mode 100644 index 227e8c9..0000000 --- a/etesync_server/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright © 2017 Tom Hacohen -# -# 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, version 3. -# -# This library 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - diff --git a/etesync_server/settings.py b/etesync_server/settings.py deleted file mode 100644 index cca7915..0000000 --- a/etesync_server/settings.py +++ /dev/null @@ -1,185 +0,0 @@ -# Copyright © 2017 Tom Hacohen -# -# 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, version 3. -# -# This library 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Django settings for etesync_server project. - -Generated by 'django-admin startproject' using Django 2.0.5. - -For more information on this file, see -https://docs.djangoproject.com/en/2.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.0/ref/settings/ -""" - -import os -import configparser -from .utils import get_secret_from_file - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -# See secret.py for how this is generated; uses a file 'secret.txt' in the root -# directory -SECRET_FILE = os.path.join(BASE_DIR, "secret.txt") - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False - -ALLOWED_HOSTS = [] - -# Database -# https://docs.djangoproject.com/en/2.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.environ.get('ETESYNC_DB_PATH', - os.path.join(BASE_DIR, 'db.sqlite3')), - } -} - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'corsheaders', - 'rest_framework', - 'rest_framework.authtoken', - 'journal.apps.JournalConfig', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'etesync_server.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - os.path.join(BASE_DIR, 'templates') - ], - '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 = 'etesync_server.wsgi.application' - - -# Password validation -# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators - -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', - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.0/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.0/howto/static-files/ - -STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'static/') - - -# Define where to find configuration files -config_locations = ['etesync-server.ini', '/etc/etesync-server/etesync-server.ini'] -# Use config file if present -if any(os.path.isfile(x) for x in config_locations): - config = configparser.ConfigParser() - config.read(config_locations) - - section = config['global'] - - SECRET_FILE = section.get('secret_file', SECRET_FILE) - STATIC_ROOT = section.get('static_root', STATIC_ROOT) - STATIC_URL = section.get('static_url', STATIC_URL) - LANGUAGE_CODE = section.get('language_code', LANGUAGE_CODE) - TIME_ZONE = section.get('time_zone', TIME_ZONE) - DEBUG = section.getboolean('debug', DEBUG) - - if 'allowed_hosts' in config: - ALLOWED_HOSTS = [y for x, y in config.items('allowed_hosts')] - - if 'database' in config: - DATABASES = { 'default': { x.upper(): y for x, y in config.items('database') } } - -JOURNAL_API_PERMISSIONS = ( - 'rest_framework.permissions.IsAuthenticated', - ) - -# Cors -CORS_ORIGIN_ALLOW_ALL = True - -# Make an `etesync_site_settings` module available to override settings. -try: - from etesync_site_settings import * -except ImportError: - pass - -if 'SECRET_KEY' not in locals(): - SECRET_KEY = get_secret_from_file(SECRET_FILE) diff --git a/etesync_server/urls.py b/etesync_server/urls.py deleted file mode 100644 index feb8892..0000000 --- a/etesync_server/urls.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright © 2017 Tom Hacohen -# -# 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, version 3. -# -# This library 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""etesync_server URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.conf import settings -from django.urls import include, path, re_path -from django.contrib import admin -from django.views.generic import TemplateView - -from rest_framework_nested import routers -from rest_framework.authtoken import views as token_views -from rest_framework.decorators import api_view -from rest_framework.response import Response - -from journal import views - -router = routers.DefaultRouter() -router.register(r'journals', views.JournalViewSet) -router.register(r'journal/(?P[^/]+)', views.EntryViewSet) -router.register(r'user', views.UserInfoViewSet) - -journals_router = routers.NestedSimpleRouter(router, r'journals', lookup='journal') -journals_router.register(r'members', views.MembersViewSet, basename='journal-members') -journals_router.register(r'entries', views.EntryViewSet, basename='journal-entries') - - -@api_view(['POST']) -def nop_view(request): - return Response({}) - - -urlpatterns = [ - re_path(r'^api/v1/', include(router.urls)), - re_path(r'^api/v1/', include(journals_router.urls)), - re_path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), - re_path(r'^api-token-auth/', token_views.obtain_auth_token), - path('api/logout/', nop_view), - path('admin/', admin.site.urls), - path('', TemplateView.as_view(template_name='success.html')), -] - -if settings.DEBUG: - urlpatterns = [ - path('reset/', views.reset, name='reset_debug'), - ] + urlpatterns diff --git a/etesync_server/utils.py b/etesync_server/utils.py deleted file mode 100644 index 21c99f2..0000000 --- a/etesync_server/utils.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright © 2017 Tom Hacohen -# -# 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, version 3. -# -# This library 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from django.core.management import utils - -def get_secret_from_file(path): - try: - with open(path, "r") as f: - return f.read().strip() - except EnvironmentError: - with open(path, "w") as f: - secret_key = utils.get_random_secret_key() - f.write(secret_key) - return secret_key diff --git a/etesync_server/wsgi.py b/etesync_server/wsgi.py deleted file mode 100644 index 6738999..0000000 --- a/etesync_server/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for etesync_server 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/2.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "etesync_server.settings") - -application = get_wsgi_application()