Skip to content

Commit

Permalink
Merge pull request #30 from archesproject/add_pre_commit
Browse files Browse the repository at this point in the history
Adds pre-commit hooks
  • Loading branch information
chrabyrd authored Jun 12, 2024
2 parents 605b4cd + c051fb7 commit 7e1514c
Show file tree
Hide file tree
Showing 15 changed files with 12,639 additions and 986 deletions.
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
repos:

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [--quiet]
exclude: node_modules

- repo: local
hooks:
- id: prettier
name: prettier
entry: npm run prettier:fix
language: system
files: arches_lingo/src
- id: eslint
name: eslint
entry: npm run eslint:fix
language: system
files: arches_lingo/src
- id: typescript
name: typescript
entry: npm run ts:check
language: system
types: [
"ts",
"vue",
]
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleAttributePerLine": true
}
Empty file.
180 changes: 102 additions & 78 deletions arches_lingo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
except ImportError:
pass

APP_NAME = 'arches_lingo'
APP_NAME = "arches_lingo"
APP_VERSION = semantic_version.Version(major=0, minor=0, patch=0)
APP_ROOT = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
MIN_ARCHES_VERSION = arches.__version__
Expand All @@ -25,32 +25,50 @@

WEBPACK_LOADER = {
"DEFAULT": {
"STATS_FILE": os.path.join(APP_ROOT, 'webpack/webpack-stats.json'),
"STATS_FILE": os.path.join(APP_ROOT, "..", "webpack/webpack-stats.json"),
},
}

DATATYPE_LOCATIONS.append('arches_lingo.datatypes')
FUNCTION_LOCATIONS.append('arches_lingo.functions')
ETL_MODULE_LOCATIONS.append('arches_lingo.etl_modules')
SEARCH_COMPONENT_LOCATIONS.append('arches_lingo.search_components')
DATATYPE_LOCATIONS.append("arches_lingo.datatypes")
FUNCTION_LOCATIONS.append("arches_lingo.functions")
ETL_MODULE_LOCATIONS.append("arches_lingo.etl_modules")
SEARCH_COMPONENT_LOCATIONS.append("arches_lingo.search_components")

LOCALE_PATHS.append(os.path.join(APP_ROOT, 'locale'))
LOCALE_PATHS.append(os.path.join(APP_ROOT, "locale"))

FILE_TYPE_CHECKING = False
FILE_TYPES = ["bmp", "gif", "jpg", "jpeg", "pdf", "png", "psd", "rtf", "tif", "tiff", "xlsx", "csv", "zip"]
FILE_TYPES = [
"bmp",
"gif",
"jpg",
"jpeg",
"pdf",
"png",
"psd",
"rtf",
"tif",
"tiff",
"xlsx",
"csv",
"zip",
]
FILENAME_GENERATOR = "arches.app.utils.storage_filename_generator.generate_filename"
UPLOADED_FILES_DIR = "uploadedfiles"

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '--+c7*txnosqv=flep00qp+=t-xhrj%f4==r8w*n_7pm@mi%)7'
SECRET_KEY = "--+c7*txnosqv=flep00qp+=t-xhrj%f4==r8w*n_7pm@mi%)7"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ROOT_URLCONF = 'arches_lingo.urls'
ROOT_URLCONF = "arches_lingo.urls"

# Modify this line as needed for your project to connect to elasticsearch with a password that you generate
ELASTICSEARCH_CONNECTION_OPTIONS = {"request_timeout": 30, "verify_certs": False, "basic_auth": ("elastic", "E1asticSearchforArche5")}
ELASTICSEARCH_CONNECTION_OPTIONS = {
"request_timeout": 30,
"verify_certs": False,
"basic_auth": ("elastic", "E1asticSearchforArche5"),
}

# If you need to connect to Elasticsearch via an API key instead of username/password, use the syntax below:
# ELASTICSEARCH_CONNECTION_OPTIONS = {"timeout": 30, "verify_certs": False, "api_key": "<ENCODED_API_KEY>"}
Expand All @@ -65,7 +83,7 @@
# Or Kibana: https://www.elastic.co/guide/en/kibana/current/api-keys.html

# a prefix to append to all elasticsearch indexes, note: must be lower case
ELASTICSEARCH_PREFIX = 'arches_lingo'
ELASTICSEARCH_PREFIX = "arches_lingo"

ELASTICSEARCH_CUSTOM_INDEXES = []
# [{
Expand Down Expand Up @@ -98,14 +116,9 @@
"PASSWORD": "postgis",
"PORT": "5432",
"POSTGIS_TEMPLATE": "template_postgis",
"TEST": {
"CHARSET": None,
"COLLATION": None,
"MIRROR": None,
"NAME": None
},
"TEST": {"CHARSET": None, "COLLATION": None, "MIRROR": None, "NAME": None},
"TIME_ZONE": None,
"USER": "postgres"
"USER": "postgres",
}
}

