Skip to content

Commit

Permalink
fix: remove modules from project (#7158)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Jul 25, 2020
1 parent 5cf9640 commit 78cdfeb
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 305 deletions.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,6 @@ Clone the repo and set up the server according to the steps listed. Make sure yo
pip3 install -r requirements/tests.txt
```

#### Enable/Disable modules

- Enable/Disable a specific module

```
python manage.py module --name module_name --switch on/off
```

**_Example :_**

```
python manage.py module --name ticket_include --switch on
python manage.py module -n ticket_include -s off
```

- Enable/Disable all modules

```
python manage.py module --name module_name --switch on/off
```

**_Example :_**

```
python manage.py module --name all --switch on
python manage.py module -n all -s off
```

#### Running unit tests

* If you have docker installed and want to run tests faster, run
Expand Down
24 changes: 3 additions & 21 deletions app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from app.models.faq_type import FaqType
from app.models.feedback import Feedback
from app.models.microlocation import Microlocation
from app.models.module import Module
from app.models.order import Order
from app.models.role import Role
from app.models.role_invite import RoleInvite
Expand Down Expand Up @@ -64,24 +63,9 @@
from app.models.users_events_role import UsersEventsRoles


def validate_event(user, modules, data):
def validate_event(user, data):
if not user.can_create_event():
raise ForbiddenError({'source': ''}, "Please verify your Email")
elif not modules.ticket_include:
raise ForbiddenError({'source': ''}, "Ticketing is not enabled in the system")
if (
data.get('can_pay_by_paypal', False)
or data.get('can_pay_by_cheque', False)
or data.get('can_pay_by_bank', False)
or data.get('can_pay_by_stripe', False)
):
if not modules.payment_include:
raise ForbiddenError({'source': ''}, "Payment is not enabled in the system")
if data.get('is_donation_enabled', False) and not modules.donation_include:
raise ForbiddenError(
{'source': '/data/attributes/is-donation-enabled'},
"Donation is not enabled in the system",
)

if data.get('state', None) == 'published' and not user.can_publish_event():
raise ForbiddenError({'source': ''}, "Only verified accounts can publish events")
Expand Down Expand Up @@ -338,8 +322,7 @@ def before_post(self, args, kwargs, data=None):
:return:
"""
user = User.query.filter_by(id=kwargs['user_id']).first()
modules = Module.query.first()
validate_event(user, modules, data)
validate_event(user, data)
if data['state'] != 'draft':
validate_date(None, data)

Expand Down Expand Up @@ -690,8 +673,7 @@ def before_patch(self, args, kwargs, data=None):
:return:
"""
user = User.query.filter_by(id=current_user.id).one()
modules = Module.query.first()
validate_event(user, modules, data)
validate_event(user, data)

def before_update_object(self, event, data, view_kwargs):
"""
Expand Down
39 changes: 0 additions & 39 deletions app/api/modules.py

This file was deleted.

4 changes: 0 additions & 4 deletions app/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
MicrolocationRelationshipOptional,
MicrolocationRelationshipRequired,
)
from app.api.modules import ModuleDetail
from app.api.notifications import (
NotificationActionDetail,
NotificationActionList,
Expand Down Expand Up @@ -425,9 +424,6 @@
# settings
api.route(SettingDetail, 'setting_detail', '/settings/<id>', '/settings')

# modules
api.route(ModuleDetail, 'module_detail', '/modules/<id>', '/modules')

# pages
api.route(PageList, 'page_list', '/pages')
api.route(PageDetail, 'page_detail', '/pages/<int:id>')
Expand Down
27 changes: 0 additions & 27 deletions app/api/schema/modules.py

This file was deleted.

14 changes: 0 additions & 14 deletions app/models/module.py

This file was deleted.

2 changes: 0 additions & 2 deletions docs/api/api_blueprint_source.apib
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ The Open Event API Server

<!-- include(blueprint/settings.apib) -->

<!-- include(blueprint/modules.apib) -->

<!-- include(blueprint/upload.apib) -->

<!-- include(blueprint/stripe_authorization.apib) -->
Expand Down
98 changes: 0 additions & 98 deletions docs/api/blueprint/modules.apib

This file was deleted.

21 changes: 0 additions & 21 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from app.api.helpers.tasks import resize_event_images_task, resize_speaker_images_task
from app.models import db
from app.models.event import Event, get_new_event_identifier
from app.models.module import Module
from app.models.speaker import Speaker
from populate_db import populate
from tests.all.integration.auth_helper import create_super_admin
Expand Down Expand Up @@ -85,26 +84,6 @@ def fix_digit_identifier():
db.session.commit()


@manager.option('-n', '--name', dest='name', default='all')
@manager.option('-s', '--switch', dest='switch', default='off')
def module(name, switch):
keys = [i.name for i in Module.__table__.columns][1:]
convey = {"on": True, "off": False}
if switch not in ['on', 'off']:
print("Choose either state On/Off")

elif name == 'all':
for key in keys:
setattr(Module.query.first(), key, convey[switch])
print("Module %s turned %s" % (key, switch))
elif name in keys:
setattr(Module.query.first(), name, convey[switch])
print("Module %s turned %s" % (name, switch))
else:
print("Invalid module selected")
db.session.commit()


@manager.option('-e', '--event', help='Event ID. Eg. 1')
def fix_speaker_images(event):
from app.helpers.sessions_speakers.speakers import speaker_image_sizes
Expand Down
34 changes: 34 additions & 0 deletions migrations/versions/rev-2020-07-24-21:26:41-286869159bb5_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""empty message
Revision ID: 286869159bb5
Revises: 8aef207c014f
Create Date: 2020-07-24 21:26:41.814719
"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = '286869159bb5'
down_revision = '8aef207c014f'


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('modules')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('modules',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('ticket_include', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('payment_include', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('donation_include', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='modules_pkey')
)
# ### end Alembic commands ###
Loading

0 comments on commit 78cdfeb

Please sign in to comment.