internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: fossasia/open-event-server

Issue:
All URLs of event are on localhost
Pentabarf, iCal, xCal URLs are all on localhost

https://open-event-api-dev.herokuapp.com/v1/events/7


Discussion:
@iamareebjamal Can I take this?
Go ahead
@iamareebjamal Can you please help me reproduce the error in local? I have tried creating new events but they all are having `i_cal`, `x_cal` values to be `null`

Resolving patch:
diff --git a/app/api/helpers/storage.py b/app/api/helpers/storage.py
--- a/app/api/helpers/storage.py
+++ b/app/api/helpers/storage.py
@@ -178,7 +178,7 @@ def upload_local(uploaded_file, key, upload_dir='static/media/', **kwargs):
     file_relative_path = '/' + file_relative_path
     if get_settings()['static_domain']:
         return get_settings()['static_domain'] + \
-               file_relative_path.replace('/static', '')
+               file_relative_path
 
     return create_url(request.url, file_relative_path)
 


Test patch:
diff --git a/tests/all/integration/api/helpers/test_storage.py b/tests/all/integration/api/helpers/test_storage.py
--- a/tests/all/integration/api/helpers/test_storage.py
+++ b/tests/all/integration/api/helpers/test_storage.py
@@ -19,7 +19,7 @@ def Setup(self):
     @patch('app.api.helpers.storage.get_settings', return_value={'static_domain': 'https://next.eventyay.com'})
     @patch('app.api.helpers.storage.UploadedFile')
     def test_upload_local(self, uploadedfile_object, settings, generated_hash, uploadlocal):
-        expected_response = 'https://next.eventyay.com/media/upload_key/hash/test.pdf'
+        expected_response = 'https://next.eventyay.com/static/media/upload_key/hash/test.pdf'
         uploadedfile_object.filename = 'test.pdf'
 
         with app.test_request_context():
Repository: fossasia/open-event-server

Issue:
AliPay/Omise routes should only be accessible for authenticated users
**Describe the bug**
The current routes are prone to faulty source creation on test deployments. 
Needs to be fixed using Flask-JWT Extended.




Discussion:

Resolving patch:
diff --git a/app/api/orders.py b/app/api/orders.py
--- a/app/api/orders.py
+++ b/app/api/orders.py
@@ -561,6 +561,7 @@ def verify_mobile_paypal_payment(order_identifier):
 
 
 @alipay_blueprint.route('/create_source/<string:order_identifier>', methods=['GET', 'POST'])
+@jwt_required
 def create_source(order_identifier):
     """
     Create a source object for alipay payments.
@@ -600,6 +601,7 @@ def alipay_return_uri(order_identifier):
 
 
 @order_misc_routes.route('/orders/<string:order_identifier>/omise-checkout', methods=['POST', 'GET'])
+@jwt_required
 def omise_checkout(order_identifier):
     """
     Charging the user and returning payment response for Omise Gateway


Test patch:
Repository: fossasia/open-event-server

Issue:
Add celery, redis and SQLAlchemy integrations in sentry
- [ ] Celery integration
- [ ] Redis Integration
- [ ] SQLAlchemy Integration


Discussion:
@iamareebjamal Can you guide me how can I take this?
You have to add these extensions in sentry integration. Read sentry python docs

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -6,6 +6,12 @@
 import sys
 from flask import Flask, json, make_response
 from flask_celeryext import FlaskCeleryExt
+import sentry_sdk
+from sentry_sdk.integrations.flask import FlaskIntegration
+from sentry_sdk.integrations.celery import CeleryIntegration
+from sentry_sdk.integrations.redis import RedisIntegration
+from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
+
 from app.settings import get_settings, get_setts
 from flask_migrate import Migrate, MigrateCommand
 from flask_script import Manager
@@ -42,8 +48,6 @@
 from app.views.redis_store import redis_store
 from app.views.celery_ import celery
 from app.templates.flask_ext.jinja.filters import init_filters
-import sentry_sdk
-from sentry_sdk.integrations.flask import FlaskIntegration
 
 
 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -173,7 +177,8 @@ def create_app():
 
     # sentry
     if not app_created and 'SENTRY_DSN' in app.config:
-        sentry_sdk.init(app.config['SENTRY_DSN'], integrations=[FlaskIntegration()])
+        sentry_sdk.init(app.config['SENTRY_DSN'], integrations=[FlaskIntegration(), RedisIntegration(),
+                                                                CeleryIntegration(), SqlalchemyIntegration()])
 
     # redis
     redis_store.init_app(app)