Expand Down Expand Up @@ -167,19 +180,21 @@

ALLOWED_HOSTS = []

SYSTEM_SETTINGS_LOCAL_PATH = os.path.join(APP_ROOT, 'system_settings', 'System_Settings.json')
WSGI_APPLICATION = 'arches_lingo.wsgi.application'
SYSTEM_SETTINGS_LOCAL_PATH = os.path.join(
APP_ROOT, "system_settings", "System_Settings.json"
)
WSGI_APPLICATION = "arches_lingo.wsgi.application"

# URL that handles the media served from MEDIA_ROOT, used for managing stored files.
# It must end in a slash if set to a non-empty value.
MEDIA_URL = '/files/'
MEDIA_URL = "/files/"

# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = os.path.join(APP_ROOT)
MEDIA_ROOT = os.path.join(APP_ROOT)

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
STATIC_URL = "/static/"

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
Expand All @@ -190,37 +205,37 @@
# when hosting Arches under a sub path set this value to the sub path eg : "/{sub_path}/"
FORCE_SCRIPT_NAME = None

RESOURCE_IMPORT_LOG = os.path.join(APP_ROOT, 'logs', 'resource_import.log')
DEFAULT_RESOURCE_IMPORT_USER = {'username': 'admin', 'userid': 1}
RESOURCE_IMPORT_LOG = os.path.join(APP_ROOT, "logs", "resource_import.log")
DEFAULT_RESOURCE_IMPORT_USER = {"username": "admin", "userid": 1}

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'console': {
'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"console": {
"format": "%(asctime)s %(name)-12s %(levelname)-8s %(message)s",
},
},
'handlers': {
'file': {
'level': 'WARNING', # DEBUG, INFO, WARNING, ERROR
'class': 'logging.FileHandler',
'filename': os.path.join(APP_ROOT, 'arches.log'),
'formatter': 'console'
"handlers": {
"file": {
"level": "WARNING", # DEBUG, INFO, WARNING, ERROR
"class": "logging.FileHandler",
"filename": os.path.join(APP_ROOT, "arches.log"),
"formatter": "console",
},
"console": {
"level": "WARNING",
"class": "logging.StreamHandler",
"formatter": "console",
},
'console': {
'level': 'WARNING',
'class': 'logging.StreamHandler',
'formatter': 'console'
}
},
'loggers': {
'arches': {
'handlers': ['file', 'console'],
'level': 'WARNING',
'propagate': True
"loggers": {
"arches": {
"handlers": ["file", "console"],
"level": "WARNING",
"propagate": True,
}
}
},
}

# Rate limit for authentication views
Expand All @@ -232,16 +247,16 @@
DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640

# Unique session cookie ensures that logins are treated separately for each app
SESSION_COOKIE_NAME = 'arches_lingo'
SESSION_COOKIE_NAME = "arches_lingo"

# For more info on configuring your cache: https://docs.djangoproject.com/en/2.2/topics/cache/
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
},
'user_permission': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'user_permission_cache',
"user_permission": {
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
"LOCATION": "user_permission_cache",
},
}

Expand All @@ -251,27 +266,26 @@
BYPASS_UNIQUE_CONSTRAINT_TILE_VALIDATION = False
BYPASS_REQUIRED_VALUE_TILE_VALIDATION = False

DATE_IMPORT_EXPORT_FORMAT = "%Y-%m-%d" # Custom date format for dates imported from and exported to csv
DATE_IMPORT_EXPORT_FORMAT = (
"%Y-%m-%d" # Custom date format for dates imported from and exported to csv
)

# This is used to indicate whether the data in the CSV and SHP exports should be
# ordered as seen in the resource cards or not.
EXPORT_DATA_FIELDS_IN_CARD_ORDER = False

#Identify the usernames and duration (seconds) for which you want to cache the time wheel
CACHE_BY_USER = {
"default": 3600 * 24, #24hrs
"anonymous": 3600 * 24 #24hrs
}
# Identify the usernames and duration (seconds) for which you want to cache the time wheel
CACHE_BY_USER = {"default": 3600 * 24, "anonymous": 3600 * 24} # 24hrs # 24hrs

TILE_CACHE_TIMEOUT = 600 #seconds
CLUSTER_DISTANCE_MAX = 5000 #meters
TILE_CACHE_TIMEOUT = 600 # seconds
CLUSTER_DISTANCE_MAX = 5000 # meters
GRAPH_MODEL_CACHE_TIMEOUT = None

OAUTH_CLIENT_ID = '' #'9JCibwrWQ4hwuGn5fu2u1oRZSs9V6gK8Vu8hpRC4'
OAUTH_CLIENT_ID = "" #'9JCibwrWQ4hwuGn5fu2u1oRZSs9V6gK8Vu8hpRC4'

