Skip to content

Commit

Permalink
Merge branch 'master' into feature/move-settings-for-events-to-event-…
Browse files Browse the repository at this point in the history
…settings
  • Loading branch information
Tschuppi81 committed Jul 16, 2024
2 parents 9d48978 + 61ea339 commit bee51f5
Show file tree
Hide file tree
Showing 74 changed files with 5,720 additions and 2,738 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
- id: sass-lint
files: '^src/.*\.scss'
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.6.0
rev: v9.7.0
hooks:
- id: eslint
files: '^src/.*\.jsx?$'
Expand Down
4,976 changes: 2,489 additions & 2,487 deletions .test_durations

Large diffs are not rendered by default.

33 changes: 12 additions & 21 deletions docs/api/api.md → docs/api/agency/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# OneGov Cloud API

## Agency API
# OneGov Agency API

The headless Agency API offers the following views:

Expand All @@ -11,7 +9,7 @@ The headless Agency API offers the following views:
We implement the called Collection+JSON standard established by Mike
Amundsen. For details please refer to [media types - collection & json](http://amundsen.com/media-types/collection/format/)

### Agencies View
## Agencies View

The agencies view provides information about all the existing agencies
within the organisation. Each agency offers several data fields like title,
Expand All @@ -21,7 +19,7 @@ memberships if given.

`curl https://[base_url]/agencies`

#### Agency Query Fields
### Agency Query Fields

The agencies api support the following query fields:

Expand All @@ -36,7 +34,7 @@ The agencies api support the following query fields:
| updated_gt | queries agencies updated after date specified (greater than) |


#### cURL Example
### cURL Example

`curl https://[base_url]/agencies?title=datenschutzbeauftragter`

Expand Down Expand Up @@ -156,7 +154,7 @@ A collection+JSON of items if found including paging
}
```

### People View
## People View

The people view provides information about all people in relation with agencies
within the organisation. Each person offers several data fields like
Expand All @@ -166,7 +164,7 @@ a picture, website and memberships to agencies memberships if given.

`curl https://[base_url]/people`

#### People Query Fields
### People Query Fields

The people api supports the following query fields that can be combined:

Expand All @@ -180,7 +178,7 @@ The people api supports the following query fields that can be combined:
| updated_ge | queries people updated after or date specified (greater equal) |
| updated_gt | queries people updated after date specified (greater than) |

#### cURL Example
### cURL Example

`curl https://[base_url]/people?first_name=moritz`

Expand Down Expand Up @@ -320,15 +318,15 @@ A collection+JSON of items if found including paging
}
```

### Membership View
## Membership View

The membership view provides information about all the existing memberships
between people and agencies within the organisation. Each membership has
data points and links to its person and agency.

`curl https://[base_url]/memberships`

#### Membership Query Fields
### Membership Query Fields

The agencies api support the following query fields:

Expand All @@ -343,7 +341,7 @@ The agencies api support the following query fields:
| updated_gt | queries memberships updated after date specified (greater than) |


#### cURL Example
### cURL Example

`curl https://staka.zug.ch/api/memberships?agency=1`