Test patch:
Repository: fossasia/open-event-server

Issue:
Add server version and an API to show it
- [x] README shows wrong release information, update it to correct release
- [ ] Add an API which shows the current version of the server. 


Discussion:
Hi there,
I would like to work on this issue.
Can you please assign it to me ?
Thanks.
You can start working on it
@iamareebjamal @prateekj117 
Would like like to take this issue! is the server version stored somewhere?
@lladhibhutall Go ahead. I don't think there is. @iamareebjamal Correct me if I am wrong.
No, it needs to be added as a constant in the project
Will create a new file in the root of the project named server_version.py which will have the endpoint returning the current version. 
Create the file in app folder

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -149,6 +149,7 @@ def create_app():
         from app.api.admin_translations import admin_blueprint
         from app.api.orders import alipay_blueprint
         from app.api.settings import admin_misc_routes
+        from app.api.server_version import info_route
 
         app.register_blueprint(api_v1)
         app.register_blueprint(event_copy)
@@ -167,6 +168,7 @@ def create_app():
         app.register_blueprint(admin_blueprint)
         app.register_blueprint(alipay_blueprint)
         app.register_blueprint(admin_misc_routes)
+        app.register_blueprint(info_route)
 
         add_engine_pidguard(db.engine)
 
diff --git a/app/api/server_version.py b/app/api/server_version.py
new file mode 100644
--- /dev/null
+++ b/app/api/server_version.py
@@ -0,0 +1,11 @@
+from flask import jsonify, Blueprint
+
+SERVER_VERSION = '1.7.0-SNAPSHOT'
+
+info_route = Blueprint('info', __name__, url_prefix='/v1')
+_build = {'version': SERVER_VERSION}
+
+
+@info_route.route('/info')
+def version():
+    return jsonify(build=_build)


Test patch:
Repository: fossasia/open-event-server

Issue:
Rename association table to a proper name
There's a table called association

Can anyone guess what it is used for?

That's right. Linking ticket tags and tickets. So obvious...


Discussion:
@iamareebjamal I am a newcomer and I want to take this issue. 
Go on

On Sun, 29 Sep, 2019, 18:05 Sanchit Khurana, <notifications@github.com>
wrote:

> @iamareebjamal <https://github.com/iamareebjamal> I am a newcomer and I
> want to take this issue.
>
> —
> You are receiving this because you were assigned.
> Reply to this email directly, view it on GitHub
> <https://github.com/fossasia/open-event-server/issues/6389?email_source=notifications&email_token=AKQMTLX65NJF42OLLNVUH5DQMCOKTA5CNFSM4IMQTVK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73TTGI#issuecomment-536295833>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AKQMTLTC5UUPQQOYQ7FNDPTQMCOKTANCNFSM4IMQTVKQ>
> .
>

Hi, @kushthedude could you help me with this.
I am new to the community and open source.


Resolving patch:
diff --git a/app/models/ticket.py b/app/models/ticket.py
--- a/app/models/ticket.py
+++ b/app/models/ticket.py
@@ -14,7 +14,7 @@
     db.Column('ticket_id', db.Integer, db.ForeignKey('tickets.id', ondelete='CASCADE')),
     db.PrimaryKeyConstraint('discount_code_id', 'ticket_id'))
 
