Skip to content

Commit

Permalink
Merge pull request #383 from RockefellerArchiveCenter/v2.0
Browse files Browse the repository at this point in the history
v2.0
  • Loading branch information
helrond authored May 4, 2020
2 parents 992d2a7 + 474687c commit 2b09ac8
Show file tree
Hide file tree
Showing 354 changed files with 4,983 additions and 4,846 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env/
/scripts/ldap.*
.DS_Store
__pycache__
*.pyc
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ before_install:
- cp aurora/aurora/config.py.example aurora/aurora/config.py
- docker-compose up -d
- sleep 60s
- docker-compose exec web pip install coverage
install: true
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2.7
FROM python:3.6

ENV PYTHONUNBUFFERED 1

Expand Down
111 changes: 51 additions & 60 deletions aurora/aurora/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

import os
import sys

from aurora import config as CF

Expand All @@ -22,7 +21,7 @@
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=*+t-qchu_$#hhf9m-n45s7p=@n46(zmf^mof$+cdaa0t6h8pq'
SECRET_KEY = "=*+t-qchu_$#hhf9m-n45s7p=@n46(zmf^mof$+cdaa0t6h8pq"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = CF.DEBUG
Expand All @@ -33,96 +32,88 @@

# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cron',
'rest_framework',
'drf_yasg',
'bag_transfer',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_cron",
"rest_framework",
'health_check',
"bag_transfer",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'bag_transfer.middleware.AuthenticationMiddlewareJWT',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"bag_transfer.middleware.AuthenticationMiddlewareJWT",
]

ROOT_URLCONF = 'aurora.urls'
ROOT_URLCONF = "aurora.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'bag_transfer', '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',
'bag_transfer.context_processors.gtm_id',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "bag_transfer", "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",
"bag_transfer.context_processors.gtm_id",
],
},
},
]

LOGIN_REDIRECT_URL = 'app_home'
LOGIN_REDIRECT_URL = "app_home"

WSGI_APPLICATION = 'aurora.wsgi.application'
WSGI_APPLICATION = "aurora.wsgi.application"

REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 50,
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"PAGE_SIZE": 50,
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_jwt.authentication.JSONWebTokenAuthentication",
"rest_framework.authentication.SessionAuthentication",
),
}

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': CF.DEFAULT_DB,
"default": CF.DEFAULT_DB,
}

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)

# Password validation
# https://docs.djangoproject.com/en/1.11/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',
"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",},
]

AUTH_USER_MODEL = 'bag_transfer.User'
LOGIN_REDIRECT_URL = '/app'
AUTH_USER_MODEL = "bag_transfer.User"
LOGIN_REDIRECT_URL = "/app"

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"
TIME_ZONE = CF.TIME_ZONE
USE_I18N = True
USE_L10N = True
Expand All @@ -131,7 +122,7 @@

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_URL = "/static/"
STATIC_ROOT = CF.STATIC_ROOT
STORAGE_ROOT_DIR = CF.STORAGE_ROOT_DIR
DELIVERY_QUEUE_DIR = CF.DELIVERY_QUEUE_DIR
Expand All @@ -151,8 +142,8 @@
"django_cron.backends.lock.file.FileLock",
]

#Django Cron Lock
DJANGO_CRON_LOCK_BACKEND="django_cron.backends.lock.file.FileLock"
# Django Cron Lock
DJANGO_CRON_LOCK_BACKEND = "django_cron.backends.lock.file.FileLock"

# Email
EMAIL_HOST = CF.EMAIL_HOST
Expand All @@ -173,8 +164,8 @@


# Post-accession callbacks
DELIVERY_URL = getattr(CF, 'DELIVERY_URL', None)
API_KEY = getattr(CF, 'API_KEY', None)
DELIVERY_URL = getattr(CF, "DELIVERY_URL", None)
API_KEY = getattr(CF, "API_KEY", None)

