Allererste Fassung von Gruppen- und Dispatcher-Mobil View
This commit is contained in:
1 parent
47240302d0
commit
8e5f91948f
9 files changed
+1383
-20
No files matched your search
@@ -11,6 +11,18 @@ from cmbnet.utils.helpers import log_transaction
|
||||
api_groups_bp = Blueprint('api_groups', __name__)
|
||||
|
||||
|
||||
@api_groups_bp.route('/groups/me')
|
||||
@role_required(['Gruppe'])
|
||||
def get_my_group(**kwargs):
|
||||
from cmbnet.services.groups_service import GroupsService
|
||||
groups = GroupsService.get_all(g.tenant_id)
|
||||
account_id = g.current_account['id']
|
||||
for group in groups.values():
|
||||
if group.get('account_id') == account_id:
|
||||
return jsonify(group)
|
||||
return jsonify({'error': 'Gruppe nicht gefunden'}), 404
|
||||
|
||||
|
||||
@api_groups_bp.route('/groups/<int:group_id>/alias', methods=['POST'])
|
||||
@role_required(['Dispatcher', 'Administrator'])
|
||||
def update_group_alias(group_id, **kwargs):
|
||||
|
||||
@@ -11,6 +11,32 @@ from cmbnet.services.groups_service import GroupsService
|
||||
api_init_bp = Blueprint('api_init', __name__)
|
||||
|
||||
|
||||
@api_init_bp.route('/init/me')
|
||||
@login_required
|
||||
def init_me(**kwargs):
|
||||
account = getattr(g, 'current_account', None)
|
||||
if not account:
|
||||
return jsonify({'id': None, 'role': None, 'name': None})
|
||||
return jsonify({
|
||||
'id': account['id'],
|
||||
'role': account['role'],
|
||||
'name': account['name'],
|
||||
'tenant_id': account['tenant_id'],
|
||||
'tenant_code': account['tenant_code']
|
||||
})
|
||||
|
||||
|
||||
@api_init_bp.route('/init/groups/<int:group_id>/streets')
|
||||
@login_required
|
||||
def init_group_streets(group_id, **kwargs):
|
||||
from cmbnet.services.groups_service import GroupsService
|
||||
streets = GroupsService.get_streets_for_group(group_id, g.tenant_id)
|
||||
result = []
|
||||
for street in streets:
|
||||
result.append(dict(street))
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api_init_bp.route('/init/accounts')
|
||||
@login_required
|
||||
def init_accounts(**kwargs):
|
||||
|
||||
Reference in new issue
Block a user