| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
|
|
|||
| 2 | import typing |
||
| 3 | |||
| 4 | __author__ = 'damien' |
||
| 5 | |||
| 6 | from tracim.models.auth import Group, User |
||
| 7 | from sqlalchemy.orm import Query |
||
| 8 | from sqlalchemy.orm import Session |
||
| 9 | |||
| 10 | |||
| 11 | class GroupApi(object): |
||
| 12 | |||
| 13 | def __init__( |
||
| 14 | self, |
||
| 15 | session: Session, |
||
| 16 | current_user: typing.Optional[User], |
||
| 17 | ): |
||
| 18 | self._user = current_user |
||
| 19 | self._session = session |
||
| 20 | |||
| 21 | def _base_query(self) -> Query: |
||
| 22 | return self._session.query(Group) |
||
| 23 | |||
| 24 | def get_one(self, group_id) -> Group: |
||
| 25 | return self._base_query().filter(Group.group_id == group_id).one() |
||
| 26 | |||
| 27 | def get_one_with_name(self, group_name) -> Group: |
||
| 28 | return self._base_query().filter(Group.group_name == group_name).one() |
||
| 29 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.