-
Notifications
You must be signed in to change notification settings - Fork 38
DESK_REJECT added #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
DESK_REJECT added #1285
Changes from 4 commits
a8a1314
b887a91
97dde8b
afd9bf1
149e845
0c01a8c
6a2668a
84cdd76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,12 @@ | |
| from flask import g, request | ||
| from sqlalchemy.exc import SQLAlchemyError | ||
|
|
||
| from app.events.models import EventType | ||
| from app.outcome.models import Outcome, Status | ||
| from app.outcome.repository import OutcomeRepository as outcome_repository | ||
| from app.events.repository import EventRepository as event_repository | ||
| from app.users.repository import UserRepository as user_repository | ||
| from app.responses.repository import ResponseRepository as response_repository | ||
| from app.utils.emailer import email_user | ||
|
|
||
| from app.utils.auth import auth_required, event_admin_required | ||
|
|
@@ -26,6 +28,7 @@ def _extract_status(outcome): | |
| 'id': fields.Integer, | ||
| 'status': fields.String(attribute=_extract_status), | ||
| 'timestamp': fields.DateTime(dt_format='iso8601'), | ||
| 'reason': fields.String, | ||
| } | ||
|
|
||
| user_fields = { | ||
|
|
@@ -75,6 +78,7 @@ def post(self, event_id): | |
| req_parser = reqparse.RequestParser() | ||
| req_parser.add_argument('user_id', type=int, required=True) | ||
| req_parser.add_argument('outcome', type=str, required=True) | ||
| req_parser.add_argument('reason', type=str) | ||
| args = req_parser.parse_args() | ||
|
|
||
| event = event_repository.get_by_id(event_id) | ||
|
|
@@ -85,8 +89,13 @@ def post(self, event_id): | |
| if not user: | ||
| return errors.USER_NOT_FOUND | ||
|
|
||
| response = response_repository.get_submitted_by_user_id_for_event(args['user_id'], event_id) | ||
| if not response: | ||
| return errors.RESPONSE_NOT_FOUND | ||
|
|
||
| try: | ||
| status = Status[args['outcome']] | ||
|
|
||
| except KeyError: | ||
| return errors.OUTCOME_STATUS_NOT_VALID | ||
|
|
||
|
|
@@ -101,20 +110,33 @@ def post(self, event_id): | |
| event_id, | ||
| args['user_id'], | ||
| status, | ||
| g.current_user['id']) | ||
| g.current_user['id'], | ||
| reason=args['reason'] | ||
| ) | ||
|
|
||
| outcome_repository.add(outcome) | ||
| db.session.commit() | ||
|
|
||
| if (status == Status.REJECTED or status == Status.WAITLIST): # Email will be sent with offer for accepted candidates | ||
| email_user( | ||
| 'outcome-rejected' if status == Status.REJECTED else 'outcome-waitlist', | ||
| template_parameters=dict( | ||
| host=misc.get_baobab_host() | ||
| ), | ||
| event=event, | ||
| user=user, | ||
| ) | ||
| print("event_type::::::::", event.event_type) | ||
|
||
| print("Type of event.event_type:::::::", type(event.event_type)) | ||
|
||
| if status in [Status.REJECTED, Status.WAITLIST, Status.DESK_REJECTED]: | ||
| email_template = { | ||
| Status.REJECTED: 'outcome-rejected' if not event.event_type == EventType.JOURNAL else 'outcome-journal-rejected', | ||
| Status.WAITLIST: 'outcome-waitlist', | ||
| Status.DESK_REJECTED: 'outcome-desk-rejected' if not event.event_type == EventType.JOURNAL else 'outcome-journal-desk-rejected' | ||
| }.get(status) | ||
|
|
||
| if email_template: | ||
| email_user( | ||
| email_template, | ||
| template_parameters=dict( | ||
| host=misc.get_baobab_host(), | ||
| reason=args['reason'], | ||
| response_id=response.id | ||
| ), | ||
| event=event, | ||
| user=user | ||
|
|
||
| ) | ||
|
|
||
| return outcome, 201 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| """empty message | ||
|
|
||
| Revision ID: 3447b1bb8210 | ||
| Revises: d2c160b0cbe5 | ||
| Create Date: 2024-09-21 11:30:45.546768 | ||
|
|
||
| """ | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = '3447b1bb8210' | ||
| down_revision = 'd2c160b0cbe5' | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| def upgrade(): | ||
|
|
||
| op.execute("""INSERT INTO email_template (id, key, template, language, subject) | ||
| VALUES (71, 'outcome-desk-rejected', 'Dear {title} {firstname} {lastname}, | ||
|
|
||
| Thank you very much for submitting the application, with submission number {response_id}, to the {event_name}. | ||
|
|
||
| We regret to inform you that your submission is desk rejected, with the following motivation by the editors: | ||
|
|
||
| {reason} | ||
|
|
||
| Best wishes, | ||
| The {event_name} Editors', 'en', '{event_name} Application Status Update')""") | ||
|
|
||
| op.execute("""INSERT INTO email_template (id, key, template, language, subject) | ||
| VALUES (72, 'outcome-journal-desk-rejected', 'Dear {title} {firstname} {lastname}, | ||
|
|
||
| Thank you very much for submitting your paper with submission number {response_id} to the {event_name}. | ||
|
|
||
| We regret to inform you that your submission is desk rejected, with the following motivation by the editors: | ||
|
|
||
| {reason} | ||
|
|
||
| Best wishes, | ||
| The {event_name} Editors', 'en', '{event_name} Application Status Update')""") | ||
|
|
||
| op.execute("""INSERT INTO email_template (id, key, template, language, subject) | ||
| VALUES (73, 'outcome-journal-rejected', 'Dear {title} {firstname} {lastname}, | ||
|
|
||
| Thank you very much for submitting your paper with submission number {response_id} to the {event_name}. | ||
|
|
||
| We regret to inform you that your submission is rejected, with the following motivation by the editors: | ||
|
|
||
| {reason} | ||
|
|
||
| Best wishes, | ||
| The {event_name} Editors', 'en', '{event_name} Application Status Update')""") | ||
|
|
||
| def downgrade(): | ||
| # Remove the added email template rows | ||
| op.execute("DELETE FROM email_template WHERE key IN ('outcome-journal-rejected', 'outcome-journal-desk-rejected', 'outcome-desk-rejected')") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """empty message | ||
|
|
||
| Revision ID: d2c160b0cbe5 | ||
| Revises: fb6d5f943621 | ||
| Create Date: 2024-09-16 08:42:06.110593 | ||
|
|
||
| """ | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = 'd2c160b0cbe5' | ||
| down_revision = 'fb6d5f943621' | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.add_column('outcome', sa.Column('reason', sa.String(length=255), nullable=True)) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_column('outcome', 'reason') | ||
| # ### end Alembic commands ### |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """empty message | ||
|
|
||
| Revision ID: fb6d5f943621 | ||
| Revises: d4f153e3cea2 | ||
| Create Date: 2024-09-16 07:53:51.262038 | ||
|
|
||
| """ | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = 'fb6d5f943621' | ||
| down_revision = 'd4f153e3cea2' | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| def upgrade(): | ||
| op.execute("CREATE TYPE outcome_status_new AS ENUM ('ACCEPTED', 'REJECTED', 'WAITLIST', 'REVIEW', 'ACCEPT_W_REVISION', 'REJECT_W_ENCOURAGEMENT', 'DESK_REJECTED')") | ||
| op.execute("ALTER TABLE outcome ALTER COLUMN status TYPE outcome_status_new USING status::text::outcome_status_new") | ||
| op.execute("DROP TYPE outcome_status") | ||
| op.execute("ALTER TYPE outcome_status_new RENAME TO outcome_status") | ||
|
|
||
| def downgrade(): | ||
| op.execute("UPDATE outcome SET status = 'REJECTED' WHERE status = 'DESK_REJECTED'") | ||
| op.execute("CREATE TYPE outcome_status_old AS ENUM ('ACCEPTED', 'REJECTED', 'WAITLIST', 'REVIEW', 'ACCEPT_W_REVISION', 'REJECT_W_ENCOURAGEMENT')") | ||
| op.execute("ALTER TABLE outcome ALTER COLUMN status TYPE outcome_status_old USING status::text::outcome_status_old") | ||
| op.execute("DROP TYPE outcome_status") | ||
| op.execute("ALTER TYPE outcome_status_old RENAME TO outcome_status") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up. I think there is no other print statement that would go in prod.