# ArchivesSpace configs
ASPACE = CF.ASPACE
Expand Down
75 changes: 53 additions & 22 deletions aurora/aurora/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,61 @@
"""
from django.conf.urls import url, include
from django.contrib import admin
from bag_transfer.users.views import *
from bag_transfer.users.form import UserPasswordResetForm, UserSetPasswordForm
from bag_transfer.users.views import (
SplashView,
UserPasswordResetView,
UserPasswordResetDoneView,
UserPasswordResetConfirmView,
UserPasswordResetCompleteView,
)
from django.contrib.auth import views as auth_views
from bag_transfer.transfers.views import MainView

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^app/$', MainView.as_view(), name='app_home'),
url(r'^app/transfers/', include('bag_transfer.transfers.urls', namespace='transfers')),
url(r'^app/orgs/', include('bag_transfer.orgs.urls', namespace='orgs')),
url(r'^app/users/', include('bag_transfer.users.urls', namespace='users')),
url(r'^reset-password/$', UserPasswordResetView.as_view(
email_template_name='users/password_reset_email.html',
subject_template_name='users/password_reset_subject.txt'
), name='password_reset'),
url(r'^reset-password/done/$', UserPasswordResetDoneView.as_view(), name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
UserPasswordResetConfirmView.as_view(), name='password_reset_confirm'),
url(r'^reset/done/$', UserPasswordResetCompleteView.as_view(), name='password_reset_complete'),
url(r'^app/accession/', include('bag_transfer.accession.urls', namespace='accession')),
url(r'^app/appraise/', include('bag_transfer.appraise.urls', namespace='appraise')),
url(r'^app/rights/', include('bag_transfer.rights.urls', namespace='rights')),
url(r'^$', SplashView.as_view()),
url(r'^login/$', auth_views.login, {'template_name': 'users/login.html'}, name='login'),
url(r'^logout/$', auth_views.logout, {'next_page': '/login'}, name='logout'),
url(r'^api/', include('bag_transfer.api.urls')),
url(r"^admin/", admin.site.urls),
url(r"^app/$", MainView.as_view(), name="app_home"),
url(
r"^app/transfers/",
include("bag_transfer.transfers.urls", namespace="transfers"),
),
url(r"^app/orgs/", include("bag_transfer.orgs.urls", namespace="orgs")),
url(r"^app/users/", include("bag_transfer.users.urls", namespace="users")),
url(
r"^reset-password/$",
UserPasswordResetView.as_view(
email_template_name="users/password_reset_email.html",
subject_template_name="users/password_reset_subject.txt",
),
name="password_reset",
),
url(
r"^reset-password/done/$",
UserPasswordResetDoneView.as_view(),
name="password_reset_done",
),
url(
r"^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$",
UserPasswordResetConfirmView.as_view(),
name="password_reset_confirm",
),
url(
r"^reset/done/$",
UserPasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
url(
r"^app/accession/",
include("bag_transfer.accession.urls", namespace="accession"),
),
url(r"^app/appraise/", include("bag_transfer.appraise.urls", namespace="appraise")),
url(r"^app/rights/", include("bag_transfer.rights.urls", namespace="rights")),
url(r"^$", SplashView.as_view()),
url(
r"^login/$",
auth_views.LoginView.as_view(template_name="users/login.html"),
name="login",
),
url(r"^logout/$", auth_views.LogoutView.as_view(next_page="/login"), name="logout"),
url(r"^api/", include("bag_transfer.api.urls")),
url(r'^status/', include('health_check.api.urls')),
]
8 changes: 7 additions & 1 deletion aurora/aurora/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
"""

import os
import sys

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_electron.settings")
path = '/data/htdocs/aurora/aurora'

if path not in sys.path:
sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "aurora.settings")

application = get_wsgi_application()
12 changes: 5 additions & 7 deletions aurora/bag_transfer/accession/db_functions.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db.models import CharField, Aggregate


class GroupConcat(Aggregate):
function = 'GROUP_CONCAT'
template = '%(function)s(%(distinct)s%(expressions)s)'
function = "GROUP_CONCAT"
template = "%(function)s(%(distinct)s%(expressions)s)"

def __init__(self, expression, distinct=False, **extra):
super(GroupConcat, self).__init__(
expression,
distinct='DISTINCT ' if distinct else '',
distinct="DISTINCT " if distinct else "",
output_field=CharField(),
**extra)
**extra
)
Loading

0 comments on commit 2b09ac8

Please sign in to comment.