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

Issue:
Make invoices and emails fully translatable
Emails and invoices are not fully translated. This results in email with mixed languages. Some strings are not labeled ready for translations. Therefore Weblate will not recognize them as translatable. For example in Weblate German shows up as 100% translated even though text is not translated. If Weblate shows up 100% translated, but areas are not really translated something is wrong. Compare https://hosted.weblate.org/projects/open-event/server/de/

For example check the ticket order email. Only the first sentence is translatable.



Discussion:
Reopening for some changes
After applying the recent changes some areas are still not translatable. 

Please check how to make the email subjects translatable.

![Screenshot from 2021-10-29 04-43-12](https://user-images.githubusercontent.com/1583873/139365171-cf9b0121-48cd-47b1-afcd-3851720491f7.png)

On the invoice PDF the following is not translatable
* Payment status
* Payment method

![Screenshot from 2021-10-29 11-07-10](https://user-images.githubusercontent.com/1583873/139408705-8c0bcd64-11e9-4bad-8a8a-35ba25c598a3.png)

Looking into this
Is there any chance to display date and time in the correct language too?
Payment status and payment method are not yet translatable, e.g. in Emails.

![Screenshot from 2021-11-04 13-20-23](https://user-images.githubusercontent.com/1583873/140312780-75bcb92c-8b40-48e7-9c9c-b6d5edf209f9.png)

Still need to make email subjects translatable.
I will solve that in #8333 
Thank you for the recent changes.

I still find the following not translated in emails:

"Online (Please login to the platform to access the video room on the event page)"

![Screenshot from 2021-11-06 18-46-01](https://user-images.githubusercontent.com/1583873/140618968-d44cee59-3e79-4c0c-9c3f-a0d2fcbaa4a9.png)


Resolving patch:
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -7,6 +7,7 @@
 import flask_login as login
 import pytz
 from flask import current_app
+from flask_babel import _
 from sqlalchemy import event
 from sqlalchemy.dialects.postgresql import JSONB
 from sqlalchemy.sql import func
@@ -464,16 +465,16 @@ def normalized_location(self):
             return self.location_name
         elif self.online:
             return self.site_link
-        return 'Location Not Announced'
+        return _('Location Not Announced')
 
     @property
     def event_location_status(self):
         if self.online:
-            return 'Online (Please login to the platform to access the video room on the event page)'
+            return _('Online (Please login to the platform to access the video room on the event page)')
         elif self.location_name:
             return self.location_name
         else:
-            return 'Location Not Announced'
+            return _('Location Not Announced')
 
     @property
     def has_coordinates(self):


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

Issue:
Change absolute links to system links
As seen in this PR https://github.com/fossasia/open-event-server/pull/8330/files a number of files have absolute links instead of relative URLs or system variables.

Please implement this in a proper way.


Discussion:
https://github.com/fossasia/open-event-server/pull/8330#discussion_r739771027

Resolving patch:
diff --git a/app/api/helpers/mail.py b/app/api/helpers/mail.py
--- a/app/api/helpers/mail.py
+++ b/app/api/helpers/mail.py
@@ -425,6 +425,7 @@ def send_email_for_monthly_fee_payment(
     key = options[follow_up]
     mail = MAILS[key]
     email = user.email
+    invoice_url = make_frontend_url('/account/billing/invoices')
     send_email(
         to=email,
         action=key,
@@ -436,6 +437,7 @@ def send_email_for_monthly_fee_payment(
             name=user.full_name,
             email=email,
             event_name=event_name,
+            invoice_url=invoice_url,
             date=previous_month,
             amount=amount,
             app_name=app_name,


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

Issue:
Prefill customer_email in stripe checkout page
Self explainable.

Parent issue: #8146 


Discussion:

Resolving patch:
diff --git a/app/api/helpers/payment.py b/app/api/helpers/payment.py
--- a/app/api/helpers/payment.py
+++ b/app/api/helpers/payment.py
@@ -122,17 +122,20 @@ def capture_payment(order_invoice, currency=None, credentials=None):
             #     payment_method_types.append('sepa_debit')
 
             session = stripe.checkout.Session.create(
-                payment_method_types= payment_method_types,
-                line_items=[{
-                    'price_data': {
-                        'currency': currency.lower(),
-                        'product_data': {
-                            'name': order_invoice.event.name,
+                customer_email=order_invoice.user.email,
+                payment_method_types=payment_method_types,
+                line_items=[
+                    {
+                        'price_data': {
+                            'currency': currency.lower(),
+                            'product_data': {
+                                'name': order_invoice.event.name,
+                            },
+                            'unit_amount': int(order_invoice.amount * 100),
                         },
-                        'unit_amount': int(order_invoice.amount * 100),
-                    },
-                    'quantity': 1,
-                }],
+                        'quantity': 1,
+                    }
+                ],
                 mode='payment',
                 success_url=f"{frontend_url}/orders/{order_invoice.identifier}/view",
                 cancel_url=f"{frontend_url}/orders/{order_invoice.identifier}/view",


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

Issue:
Improve ticket PDF and add missing info
Improve the ticket PDF
You can take some inspiration from other tickets. Change the following:
* Add a box around the basic ticket info and add the app logo on the top left
* Add order information
* Align Order info and Name/Email more orderly
* Add the event image on the top right next to the event name
* Add a box to display the "After Order Message" from wizard step one. Only show the box if there is actually an after order message.

Compare to the ticket PDF of other services
![Screenshot from 2021-10-09 22-54-27](https://user-images.githubusercontent.com/1583873/136673692-a590682b-1e12-4dc2-b85e-6b786a87ce5b.png)

Current example of the ticket PDF
![Screenshot from 2021-10-09 10-53-53](https://user-images.githubusercontent.com/1583873/136673694-0a631f10-c67b-448a-a7c2-84220661968b.png)



Discussion:
working on it.

Resolving patch:
diff --git a/app/api/helpers/order.py b/app/api/helpers/order.py
--- a/app/api/helpers/order.py
+++ b/app/api/helpers/order.py
@@ -87,15 +87,10 @@ def create_pdf_tickets_for_holder(order):
         date_time=order.event.ends_at,
         tz=order.event.timezone
     )
-
+    admin_info = Setting.query.first()
     if order.status == 'completed' or order.status == 'placed':
         pdf = create_save_pdf(
-            render_template(
-                'pdf/ticket_purchaser.html',
-                order=order,
-                starts_at=starts_at,
-                ends_at=ends_at
-            ),
+            render_template('pdf/ticket_purchaser.html', order=order,app_name=get_settings()['app_name'],admin_info=admin_info,starts_at=starts_at,ends_at=ends_at),
             UPLOAD_PATHS['pdf']['tickets_all'],
             dir_path='/static/uploads/pdf/tickets/',
             identifier=order.identifier,
@@ -119,12 +114,7 @@ def create_pdf_tickets_for_holder(order):
 
             # create attendee pdf for every ticket holder
             pdf = create_save_pdf(
-                render_template(
-                    'pdf/ticket_attendee.html',
-                    order=order,
-                    starts_at=starts_at,
-                    ends_at=ends_at,
-                    holder=holder),
+                render_template('pdf/ticket_attendee.html', order=order, holder=holder,app_name=get_settings()['app_name'],admin_info=admin_info,starts_at=starts_at,ends_at=ends_at),
                 UPLOAD_PATHS['pdf']['tickets_all'],
                 dir_path='/static/uploads/pdf/tickets/',
                 identifier=order.identifier,
@@ -134,7 +124,6 @@ def create_pdf_tickets_for_holder(order):
             holder.pdf_url = pdf
             save_to_db(holder)
         
-        admin_info = Setting.query.first()
 
         # create order invoices pdf
         order_tickets = OrderTicket.query.filter_by(order_id=order.id).all()


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

Issue:
Fix app name in strings
Please change the following strings in the app

- Email Confirmation to Create Account for Open-Event -> Email Confirmation to Create Account for {app_name}
- {event_name} is over. Thank you for using eventyay! -> {event_name} is over. Thank you for using {app_name}!


Discussion:

Resolving patch:
diff --git a/app/api/helpers/mail.py b/app/api/helpers/mail.py
--- a/app/api/helpers/mail.py
+++ b/app/api/helpers/mail.py
@@ -506,9 +506,15 @@ def send_email_change_user_email(user, email):
         base64.b64encode(bytes(serializer.dumps([email, str_generator()]), 'utf-8')),
         'utf-8',
     )
+    app_name=get_settings()['app_name']
     link = make_frontend_url('/email/verify', {'token': hash_})
     send_email_with_action(
-        user.email, MailType.USER_CONFIRM, 'user_confirm', email=user.email, link=link
+        user.email,
+        MailType.USER_CONFIRM,
+        'user_confirm',
+        email=user.email,
+        link=link,
+        app_name=app_name
     )
     send_email_with_action(
         email,
@@ -759,7 +765,10 @@ def send_email_after_event(email, event_name):
     send_email(
         to=email,
         action=action,
-        subject=mail['subject'].format(event_name=event_name),
+        subject=mail['subject'].format(
+            event_name=event_name,
+            app_name=app_name
+        ),
         html=render_template(
             mail['template'],
             app_name=app_name,
diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py
--- a/app/api/helpers/system_mails.py
+++ b/app/api/helpers/system_mails.py
@@ -153,7 +153,7 @@ def entries():
     },
     MailType.USER_CONFIRM: {
         'recipient': 'User',
-        'subject': _('Email Confirmation to Create Account for Open-Event'),
+        'subject': _('Email Confirmation to Create Account for {app_name}'),
         'template': 'email/user_confirm.html',
     },
     MailType.USER_CHANGE_EMAIL: {
@@ -280,7 +280,7 @@ def entries():
     },
     MailType.AFTER_EVENT: {
         'recipient': 'Owner, Organizer, Coorganizer',
-        'subject': _('{event_name} is over. Thank you for using eventyay!'),
+        'subject': _('{event_name} is over. Thank you for using {app_name}!'),
         'template': 'email/after_event.html',
     },
     MailType.AFTER_EVENT_SPEAKER: {


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

Issue:
Integrate Klarna, Sepa in Stripe
Integrate Klarna, Sepa payment methods in Stripe


Discussion:
![Screenshot from 2021-11-15 20-31-39](https://user-images.githubusercontent.com/1583873/141843095-98ff3650-ee15-4435-9295-c4d9114880fd.png)

Actually Klarna (Sofort) and Sepa are active both in live and test mode. They just need to be implemented to show up in the "live" section.

Stripe states:
> Once you start to receive payments with a payment method, it will move from the “eligible” section to the “live” section on your payment settings dashboard.

Resolving patch:
diff --git a/app/api/helpers/payment.py b/app/api/helpers/payment.py
--- a/app/api/helpers/payment.py
+++ b/app/api/helpers/payment.py
@@ -116,14 +116,8 @@ def capture_payment(order_invoice, currency=None, credentials=None):
         frontend_url = get_settings()['frontend_url']
 
         try:
-            # payment_method_types = ['card', 'klarna']
-            payment_method_types = ['card']
-            # if currency.lower() == 'eur':
-            #     payment_method_types.append('sepa_debit')
-
             session = stripe.checkout.Session.create(
                 customer_email=order_invoice.user.email,
-                payment_method_types=payment_method_types,
                 line_items=[
                     {
                         'price_data': {


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

Issue:
Celery config deprecation
Celery now expects lowercase settings. See [this](https://docs.celeryproject.org/en/stable/userguide/configuration.html#new-lowercase-settings)


Discussion:

Resolving patch:
diff --git a/app/instance.py b/app/instance.py
--- a/app/instance.py
+++ b/app/instance.py
@@ -123,9 +123,9 @@ def create_app():
     _jwt.token_in_blacklist_loader(is_token_blacklisted)
 
     # setup celery
-    app.config['CELERY_BROKER_URL'] = app.config['REDIS_URL']
-    app.config['CELERY_RESULT_BACKEND'] = app.config['CELERY_BROKER_URL']
-    app.config['CELERY_ACCEPT_CONTENT'] = ['json', 'application/text']
+    app.config['broker_url'] = app.config['REDIS_URL']
+    app.config['result_backend'] = app.config['broker_url']
+    app.config['accept_content'] = ['json', 'application/text']
 
     app.config['MAIL_RECORDER'] = MailRecorder(use_env=True)
 


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

Issue:
Attendee does not see ticket under "my tickets" if another user bought the ticket
If one user (ticket buyer) buys a ticket for another user (attendee) the order should show up for both people under "my tickets". Only one thing should not show for the "attendee" which is "Cancel Order".

The attendee should then also have access to the online event. This currently works as expected.

![Screenshot from 2021-11-24 13-10-43](https://user-images.githubusercontent.com/1583873/143236045-6084648f-3fc5-49ce-b86b-b05931257b06.png)



Discussion:
can i work on this?
@Mani7061338807 Yes
Ok thanks
hello sir, i have required a small help, i am unable to run this app in my local system. how can i do this?

@pc-beast This needs changes in the db models. Should I add a new relationship on the `User` table to reference `TicketHolder` table ??
how i can contribute 


Resolving patch:
diff --git a/app/api/orders.py b/app/api/orders.py
--- a/app/api/orders.py
+++ b/app/api/orders.py
@@ -242,7 +242,7 @@ def query(self, view_kwargs):
             user = safe_query_kwargs(User, view_kwargs, 'user_id')
             if not has_access('is_user_itself', user_id=user.id):
                 raise ForbiddenError({'source': ''}, 'Access Forbidden')
-            query_ = query_.filter(Order.user_id == user.id)
+            query_ = query_.join(TicketHolder).filter(TicketHolder.email == user.email)
         else:
             # orders under an event
             query_ = event_query(query_, view_kwargs, restrict=True)


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

Issue:
Error while buying a free registration ticket
- Create an event with free registration ticket
- Try to buy a ticket and see the error in console


Discussion:

Resolving patch:
diff --git a/app/api/helpers/order.py b/app/api/helpers/order.py
--- a/app/api/helpers/order.py
+++ b/app/api/helpers/order.py
@@ -283,7 +283,7 @@ def calculate_order_amount(tickets, discount_code=None):
                     f"{ticket.min_price} to {ticket.max_price}",
                 )
         else:
-            price = ticket.price if ticket.type != 'free' else 0.0
+            price = ticket.price if ticket.type not in ['free', 'freeRegistration'] else 0.0
 
         if tax:
             if tax_included:
@@ -291,7 +291,7 @@ def calculate_order_amount(tickets, discount_code=None):
             else:
                 ticket_tax = price * tax.rate / 100
 
-        if discount_code and ticket.type != 'free':
+        if discount_code and ticket.type not in ['free', 'freeRegistration']:
             code = (
                 DiscountCode.query.with_parent(ticket)
                 .filter_by(id=discount_code.id)


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

Issue:
Adjust the Server to the Changes in Gender Options
The server needs to be changed slightly in order to work with the new client after implementing [feature no 8842](https://github.com/fossasia/open-event-frontend/issues/8842) in the frontend.


Discussion:

Resolving patch:
diff --git a/app/api/helpers/static.py b/app/api/helpers/static.py
--- a/app/api/helpers/static.py
+++ b/app/api/helpers/static.py
@@ -563,11 +563,13 @@
 ]
 
 GENDER_CHOICES = [
-    'Male',
-    'Female',
-    'Other',
-    'Diverse / Non-binary',
-    'Prefer not to share',
+    'Man',
+    'Woman',
+    'Transgender',
+    'Non-binary',
+    'Genderqueer',
+    'An identity not listed here',
+    'I prefer not to say',
 ]
 
 LEVEL_CHOICES = ['Beginner', 'Intermediate', 'Advanced', 'Expert']


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

Issue:
Adjust the Server to the Changes in Gender Options
The server needs to be changed slightly in order to work with the new client after implementing [feature no 8842](https://github.com/fossasia/open-event-frontend/issues/8842) in the frontend.


Discussion:
The bug of still occurring "gender" prompts instead of "Which of these categories describe your gender identity? (check all that apply)" prompts mentioned by @lthanhhieu [here](https://github.com/fossasia/open-event-frontend/issues/8842) actually needs to be fixed in the backend.

Resolving patch:
diff --git a/app/models/custom_form.py b/app/models/custom_form.py
--- a/app/models/custom_form.py
+++ b/app/models/custom_form.py
@@ -145,7 +145,7 @@
     "github": "GitHub",
     "linkedin": "LinkedIn",
     "instagram": "Instagram",
-    "gender": "Gender",
+    "gender": "Which of these categories describe your gender identity? (check all that apply)",
     "ageGroup": "Age Group",
     "acceptVideoRecording": "Photo & video & text consent",
     "acceptShareDetails": "Partner contact consent",


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

Issue:
Merge development to master
SSIA


Discussion:

Resolving patch:
diff --git a/app/models/custom_form.py b/app/models/custom_form.py
--- a/app/models/custom_form.py
+++ b/app/models/custom_form.py
@@ -150,7 +150,7 @@
     "acceptVideoRecording": "Photo & video & text consent",
     "acceptShareDetails": "Partner contact consent",
     "acceptReceiveEmails": "Email consent",
-    "is_consent_form_field": "Consent form field",
+    "is_consent_form_field": "Code of conduct consent",
     "is_consent_form_field_photo": "Wikimania photo consent",
     "is_consent_form_field_email": "Wikimania email updates",
     "is_consent_of_refund_policy": "Consent of refund policy",


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

Issue:
8870-stripe-id-description
<!--
(Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.)
-->
<!-- Add the issue number that is fixed by this PR (In the form Fixes #123) -->

Fixes #8960

#### Short description of what this resolves:


#### Changes proposed in this pull request:

- Updated paymentIntent object to have description from invoice's event
-
-

#### Checklist

- [x] I have read the [Contribution & Best practices Guide](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia) and my PR follows them.
- [x] My branch is up-to-date with the Upstream `development` branch.
- [ ] The unit tests pass locally with my changes <!-- use `nosetests tests/` to run all the tests -->
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)
<!-- If an existing function does not have a docstring, please add one -->
- [ ] All the functions created/modified in this PR contain relevant docstrings.



Discussion:

Resolving patch:
diff --git a/app/api/helpers/payment.py b/app/api/helpers/payment.py
--- a/app/api/helpers/payment.py
+++ b/app/api/helpers/payment.py
@@ -114,6 +114,8 @@ def get_payment_intent_stripe(order_invoice, currency=None, credentials=None):
         if not currency or currency == "":
             currency = "USD"
 
+        event_name = order_invoice.event.name
+
         try:
             payment_intent = stripe.PaymentIntent.create(
                 amount=int(order_invoice.amount * 100),
@@ -122,6 +124,7 @@ def get_payment_intent_stripe(order_invoice, currency=None, credentials=None):
                 automatic_payment_methods={
                     'enabled': True,
                 },
+                description=f"Eventyay {event_name}"
             )
             return payment_intent
 


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

Issue:
API to get user ID with JWT token



Discussion:
To Store under Users > User Details > Get User ID 

Resolving patch:
diff --git a/app/api/custom/users.py b/app/api/custom/users.py
new file mode 100644
--- /dev/null
+++ b/app/api/custom/users.py
@@ -0,0 +1,30 @@
+import jwt
+from flask import Blueprint, current_app, request
+
+from app.api.helpers.permissions import jwt_required
+
+users_routes = Blueprint('users_routes', __name__, url_prefix='/v1/users')
+
+
+@users_routes.route('/user-details/get-user-id', methods=['GET'])
+@jwt_required
+def get_user_id():
+    """
+    Get user id from token
+    """
+    token = None
+    if "Authorization" in request.headers:
+        token = request.headers["Authorization"].split(" ")[1]
+    if not token:
+        return {
+            "message": "Authentication Token is missing!",
+            "data": None,
+            "error": "Unauthorized",
+        }, 401
+    try:
+        data = jwt.decode(token, current_app.config["SECRET_KEY"], algorithms=["HS256"])
+        if not data.get('identity', False):
+            return {"message": "Can't get user id!", "data": None}, 404
+        return {"user_id": data["identity"]}, 200
+    except UnicodeDecodeError:
+        return {"message": "Can't get user id!", "data": None}, 500
diff --git a/app/instance.py b/app/instance.py
--- a/app/instance.py
+++ b/app/instance.py
@@ -169,6 +169,7 @@ def create_app():
         from app.api.custom.group_role_invite import group_role_invites_routes
         from app.api.video_stream import streams_routes
         from app.api.events import events_blueprint
+        from app.api.custom.users import users_routes
 
         app.register_blueprint(api_v1)
         app.register_blueprint(event_copy)
@@ -202,6 +203,7 @@ def create_app():
         app.register_blueprint(events_blueprint)
         app.register_blueprint(tickets_routes)
         app.register_blueprint(group_role_invites_routes)
+        app.register_blueprint(users_routes)
 
         add_engine_pidguard(db.engine)
 


Test patch:
diff --git a/tests/all/integration/api/helpers/test_auth.py b/tests/all/integration/api/helpers/test_auth.py
--- a/tests/all/integration/api/helpers/test_auth.py
+++ b/tests/all/integration/api/helpers/test_auth.py
@@ -1,3 +1,5 @@
+import json
+
 from flask_login import login_user, logout_user
 
 from app.api.helpers.auth import AuthManager
@@ -41,3 +43,16 @@ def test_check_auth_admin(db):
     user.is_admin = False
     status = AuthManager.check_auth_admin('authtest2@gmail.com', 'password')
     assert False == status
+
+
+def test_get_user_id(client, jwt):
+    """Method to test get user id"""
+
+    response = client.get(
+        '/v1/users/user-details/get-user-id',
+        content_type='application/vnd.api+json',
+        headers=jwt,
+    )
+
+    assert response.status_code == 200
+    assert json.loads(response.data)['user_id']