Expand Down Expand Up @@ -451,7 +449,7 @@ A collection+JSON of items if found
}
```

### Authorization
## Authorization

The API employs token-based authentication, which allows for unrestricted usage of the API without encountering rate-limiting restrictions.
A token will be valid for one hour, afterward you have to request a new one.
Expand All @@ -475,7 +473,7 @@ Once you have a key, you can request a token. The token is used for all other re
2. To request a token, make a GET to `/api/authenticate` and provide the API access key via HTTP basic authentication in the username part (the password part is not used):
3. The token must be provided with all requests using the the username part of the HTTP basic authentication (the password part is not used).

#### curl example:
### curl example:

```bash
#/bin/bash
Expand All @@ -491,10 +489,3 @@ curl -X GET \
-u $(echo -n "$TOKEN:") \
<your api url>/api/agencies
```



## Election Day API

Please refer to
[Election Day API](src/onegov/election_day/static/docs/api/README.md)
1 change: 1 addition & 0 deletions docs/api/election_day
1 change: 0 additions & 1 deletion docs/api/election_day/README.md

This file was deleted.

27 changes: 17 additions & 10 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ Describes our very own Formcode™ Syntax, a DSL to write forms with.

formcode


Public API
++++++++++

Find out how to use the public API.

.. toctree::
:maxdepth: 1

api/agency/README.md

.. toctree::
:maxdepth: 1

api/election_day/README.md


Source
^^^^^^

Expand All @@ -118,13 +135,3 @@ the OneGov Cloud modules documentation.
:maxdepth: 2

modules

API
^^^

API documentation

.. toctree::
:maxdepth: 2

api/api.md
32 changes: 0 additions & 32 deletions docs/onegov_town6.rst

This file was deleted.

9 changes: 4 additions & 5 deletions src/onegov/core/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from onegov.core.framework import Framework
from onegov.core.orm import DB_CONNECTION_ERRORS
from morepath.core import excview_tween_factory # type:ignore[import-untyped]
from sentry_sdk import Scope, capture_event, get_client
from sentry_sdk.hub import Hub, _should_send_default_pii
from sentry_sdk import capture_event, get_client
from sentry_sdk.integrations import Integration
from sentry_sdk.integrations._wsgi_common import RequestExtractor
from sentry_sdk.scope import Scope, should_send_default_pii
from sentry_sdk.tracing import SOURCE_FOR_STYLE
from sentry_sdk.utils import (
capture_internal_exceptions,
Expand Down Expand Up @@ -95,8 +95,7 @@ def sentry_tween(request: 'CoreRequest') -> 'Response':
return sentry_tween

def with_sentry_middleware(self: Framework) -> bool:
hub = Hub.current
integration = hub.get_integration(OneGovCloudIntegration)
integration = get_client().get_integration(OneGovCloudIntegration)
if integration is None:
return False

Expand Down Expand Up @@ -189,7 +188,7 @@ def event_processor(event: 'Event', hint: 'Hint') -> 'Event':

user_data.setdefault(
'role', getattr(request.identity, 'role', 'anonymous'))
if _should_send_default_pii():
if should_send_default_pii():
user_info.setdefault(
'ip_address', request.environ.get('HTTP_X_REAL_IP'))
user_info.setdefault('email', request.identity.userid)
Expand Down
4 changes: 2 additions & 2 deletions src/onegov/election_day/static/docs/api/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Onegov Election Day
===================
OneGov Election Day API
=======================

Upload Formats
--------------
Expand Down
3 changes: 2 additions & 1 deletion src/onegov/org/forms/form_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class FormDefinitionBaseForm(Form):
definition = TextAreaField(
label=_("Definition"),
validators=[InputRequired(), ValidFormDefinition()],
render_kw={'rows': 32, 'data-editor': 'form'})
render_kw={'rows': 32, 'data-editor': 'form'},
default="E-Mail *= @@@")

pick_up = TextAreaField(
label=_("Pick-Up"),
Expand Down
2 changes: 1 addition & 1 deletion src/onegov/org/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def is_editor(self) -> bool:

@property
def current_username(self) -> str | None:
return self.identity and self.identity.userid or None
return self.identity .userid if self.identity else None

@cached_property
def current_user(self) -> User | None:
Expand Down
8 changes: 7 additions & 1 deletion src/onegov/pas/collections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from onegov.pas.collections.attendence import AttendenceCollection
from onegov.pas.collections.change import ChangeCollection
from onegov.pas.collections.commission import CommissionCollection
from onegov.pas.collections.commission_membership import (
CommissionMembershipCollection)
Expand All @@ -10,14 +11,19 @@
from onegov.pas.collections.parliamentary_group import (
ParliamentaryGroupCollection)
from onegov.pas.collections.party import PartyCollection
from onegov.pas.collections.rate_set import RateSetCollection
from onegov.pas.collections.settlement_run import SettlementRunCollection

__all__ = (
'AttendenceCollection',
'ChangeCollection',
'CommissionCollection',
'CommissionMembershipCollection',
'LegislativePeriodCollection',
'ParliamentarianCollection',
'ParliamentarianRoleCollection',
'ParliamentaryGroupCollection',
'PartyCollection'
'PartyCollection',
'RateSetCollection',
'SettlementRunCollection'
)
17 changes: 17 additions & 0 deletions src/onegov/pas/collections/change.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from onegov.core.collection import GenericCollection
from onegov.pas.models import Change
from sqlalchemy import desc

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from sqlalchemy.orm import Query


class ChangeCollection(GenericCollection[Change]):

@property
def model_class(self) -> type[Change]:
return Change

def query(self) -> 'Query[Change]':
return super().query().order_by(desc(Change.last_change))
7 changes: 0 additions & 7 deletions src/onegov/pas/collections/commission_membership.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
from onegov.core.collection import GenericCollection
from onegov.pas.models import CommissionMembership

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from sqlalchemy.orm import Query


class CommissionMembershipCollection(GenericCollection[CommissionMembership]):

@property
def model_class(self) -> type[CommissionMembership]:
return CommissionMembership

def query(self) -> 'Query[CommissionMembership]':
return super().query()
8 changes: 1 addition & 7 deletions src/onegov/pas/collections/legislative_period.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import date
from onegov.core.collection import GenericCollection
from onegov.pas.models import LegislativePeriod
from sqlalchemy import or_

from typing import TYPE_CHECKING
if TYPE_CHECKING:
Expand Down Expand Up @@ -29,12 +28,7 @@ def query(self) -> 'Query[LegislativePeriod]':

if self.active is not None:
if self.active:
query = query.filter(
or_(
LegislativePeriod.end.is_(None),
LegislativePeriod.end >= date.today()
)
)
query = query.filter(LegislativePeriod.end >= date.today())
else:
query = query.filter(LegislativePeriod.end < date.today())

Expand Down
7 changes: 0 additions & 7 deletions src/onegov/pas/collections/parliamentarian_role.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
from onegov.core.collection import GenericCollection
from onegov.pas.models import ParliamentarianRole

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from sqlalchemy.orm import Query


class ParliamentarianRoleCollection(GenericCollection[ParliamentarianRole]):

@property
def model_class(self) -> type[ParliamentarianRole]:
return ParliamentarianRole

def query(self) -> 'Query[ParliamentarianRole]':
return super().query()
Loading

0 comments on commit bee51f5

Please sign in to comment.