Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/tkalir/anyway into 2581-send…
Browse files Browse the repository at this point in the history
…_to_telegram_after_verified_location
  • Loading branch information
tkalir committed Apr 23, 2024
2 parents b81a1ac + 400af13 commit 44f0962
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
45 changes: 45 additions & 0 deletions alembic/versions/11ddb0cff075_adding_location_verification_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""adding location verification role
Revision ID: 11ddb0cff075
Revises: fe08b885a23f
Create Date: 2024-04-21 06:18:03.777200
"""

# revision identifiers, used by Alembic.
revision = '11ddb0cff075'
down_revision = 'fe08b885a23f'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy import orm
import datetime


def upgrade():
from anyway.models import Roles

bind = op.get_bind()
session = orm.Session(bind=bind)

role_location_verification = Roles(
name="location_verification",
description="Allows user to change and verify newsflash location.",
create_date=datetime.datetime.now(),
)
session.add(role_location_verification)
session.commit()


def downgrade():
from anyway.models import Roles

bind = op.get_bind()
session = orm.Session(bind=bind)

# Delete the role added in the upgrade
session.query(Roles).filter(Roles.name == "location_verification").delete()

session.commit()
17 changes: 17 additions & 0 deletions anyway/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ def acc_in_area_query():

app.add_url_rule("/api/v1/news-flash", endpoint=None, view_func=news_flash, methods=["GET"])


@app.after_request
def add_allow_methods_header(response):
if request.path.startswith("/api/news-flash/"):
Expand Down Expand Up @@ -1547,3 +1548,19 @@ def get(self):
return get_downloaded_data(
args.get("format", "csv"), args.get("years_ago", DEFAULT_NUMBER_OF_YEARS_AGO)
)


def test_roles():
return test_roles_func()


@roles_accepted(
BE_CONST.Roles2Names.Authenticated.value,
BE_CONST.Roles2Names.Location_verification.value,
need_all_permission=True,
)
def test_roles_func():
return jsonify({"message": "Roles test successful!"}), 200


app.add_url_rule("/api/test_roles", endpoint=None, view_func=test_roles, methods=["GET"])
3 changes: 2 additions & 1 deletion anyway/views/news_flash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ def extracted_location_and_qualification(news_flash_obj: NewsFlash):


@roles_accepted(
BE_CONST.Roles2Names.Admins.value
BE_CONST.Roles2Names.Admins.value,
BE_CONST.Roles2Names.Location_verification.value
)
def update_news_flash_qualifying(id):
current_user = get_current_user()
Expand Down

0 comments on commit 44f0962

Please sign in to comment.