Skip to content

Commit

Permalink
Run ruff and black
Browse files Browse the repository at this point in the history
  • Loading branch information
norbusan committed Jul 27, 2023
1 parent 42c403e commit 3861a7e
Show file tree
Hide file tree
Showing 37 changed files with 50 additions and 98 deletions.
4 changes: 2 additions & 2 deletions app/api/custom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def reorder_speakers(event_id):

result = group_by(data, 'order')
updates = {}
for (order, items) in result.items():
for order, items in result.items():
speaker_ids = {item['speaker'] for item in items}
result = Speaker.query.filter(Speaker.id.in_(speaker_ids)).update(
{Speaker.order: order}, synchronize_session=False
Expand Down Expand Up @@ -170,7 +170,7 @@ def reorder_exhibitors(event_id):

result = group_by(data, 'position')
updates = {}
for (position, items) in result.items():
for position, items in result.items():
exhibitor_ids = {item['exhibitor'] for item in items}
result = Exhibitor.query.filter(Exhibitor.id.in_(exhibitor_ids)).update(
{Exhibitor.position: position}, synchronize_session=False
Expand Down
1 change: 0 additions & 1 deletion app/api/custom/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def ticket_attendee_pdf(attendee_id):

@order_blueprint.route('/<string:order_identifier>/verify', methods=['POST'])
def verify_order_payment(order_identifier):

order = Order.query.filter_by(identifier=order_identifier).first()

if order.payment_mode == 'stripe':
Expand Down
2 changes: 1 addition & 1 deletion app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def query(self, view_kwargs):
)

if view_kwargs.get('group_id') and 'GET' in request.method:
group = safe_query(Group, 'id', view_kwargs.get('group_id'), 'group_id')
safe_query(Group, 'id', view_kwargs.get('group_id'), 'group_id')
query_ = self.session.query(Event).filter(
getattr(Event, 'group_id') == view_kwargs['group_id']
)
Expand Down
1 change: 0 additions & 1 deletion app/api/exhibitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def before_update_object(self, exhibitor, data, view_kwargs):


class ExhibitorRelationship(ResourceRelationship):

decorators = (
api.has_permission(
'is_coorganizer',
Expand Down
1 change: 0 additions & 1 deletion app/api/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def export_download(event_id, path):
@to_event_id
@is_coorganizer
def export_event_xcal(event_id):

from .helpers.tasks import export_xcal_task

# queue task
Expand Down
1 change: 0 additions & 1 deletion app/api/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class GroupDetail(ResourceDetail):
"""

def before_get_object(self, view_kwargs):

if view_kwargs.get('event_identifier'):
event = safe_query_kwargs(
Event, view_kwargs, 'event_identifier', 'identifier'
Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/calendar/ical.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def to_ical(event, include_sessions=False, my_schedule=False, user_id=None):
sessions = sessions_query.all()

for session in sessions:

if not (session and session.starts_at and session.ends_at):
continue

Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/export_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def create_export_job(task_id, event_id):
current_logged_user = get_current_user()

if export_job:

export_job.task = task_url
export_job.user_email = current_logged_user.email
export_job.event = Event.query.get(event_id)
Expand Down
5 changes: 1 addition & 4 deletions app/api/helpers/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ def send_email_to_attendees(order):


def send_order_purchase_organizer_email(order, recipients):

order_tickets = OrderTicket.query.filter_by(order_id=order.id).all()
emails = list({organizer.email for organizer in recipients})
print(emails[0])
Expand Down Expand Up @@ -679,9 +678,7 @@ def send_order_purchase_organizer_email(order, recipients):
def send_order_cancel_email(order):
cancel_msg = ''
if order.cancel_note:
cancel_msg = "<br/>Message from the organizer: {cancel_note}".format(
cancel_note=order.cancel_note
)
cancel_msg = f"<br/>Message from the organizer: {order.cancel_note}"

order_url = (
get_settings()['frontend_url'] + '/orders/' + str(order.identifier) + '/view/'
Expand Down
2 changes: 1 addition & 1 deletion app/api/helpers/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def get_payment_intent_stripe(order_invoice, currency=None, credentials=None):
automatic_payment_methods={
'enabled': True,
},
description=f"Eventyay {event_name}"
description=f"Eventyay {event_name}",
)
return payment_intent

Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/pentabarfxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def export(event_id):

room = Room(name=microlocation.name)
for session in sessions:

if session.ends_at is None or session.starts_at is None:
duration = ""
else:
Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def to_event_id(func):

@wraps(func)
def decorated_function(*args, **kwargs):

if 'event_identifier' in kwargs:
if not kwargs['event_identifier'].isdigit():
event = (
Expand Down
9 changes: 3 additions & 6 deletions app/api/helpers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,9 @@ def create_url(request_url, file_relative_path):
if port and url.scheme == SCHEMES.get(url.port, None):
port = None

return '{scheme}://{hostname}:{port}{file_relative_path}'.format(
scheme=url.scheme,
hostname=url.hostname,
port=port,
file_relative_path=file_relative_path,
).replace(':None', '')
return f'{url.scheme}://{url.hostname}:{port}{file_relative_path}'.replace(
':None', ''
)


def upload_to_aws(
Expand Down
6 changes: 1 addition & 5 deletions app/api/helpers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ def resize_speaker_images_task(self, speaker_id, photo_url):
speaker = Speaker.query.get(speaker_id)
try:
logging.info(
'Speaker image resizing tasks started for speaker with id {}'.format(
speaker_id
)
f'Speaker image resizing tasks started for speaker with id {speaker_id}'
)
uploaded_images = create_save_image_sizes(photo_url, 'speaker-image', speaker_id)
speaker.small_image_url = uploaded_images['small_image_url']
Expand Down Expand Up @@ -726,7 +724,6 @@ def export_admin_sales_csv_task(self, status='all'):

@celery.task(base=RequestContextTask, name='export.speakers.csv', bind=True)
def export_speakers_csv_task(self, event_id, status='all'):

if status not in [
'all',
'pending',
Expand Down Expand Up @@ -832,7 +829,6 @@ def rename_chat_room(event_id):

@celery.task(base=RequestContextTask, name='export.group.followers.csv', bind=True)
def export_group_followers_csv_task(self, group_id):

followers = UserFollowGroup.query.filter_by(group_id=group_id).all()

try:
Expand Down
4 changes: 1 addition & 3 deletions app/api/helpers/ticketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def validate_ticket_holders(ticket_holder_ids):
)
raise ConflictError(
{'pointer': '/data/relationships/attendees'},
"Order already exists for attendee with id {}".format(
str(ticket_holder.id)
),
f"Order already exists for attendee with id {str(ticket_holder.id)}",
)
return ticket_holders

Expand Down
2 changes: 1 addition & 1 deletion app/api/helpers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def require_exclusive_relationship(resource_list, data, optional=False):

if multiple or not (optional or present):
raise UnprocessableEntityError(
{'pointer': f'/data/relationships'},
{'pointer': '/data/relationships'},
f"A valid relationship with either of resources is required: {resource_list}",
)

Expand Down
2 changes: 0 additions & 2 deletions app/api/helpers/xcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def export(event_id):
)

for session in sessions:

if session and session.starts_at and session.ends_at:

v_event_node = SubElement(v_calendar_node, 'vevent')

method_node = SubElement(v_event_node, 'method')
Expand Down
2 changes: 0 additions & 2 deletions app/api/notification_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@


class NotificationSettingsList(ResourceList):

decorators = (api.has_permission('is_admin', methods="GET"),)
methods = ['GET']
schema = NotificationSettingSchema
data_layer = {'session': db.session, 'model': NotificationSettings}


class NotificationSettingsDetail(ResourceDetail):

schema = NotificationSettingSchema
decorators = (api.has_permission('is_admin', methods="PATCH"),)
methods = ['GET', 'PATCH']
Expand Down
4 changes: 1 addition & 3 deletions app/api/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,7 @@ def omise_checkout(order_identifier):
logging.exception('Error while charging omise')
if charge.failure_code is not None:
logging.warning(
"Omise Failure Message: {} ({})".format(
charge.failure_message, charge.failure_code
)
f"Omise Failure Message: {charge.failure_message} ({charge.failure_code})"
)
return jsonify(
status=False,
Expand Down
1 change: 0 additions & 1 deletion app/api/schema/exhibitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ExhibitorSocialLinkSchema(Schema):

class ExhibitorSchema(JSONAPISchema):
class Meta:

type_ = 'exhibitor'
self_view = 'v1.exhibitor_detail'
self_view_kwargs = {'id': '<id>'}
Expand Down
1 change: 0 additions & 1 deletion app/api/schema/notification_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class NotificationSettingSchema(Schema):
class Meta:

type_ = 'notification-setting'
self_view = 'v1.notification_setting_detail'
self_view_kwargs = {'id': '<id>'}
Expand Down
1 change: 0 additions & 1 deletion app/api/user_check_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def before_create_object(self, data, _view_kwargs):
STATION_TYPE.get('check in'),
STATION_TYPE.get('check out'),
):

attendee_check_in_status = (
self.session.query(UserCheckIn)
.filter(
Expand Down
1 change: 0 additions & 1 deletion app/api/user_favourite_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class UserFavouriteEventDetail(ResourceDetail):

@jwt_required
def before_get_object(self, view_kwargs):

if view_kwargs.get('id') is not None:
try:
user_favourite_event = find_user_favourite_event_by_id(
Expand Down
1 change: 0 additions & 1 deletion app/api/video_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class VideoChannelListPost(ResourceList):

methods = ['POST']
decorators = (api.has_permission('is_admin', methods="POST"),)
schema = VideoChannelSchema
Expand Down
49 changes: 23 additions & 26 deletions app/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import sqlalchemy as sa
import stripe
from celery.signals import after_task_publish
from flask_babel import Babel
from envparse import env
from flask import Flask, json, make_response, request
from flask_babel import Babel
from flask_cors import CORS
from flask_jwt_extended import JWTManager
from flask_login import current_user
Expand All @@ -29,6 +29,7 @@
from app.api.helpers.jwt import jwt_user_loader
from app.api.helpers.mail_recorder import MailRecorder
from app.extensions import limiter, shell
from app.graphql import views as graphql_views
from app.models import db
from app.models.utils import add_engine_pidguard, sqlite_datetime_fix
from app.templates.flask_ext.jinja.filters import init_filters
Expand All @@ -39,7 +40,6 @@
health_check_migrations,
)
from app.views.redis_store import redis_store
from app.graphql import views as graphql_views

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -139,40 +139,37 @@ def create_app():
# development api
with app.app_context():
from app.api.admin_statistics_api.events import event_statistics
from app.api.auth import auth_routes
from app.api.custom.attendees import attendee_blueprint
from app.api.admin_translations import admin_blueprint
from app.api.auth import auth_routes, authorised_blueprint
from app.api.bootstrap import api_v1
from app.api.celery_tasks import celery_routes
from app.api.custom.attendees import attendee_blueprint
from app.api.custom.badge_forms import badge_forms_routes
from app.api.custom.calendars import calendar_routes
from app.api.custom.events import events_routes
from app.api.custom.group_role_invite import group_role_invites_routes
from app.api.custom.groups import groups_routes
from app.api.custom.invoices import event_blueprint
from app.api.custom.orders import order_blueprint, ticket_blueprint
from app.api.custom.role_invites import role_invites_routes
from app.api.custom.tickets import ticket_routes
from app.api.custom.users import users_routes
from app.api.custom.users_check_in import users_check_in_routes
from app.api.custom.users_groups_roles import users_groups_roles_routes
from app.api.event_copy import event_copy
from app.api.events import events_blueprint
from app.api.exports import export_routes
from app.api.imports import import_routes
from app.api.uploads import upload_routes
from app.api.users import user_misc_routes
from app.api.orders import order_misc_routes
from app.api.orders import alipay_blueprint, order_misc_routes, stripe_blueprint
from app.api.role_invites import role_invites_misc_routes
from app.api.speaker_invites import speaker_invites_misc_routes
from app.api.auth import authorised_blueprint
from app.api.admin_translations import admin_blueprint
from app.api.orders import alipay_blueprint, stripe_blueprint
from app.api.server_version import info_route
from app.api.sessions import sessions_blueprint
from app.api.settings import admin_misc_routes
from app.api.server_version import info_route
from app.api.custom.orders import ticket_blueprint
from app.api.custom.orders import order_blueprint
from app.api.custom.invoices import event_blueprint
from app.api.custom.calendars import calendar_routes
from app.api.speaker_invites import speaker_invites_misc_routes
from app.api.tickets import tickets_routes
from app.api.custom.role_invites import role_invites_routes
from app.api.custom.users_groups_roles import users_groups_roles_routes
from app.api.custom.events import events_routes
from app.api.custom.groups import groups_routes
from app.api.custom.group_role_invite import group_role_invites_routes
from app.api.uploads import upload_routes
from app.api.users import user_misc_routes
from app.api.video_stream import streams_routes
from app.api.events import events_blueprint
from app.api.custom.badge_forms import badge_forms_routes
from app.api.custom.tickets import ticket_routes
from app.api.custom.users import users_routes
from app.api.custom.users_check_in import users_check_in_routes

app.register_blueprint(api_v1)
app.register_blueprint(event_copy)
Expand Down
6 changes: 1 addition & 5 deletions app/models/event_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ def __init__(self, **kwargs):
self.identifier = self.get_new_id()

def __repr__(self):
return '<EventInvoice {!r} {!r} {!r}>'.format(
self.id,
self.identifier,
self.invoice_pdf_url,
)
return f'<EventInvoice {self.id!r} {self.identifier!r} {self.invoice_pdf_url!r}>'

def get_new_id(self) -> str:
with db.session.no_autoflush:
Expand Down
2 changes: 0 additions & 2 deletions app/models/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def entries():

@generic_repr
class NotificationActor(db.Model, Timestamp):

__tablename__ = 'notification_actors'

id = db.Column(db.Integer, primary_key=True)
Expand All @@ -56,7 +55,6 @@ class NotificationActor(db.Model, Timestamp):

@generic_repr
class NotificationContent(db.Model, Timestamp):

__tablename__ = 'notification_content'

id = db.Column(db.Integer, primary_key=True)
Expand Down
4 changes: 1 addition & 3 deletions app/models/panel_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ class PanelPermission(db.Model):
can_access = db.Column(db.Boolean, default=True)

def __repr__(self):
return '<PanelPerm {!r} for {!r}>'.format(
self.custom_system_roles, self.panel_name
)
return f'<PanelPerm {self.custom_system_roles!r} for {self.panel_name!r}>'
4 changes: 1 addition & 3 deletions app/models/role_invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,4 @@ def send_invite(self):
notify_event_role_invitation(self, user, current_user)

def __repr__(self):
return '<RoleInvite {!r}:{!r}:{!r}>'.format(
self.email, self.event_id, self.role_id
)
return f'<RoleInvite {self.email!r}:{self.event_id!r}:{self.role_id!r}>'
Loading

0 comments on commit 3861a7e

Please sign in to comment.