-ticket_tags_table = db.Table('association', db.Model.metadata,
+ticket_tags_table = db.Table('ticket_tagging', db.Model.metadata,
                              db.Column('ticket_id', db.Integer, db.ForeignKey('tickets.id', ondelete='CASCADE')),
                              db.Column('ticket_tag_id', db.Integer, db.ForeignKey('ticket_tag.id', ondelete='CASCADE'))
                              )
diff --git a/migrations/versions/rev-2019-10-18-15:36:50-9effd270a6ae_association_table_name_change.py b/migrations/versions/rev-2019-10-18-15:36:50-9effd270a6ae_association_table_name_change.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/rev-2019-10-18-15:36:50-9effd270a6ae_association_table_name_change.py
@@ -0,0 +1,24 @@
+"""association table name change
+
+Revision ID: 9effd270a6ae
+Revises: 7c32ba647a18
+Create Date: 2019-10-18 15:36:50.302138
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+# revision identifiers, used by Alembic.
+revision = '9effd270a6ae'
+down_revision = '7c32ba647a18'
+
+
+def upgrade():
+    op.rename_table('association', 'ticket_tagging')
+
+
+def downgrade():
+    op.rename_table('ticket_tagging', 'association')


Test patch:
Repository: fossasia/open-event-server

Issue:
Call for Speakers Signup Form: "Don't require this email" possible for everyone
Server issue for [fossasia/open-event-frontend#3506](https://github.com/fossasia/open-event-frontend/issues/3506) 


Discussion:
Working on this.

Resolving patch:
diff --git a/app/api/speakers.py b/app/api/speakers.py
--- a/app/api/speakers.py
+++ b/app/api/speakers.py
@@ -47,10 +47,10 @@ def before_post(self, args, kwargs, data=None):
                                                           deleted_at=None)) > 0:
             raise ForbiddenException({'pointer': ''}, 'Speaker with this Email ID already exists')
 
-        if data.get('is_email_overriden') and not has_access('is_organizer', event_id=data['event']):
-            raise ForbiddenException({'pointer': 'data/attributes/is_email_overriden'},
+        if data.get('is_email_overridden') and not has_access('is_organizer', event_id=data['event']):
+            raise ForbiddenException({'pointer': 'data/attributes/is_email_overridden'},
                                      'Organizer access required to override email')
-        elif data.get('is_email_overriden') and has_access('is_organizer', event_id=data['event']) and \
+        elif data.get('is_email_overridden') and has_access('is_organizer', event_id=data['event']) and \
                 not data.get('email'):
             data['email'] = current_user.email
 
@@ -135,10 +135,10 @@ def before_update_object(self, speaker, data, view_kwargs):
         if data.get('photo_url') and data['photo_url'] != speaker.photo_url:
             start_image_resizing_tasks(speaker, data['photo_url'])
 
-        if data.get('is_email_overriden') and not has_access('is_organizer', event_id=speaker.event_id):
-            raise ForbiddenException({'pointer': 'data/attributes/is_email_overriden'},
+        if data.get('is_email_overridden') and not has_access('is_organizer', event_id=speaker.event_id):
+            raise ForbiddenException({'pointer': 'data/attributes/is_email_overridden'},
                                      'Organizer access required to override email')
-        elif data.get('is_email_overriden') and has_access('is_organizer', event_id=speaker.event_id) and \
+        elif data.get('is_email_overridden') and has_access('is_organizer', event_id=speaker.event_id) and \
                 not data.get('email'):
             data['email'] = current_user.email
 


Test patch:
Repository: fossasia/open-event-server

Issue:
Event on public page fails to open
On eventyay.com, 
https://eventyay.com/e/78230603

This event is listed in the public page, but server cannot fetch it using it's identifier as the identifier is missing alphabets and thus is interpreted as an ID.

Ideal behavior: identifiers should always have letters in them.


Is the rationale correct @iamareebjamal 


Discussion:
As a temporary solution manually changing Identifer for this particular event now.
Yes, it is correct
@iamareebjamal On it.

Resolving patch:
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -28,8 +28,7 @@
 
 def get_new_event_identifier(length=8):
     identifier = str(binascii.b2a_hex(os.urandom(int(length / 2))), 'utf-8')
-    count = get_count(Event.query.filter_by(identifier=identifier))
-    if count == 0:
+    if not identifier.isdigit() and get_count(Event.query.filter_by(identifier=identifier)) == 0:
         return identifier
     else:
         return get_new_event_identifier(length)
@@ -364,7 +363,7 @@ def get_average_rating(self):
 
     def is_payment_enabled(self):
         return self.can_pay_by_paypal or self.can_pay_by_stripe or self.can_pay_by_omise or self.can_pay_by_alipay \
-            or self.can_pay_by_cheque or self.can_pay_by_bank or self.can_pay_onsite or self.can_pay_by_paytm
+               or self.can_pay_by_cheque or self.can_pay_by_bank or self.can_pay_onsite or self.can_pay_by_paytm
 
     @property
     def average_rating(self):
@@ -455,7 +454,6 @@ def has_speakers(self):
         return Speaker.query.filter_by(event_id=self.id).count() > 0
 
 
-
 @event.listens_for(Event, 'after_update')
 @event.listens_for(Event, 'after_insert')
 def receive_init(mapper, connection, target):
diff --git a/manage.py b/manage.py
--- a/manage.py
+++ b/manage.py
@@ -37,6 +37,15 @@ def add_event_identifier():
         save_to_db(event)
 
 
+@manager.command
+def fix_digit_identifier():
+    events = Event.query.filter(Event.identifier.op('~')('^[0-9\.]+$')).all()
+    for event in events:
+        event.identifier = get_new_event_identifier()
+        db.session.add(event)
+    db.session.commit()
+
+
 @manager.option('-n', '--name', dest='name', default='all')
 @manager.option('-s', '--switch', dest='switch', default='off')
 def module(name, switch):


Test patch:
Repository: fossasia/open-event-server

Issue:
Remove functionality of deleting an order
**Describe the bug**
Right now, anyone can delete anyone's order and we can also delete a placed/deleted order. So we should delete the order deletion feature altogether.

Reference:
[#6450](https://github.com/fossasia/open-event-server/issues/6450)


Discussion:
Working on this.

Resolving patch:
diff --git a/app/api/orders.py b/app/api/orders.py
--- a/app/api/orders.py
+++ b/app/api/orders.py
@@ -431,27 +431,13 @@ def after_update_object(self, order, data, view_kwargs):
                 send_notif_ticket_purchase_organizer(order.event.owner, order.invoice_number, order_url,
                                                      order.event.name, order.identifier)
 
-    def before_delete_object(self, order, view_kwargs):
-        """
-        method to check for proper permissions for deleting
-        :param order:
-        :param view_kwargs:
-        :return:
-        """
-        if not has_access('is_coorganizer', event_id=order.event.id):
-            raise ForbiddenException({'source': ''}, 'Access Forbidden')
-        elif order.amount and order.amount > 0 and (order.status == 'completed' or order.status == 'placed'):
-            raise ConflictException({'source': ''}, 'You cannot delete a placed/completed paid order.')
-
     # This is to ensure that the permissions manager runs and hence changes the kwarg from order identifier to id.
-    decorators = (jwt_required, api.has_permission(
-        'auth_required', methods="PATCH,DELETE", model=Order),)
+    decorators = (jwt_required, api.has_permission('is_admin', methods="DELETE", model=Order),)
     schema = OrderSchema
     data_layer = {'session': db.session,
                   'model': Order,
                   'methods': {
                       'before_update_object': before_update_object,
-                      'before_delete_object': before_delete_object,
                       'before_get_object': before_get_object,
                       'after_update_object': after_update_object
                   }}


Test patch:
Repository: fossasia/open-event-server

Issue:
Error on running `python3 manage.py list_routes`
**Describe the bug**
`AttributeError: module 'urllib' has no attribute 'unquote'`

**Expected behavior**
The command should work properly

**Additional context**
On it.


Discussion:

Resolving patch:
diff --git a/manage.py b/manage.py
--- a/manage.py
+++ b/manage.py
@@ -21,7 +21,7 @@ def list_routes():
     output = []
     for rule in app.url_map.iter_rules():
         methods = ','.join(rule.methods)
-        line = urllib.unquote("{:50s} {:20s} {}".format(
+        line = urllib.parse.unquote("{:50s} {:20s} {}".format(
             rule.endpoint, methods, rule))
         output.append(line)
 


Test patch:
Repository: fossasia/open-event-server

Issue:
Remove decorators from stripe authorization
**Describe the bug**
Remove the decorators to fix the stripe authorization in the frontend 

https://github.com/fossasia/open-event-frontend/issues/3523


**Additional context**
Working on it



Discussion:

Resolving patch:
diff --git a/app/api/stripe_authorization.py b/app/api/stripe_authorization.py
--- a/app/api/stripe_authorization.py
+++ b/app/api/stripe_authorization.py
@@ -70,8 +70,6 @@ def after_create_object(self, stripe_authorization, data, view_kwargs):
         save_to_db(event)
 
     schema = StripeAuthorizationSchema
-    decorators = (api.has_permission('is_coorganizer', fetch="event_id",
-                                     fetch_as="event_id", model=StripeAuthorization),)
     methods = ['POST']
     data_layer = {'session': db.session,
                   'model': StripeAuthorization,


Test patch:
Repository: fossasia/open-event-server

Issue:
Tickets can be created with end date greater than event end date
**Describe the bug**
Tickets can be created with end date greater than event end date.


**Expected behavior**
There should be a server-side check to check that this doesn't happen


**Additional context**
- [x]  Taking this up


Discussion:

Resolving patch:
diff --git a/app/api/tickets.py b/app/api/tickets.py
--- a/app/api/tickets.py
+++ b/app/api/tickets.py
@@ -48,14 +48,20 @@ def before_create_object(self, data, view_kwargs):
         :param view_kwargs:
         :return:
         """
-        if data.get('type') == 'paid' and data.get('event'):
+        if data.get('event'):
             try:
                 event = db.session.query(Event).filter_by(id=data['event'], deleted_at=None).one()
             except NoResultFound:
                 raise UnprocessableEntity({'event_id': data['event']}, "Event does not exist")
-            if not event.is_payment_enabled():
-                raise UnprocessableEntity(
-                    {'event_id': data['event']}, "Event having paid ticket must have a payment method")
+
+            if data.get('type') == 'paid':
+                if not event.is_payment_enabled():
+                    raise UnprocessableEntity(
+                        {'event_id': data['event']}, "Event having paid ticket must have a payment method")
+
+            if data.get('sales_ends_at') > event.ends_at:
+                raise UnprocessableEntity({'sales_ends_at': '/data/attributes/sales-ends-at'},
+                                          "Ticket end date cannot be greater than event end date")
 
     schema = TicketSchema
     methods = ['POST', ]


Test patch:
Repository: fossasia/open-event-server

Issue:
Add created_at, modified_at in ticket holders
Currently, ticket holders/attendees have no information when they were created and when they were modified. At these to the model


Discussion:
Taking this up!
want to take this up
@NickSneo This is a high priority issue, not good for beginners, as we need this mered fast. And anyway, it is already taken up
@iamareebjamal okay, no problem!!!

Resolving patch:
diff --git a/app/models/ticket_holder.py b/app/models/ticket_holder.py
--- a/app/models/ticket_holder.py
+++ b/app/models/ticket_holder.py
@@ -46,6 +46,8 @@ class TicketHolder(SoftDeletionModel):
     checkout_times: str = db.Column(db.String)
     attendee_notes: str = db.Column(db.String)
     event_id: int = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
+    created_at: datetime = db.Column(db.DateTime(timezone=True), default=datetime.utcnow)
+    modified_at: datetime = db.Column(db.DateTime(timezone=True), default=datetime.utcnow,  onupdate=datetime.utcnow)
     complex_field_values: str = db.Column(db.JSON)
     user = db.relationship('User', foreign_keys=[email], primaryjoin='User.email == TicketHolder.email', viewonly=True,
                            backref='attendees')
diff --git a/migrations/versions/rev-2019-12-13-20:34:35-8621f70992ba_.py b/migrations/versions/rev-2019-12-13-20:34:35-8621f70992ba_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/rev-2019-12-13-20:34:35-8621f70992ba_.py
@@ -0,0 +1,30 @@
+"""empty message
+
+Revision ID: 8621f70992ba
+Revises: 0223c881d135
+Create Date: 2019-12-13 20:34:35.014066
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+# revision identifiers, used by Alembic.
+revision = '8621f70992ba'
+down_revision = '0223c881d135'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('ticket_holders', sa.Column('created_at', sa.DateTime(timezone=True), nullable=True))
+    op.add_column('ticket_holders', sa.Column('modified_at', sa.DateTime(timezone=True), nullable=True))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('ticket_holders', 'modified_at')
+    op.drop_column('ticket_holders', 'created_at')
+    # ### end Alembic commands ###


Test patch:
Repository: fossasia/open-event-server

Issue:
Add error handler for status 429 
Status 429 Too many requests has no error handler, and hence it returns HTML instead of JSON

https://flask-limiter.readthedocs.io/en/stable/#custom-rate-limit-exceeded-responses


Discussion:
I am new to open source and would ike to start with this one, please assign it to me
@NickSneo No need for assign, you can work and send the PR
okay thanks
Can I work on this @codedsun ?


Resolving patch:
diff --git a/app/instance.py b/app/instance.py
--- a/app/instance.py
+++ b/app/instance.py
@@ -261,5 +261,17 @@ def internal_server_error(error):
                          {'Content-Type': 'application/vnd.api+json'})
 
 
+@app.errorhandler(429)
+def ratelimit_handler(error):
+    return make_response(json.dumps({
+            'status': 429,
+            'title': 'Request Limit Exceeded'
+        }),
+        429,
+        {
+            'Content-Type': 'application/vnd.api+json'
+        })
+
+
 if __name__ == '__main__':
     current_app.run()


Test patch: