Skip to content

Commit

Permalink
Merge pull request #899 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
goessebr authored Jul 22, 2024
2 parents aa311ba + 27c2bf7 commit 7ea582c
Show file tree
Hide file tree
Showing 36 changed files with 830 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ checks:


build:
environment:
python: 3.12
nodes:
analysis:
tests:
Expand Down
7 changes: 4 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
2.1.0 (20-06-2023)
2.1.0 (22-07-2023)
------------------

Migrated from setup.py to the hatchling build tool for improved packaging and distribution. (#854)
Benefits include faster builds, modern configuration, and enhanced flexibility for future enhancements.
- Migrated from setup.py to the hatch build tool for improved packaging and distribution (#854).
Benefits include faster builds, modern configuration, and enhanced flexibility for future enhancements.
- Integrate Cookiecutter Projects into Atramhasis for Improved Maintainability and Centralization (#876)


2.0.0 (22-12-2023)
Expand Down
22 changes: 8 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ contribution. For certain changes, such as updating a part of the documentation
this is not necessary.

We place a lot of importance on code quality, expect to have a good
amount of code coverage present and run frequent unit tests. All commits and
pull requests will be tested with [Travis-ci]. Code coverage is being
monitored with [Coveralls].
amount of code coverage present and run frequent unit tests.
Code coverage is being monitored with [Coveralls].

Locally you can run unit tests by using [pytest] or [tox]. Running pytest
manually is good for running a distinct set of unit tests. For a full test run,
tox is preferred since this can run the unit tests against multiple versions of
python.
Locally you can run unit tests by using [pytest].

```bash
# Run unit tests for all environments
$ tox
# No coverage
$ py.test
# Coverage
Expand All @@ -53,9 +47,10 @@ feature/<ticketnumber>_description_of_feature
Feature and bugfix branches should be branched from develop and will be merged
back into develop once approved through a pull request.
Every pull request will be run through [Travis-ci]. When providing a pull
request, please run the unit tests first and make sure they all pass. Please
provide new unit tests to maintain 100% coverage. If you send us a pull request
All commits and pull requests will be automatically tested using
[GitHub Actions workflows]. When providing a pull request, please run
the unit tests first and make sure they all pass. Please provide new unit tests
to maintain 100% coverage. If you send us a pull request
that doesn't pass all tests, please correct the issue at hand or let us
know why it's not working.
Expand All @@ -65,7 +60,6 @@ know why it's not working.
[Github page for Atramhasis]: https://github.com/OnroerendErfgoed/atramhasis
[Github issue]: https://github.com/OnroerendErfgoed/atramhasis/issues
[development guidelines]: https://atramhasis.readthedocs.io/en/latest/development.html
[Travis-ci]: https://travis-ci.org/OnroerendErfgoed/atramhasis
[Coveralls]: https://coveralls.io/r/OnroerendErfgoed/atramhasis
[pytest]: http://pytest.org
[tox]: http://tox.readthedocs.org
[GitHub Actions workflows]: https://github.com/OnroerendErfgoed/atramhasis/actions
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Atramhasis
:target: https://pypi.python.org/pypi/atramhasis
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.5801135.svg
:target: https://doi.org/10.5281/zenodo.5801135
.. image:: https://app.travis-ci.com/OnroerendErfgoed/atramhasis.svg?branch=develop
:target: https://app.travis-ci.com/OnroerendErfgoed/atramhasis
.. image:: https://github.com/OnroerendErfgoed/atramhasis/actions/workflows/atramhasis_backend.yaml/badge.svg
:target: https://github.com/OnroerendErfgoed/atramhasis/actions/workflows/atramhasis_backend.yaml
.. image:: https://coveralls.io/repos/github/OnroerendErfgoed/atramhasis/badge.svg?branch=develop
:target: https://coveralls.io/github/OnroerendErfgoed/atramhasis?branch=develop
.. image:: https://scrutinizer-ci.com/g/OnroerendErfgoed/atramhasis/badges/quality-score.png?b=develop
Expand Down
48 changes: 41 additions & 7 deletions atramhasis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import logging
import os

from pyramid.config import Configurator
from pyramid.config import PHASE3_CONFIG
from pyramid.interfaces import ISessionFactory
from pyramid.session import SignedCookieSessionFactory
from pyramid.settings import aslist

from atramhasis.renderers import json_renderer_verbose

LOG = logging.getLogger(__name__)


DEFAULT_SETTINGS = {
"cache.tree.backend": "dogpile.cache.memory",
Expand All @@ -28,7 +34,7 @@ def includeme(config):
for key, value in DEFAULT_SETTINGS.items():
if key not in settings:
settings[key] = value

configure_session(config)
config.include('pyramid_jinja2')
config.include('pyramid_tm')
config.add_static_view('static', 'static', cache_max_age=3600)
Expand All @@ -47,6 +53,38 @@ def includeme(config):
config.scan()


def configure_session(config):
"""
Configure pyramid's session factory.
People can configure their own session factory, but if no factory is registered
atramhasis will try configuring its own.
"""

def check_session_factory_set():
session_factory = config.registry.queryUtility(ISessionFactory)
if session_factory:
return

settings = config.registry.settings
if 'atramhasis.session_factory.secret' not in settings:
msg = (
'No session factory is configured, and '
'atramhasis.session_factory.secret setting is missing.'
)
raise ValueError(msg)

LOG.info('Using default SignedCookieSessionFactory.')
default_session_factory = SignedCookieSessionFactory(
settings['atramhasis.session_factory.secret']
)
config.registry.registerUtility(default_session_factory, ISessionFactory)

config.action(
'check_session_factory_set', check_session_factory_set, order=PHASE3_CONFIG + 1
)


def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
Expand All @@ -58,14 +96,10 @@ def main(global_config, **settings):

config = Configurator(settings=settings)

return load_app(config, settings)

return load_app(config)

def load_app(config, settings):
from pyramid.session import SignedCookieSessionFactory
atramhasis_session_factory = SignedCookieSessionFactory(settings['atramhasis.session_factory.secret'])
config.set_session_factory(atramhasis_session_factory)

def load_app(config):
includeme(config)

config.include('atramhasis.data:db')
Expand Down
14 changes: 7 additions & 7 deletions atramhasis/static/admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions atramhasis/static/admin/src/app/ui/AppUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ define([

router.startup('#');
},
refresh_conceptschemes: function () {
console.debug('AppUi::refresh_conceptschemes');
var message = 'Please manually reload the page to see the changes in the main menu.';
topic.publish('dGrowl', message, {
'title': 'New Provider added',
'sticky': false,
'channel': 'info'
});
},

/**
* Hide the 'Loading'-overlay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ define([
'channel': 'info'
});
this._reset(true);
this.parentNode.refresh_conceptschemes();
}),
lang.hitch(this, function (error) {
var message = this._parseError(error);
Expand Down
14 changes: 10 additions & 4 deletions atramhasis/static/admin/src/app/ui/widgets/SearchPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ define([
if (this.appUi.canCreateProviders) {
domAttr.set(this.manageProvidersButton, 'disabled', false);
}
this._initSelectedConceptSchemeAdmin();
},

init: function (scheme, store) {
Expand Down Expand Up @@ -163,15 +164,20 @@ define([
this.emit('scheme.changed', {
schemeId: this.conceptSchemeSelect.value
});
// activate buttons for add and import, edit scheme
domAttr.set(this.addConceptButton, 'disabled', false);
domAttr.set(this.importConceptButton, 'disabled', false);
domAttr.set(this.editSchemeButton, 'disabled', false);
this._search();
}))
);
},

_initSelectedConceptSchemeAdmin: function () {
if (this.conceptSchemeList.length > 0) {
domAttr.set(this.addConceptButton, 'disabled', false);
domAttr.set(this.importConceptButton, 'disabled', false);
domAttr.set(this.editSchemeButton, 'disabled', false);
this._search();
}
},

_createContextMenu: function () {
var contextMenu = new Menu({});
var pane = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<div class="search-form">
<form data-dojo-attach-point="labelSearchForm" data-dojo-attach-event="onsubmit: _search">
<div class="large-10 columns">
<select data-dojo-attach-point="conceptSchemeSelect">
<option value="-1" selected disabled>Select thesaurus</option>
</select>
<select data-dojo-attach-point="conceptSchemeSelect"></select>
</div>
<div class="large-2 columns edit-scheme-button">
<button type="button" class="button tiny" href="#/conceptscheme/edit" data-dojo-attach-point="editSchemeButton"
Expand Down
16 changes: 14 additions & 2 deletions atramhasis/static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def initialize(self, version: str, build_data) -> None:
root_dir = Path(__file__).parent
static = root_dir / "atramhasis" / "static"
static_admin = static / "admin"
subprocess.run(["npm", "install"], cwd=static)
subprocess.run(["npm", "install"], cwd=static_admin)
subprocess.run(["npm", "install"], cwd=static, check=True)
subprocess.run(["npm", "install"], cwd=static_admin, check=True)
subprocess.run(["grunt", "-v", "build"], cwd=static_admin, check=True)
5 changes: 5 additions & 0 deletions cookiecutters/demo/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"root_folder": "atramhasis_demo",
"python_package": "atramhasis_demo",
"package_logger": "demo_logger"
}
4 changes: 4 additions & 0 deletions cookiecutters/demo/{{cookiecutter.root_folder}}/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.0
---

- Initial version
2 changes: 2 additions & 0 deletions cookiecutters/demo/{{cookiecutter.root_folder}}/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include {{cookiecutter.python_package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.jinja2 *.js *.html *.xml
3 changes: 3 additions & 0 deletions cookiecutters/demo/{{cookiecutter.root_folder}}/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{cookiecutter.python_package}} README

This is an Atramhasis demo application
60 changes: 60 additions & 0 deletions cookiecutters/demo/{{cookiecutter.root_folder}}/alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = atramhasis:alembic

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# max length of characters to apply to the
# "slug" field
#truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# sqlalchemy.url = sqlite:///%(here)s/atramhasis.sqlite

ini_location = %(here)s/development.ini

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
Loading

0 comments on commit 7ea582c

Please sign in to comment.