APP_TITLE = 'Arches | Heritage Data Management'
COPYRIGHT_TEXT = 'All Rights Reserved.'
COPYRIGHT_YEAR = '2019'
APP_TITLE = "Arches | Heritage Data Management"
COPYRIGHT_TEXT = "All Rights Reserved."
COPYRIGHT_YEAR = "2019"

ENABLE_CAPTCHA = False
# RECAPTCHA_PUBLIC_KEY = ''
Expand All @@ -292,18 +306,27 @@

DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

CELERY_BROKER_URL = "" # RabbitMQ --> "amqp://guest:guest@localhost", Redis --> "redis://localhost:6379/0"
CELERY_ACCEPT_CONTENT = ['json']
CELERY_RESULT_BACKEND = 'django-db' # Use 'django-cache' if you want to use your cache as your backend
CELERY_TASK_SERIALIZER = 'json'
CELERY_BROKER_URL = "" # RabbitMQ --> "amqp://guest:guest@localhost", Redis --> "redis://localhost:6379/0"
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_RESULT_BACKEND = (
"django-db" # Use 'django-cache' if you want to use your cache as your backend
)
CELERY_TASK_SERIALIZER = "json"


CELERY_SEARCH_EXPORT_EXPIRES = 24 * 3600 # seconds
CELERY_SEARCH_EXPORT_CHECK = 3600 # seconds

CELERY_BEAT_SCHEDULE = {
"delete-expired-search-export": {"task": "arches.app.tasks.delete_file", "schedule": CELERY_SEARCH_EXPORT_CHECK,},
"notification": {"task": "arches.app.tasks.message", "schedule": CELERY_SEARCH_EXPORT_CHECK, "args": ("Celery Beat is Running",),},
"delete-expired-search-export": {
"task": "arches.app.tasks.delete_file",
"schedule": CELERY_SEARCH_EXPORT_CHECK,
},
"notification": {
"task": "arches.app.tasks.message",
"schedule": CELERY_SEARCH_EXPORT_CHECK,
"args": ("Celery Beat is Running",),
},
}

# Set to True if you want to send celery tasks to the broker without being able to detect celery.
Expand Down Expand Up @@ -353,7 +376,9 @@
# Dictionary containing any additional context items for customising email templates
EXTRA_EMAIL_CONTEXT = {
"salutation": _("Hi"),
"expiration":(datetime.now() + timedelta(seconds=CELERY_SEARCH_EXPORT_EXPIRES)).strftime("%A, %d %B %Y")
"expiration": (
datetime.now() + timedelta(seconds=CELERY_SEARCH_EXPORT_EXPIRES)
).strftime("%A, %d %B %Y"),
}

# see https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#how-django-discovers-language-preference
Expand Down Expand Up @@ -384,10 +409,10 @@
# {langcode}-{regioncode} eg: en, en-gb ....
# a list of language codes can be found here http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGES = [
# ('de', _('German')),
('en', _('English')),
# ('en-gb', _('British English')),
# ('es', _('Spanish')),
# ('de', _('German')),
("en", _("English")),
# ('en-gb', _('British English')),
# ('es', _('Spanish')),
]

# override this to permenantly display/hide the language switcher
Expand Down Expand Up @@ -419,4 +444,3 @@
static_url=STATIC_URL,
webpack_development_server_port=WEBPACK_DEVELOPMENT_SERVER_PORT,
)

14 changes: 11 additions & 3 deletions arches_lingo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
from arches_lingo.views import ConceptTreeView

urlpatterns = [
path('', include('arches.urls')),
path("", include("arches.urls")),
path("concept_trees/", ConceptTreeView.as_view(), name="concept_trees"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# if settings.SHOW_LANGUAGE_SWITCH is True:
# urlpatterns = i18n_patterns(*urlpatterns)
# Only handle i18n routing in active project. This will still handle the routes provided by Arches core and Arches applications,
# but handling i18n routes in multiple places causes application errors.
if (
settings.APP_NAME != "Arches"
and settings.APP_NAME not in settings.ARCHES_APPLICATIONS
):
if settings.SHOW_LANGUAGE_SWITCH is True:
urlpatterns = i18n_patterns(*urlpatterns)

urlpatterns.append(path("i18n/", include("django.conf.urls.i18n")))
5 changes: 3 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import js from "@eslint/js";
import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from "eslint-config-prettier";

import vueESLintParser from 'vue-eslint-parser';

export default [
js.configs.recommended,
...pluginVue.configs['flat/recommended'],
...tseslint.configs.recommended,
eslintConfigPrettier,
{
"languageOptions": {
"globals": {
Expand Down Expand Up @@ -36,7 +38,6 @@ export default [
},
"rules": {
"semi": ["error", "always"],
"vue/html-indent": ["error", 4]
},
},
]
];
Loading

0 comments on commit 7e1514c

Please sign in to comment.