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

Issue:
Delete space in front of colons
Some text pieces coming from the server has a space in front of colons " :". Please check all text including email texts and delete the space in front of colons.


Discussion:
please assign this to me

We don't assign issues to external contributors. Please comment that you're working on the issue after checking that no one else is, and then send a pull request for it. Thank You!
I would like to work on this issue.
is this issue open for work
?

Resolving patch:
diff --git a/create_db.py b/create_db.py
--- a/create_db.py
+++ b/create_db.py
@@ -15,7 +15,7 @@ def create_default_user(email, password):
     if not email:
         ask_email = True
         while ask_email:
-            email = input("Enter email for super_admin    : ")
+            email = input("Enter email for super_admin: ")
             if not re.match(r'[^@]+@[^@]+\.[^@]+', email):
                 print('\nInvalid email address\n')
                 continue
@@ -23,11 +23,11 @@ def create_default_user(email, password):
     if not password:
         ask_password = True
         while ask_password:
-            password = getpass.getpass("Enter password for super_admin : ")
+            password = getpass.getpass("Enter password for super_admin: ")
             if len(password) < 8:
                 print('\nPassword should have minimum 8 characters')
                 continue
-            repassword = getpass.getpass("Enter your password again to confirm : ")
+            repassword = getpass.getpass("Enter your password again to confirm: ")
             if password != repassword:
                 print('\nPassword did not match')
                 continue


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

Issue:
Implement Organizer API with list of EventIDs of Organizers
Here is a question of a user about REST APIs which we also need for the organizer feature:

Is it possible to use this REST interface to query all upcoming events of an organizer? Specifically, that means, can I query all upcoming published events of a user with a web service request and receive the EventIDs? I can then use the EventIDs for the individual queries of the specific event data.


Discussion:
Once group feature is implemented, yes. Currently, the events of a user are private to them

Can I work on this issue?
 I wanna work on this isssue
Group feature has been implemented now

Resolving patch:
diff --git a/app/api/role_invites.py b/app/api/role_invites.py
--- a/app/api/role_invites.py
+++ b/app/api/role_invites.py
@@ -183,6 +183,9 @@ def accept_invite():
                     delete_previous_uer(past_owner)
             role_invite.status = "accepted"
             save_to_db(role_invite, 'Role Invite Accepted')
+            # reset the group of event
+            event.group_id = None
+            save_to_db(event, 'Group ID Removed')
             uer = UsersEventsRoles(user=user, event=event, role=role)
             save_to_db(uer, 'User Event Role Created')
             if not user.is_verified:


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

Issue:
Implement Organizer API with list of EventIDs of Organizers
Here is a question of a user about REST APIs which we also need for the organizer feature:

Is it possible to use this REST interface to query all upcoming events of an organizer? Specifically, that means, can I query all upcoming published events of a user with a web service request and receive the EventIDs? I can then use the EventIDs for the individual queries of the specific event data.


Discussion:
Once group feature is implemented, yes. Currently, the events of a user are private to them

Can I work on this issue?
 I wanna work on this isssue
Group feature has been implemented now

Resolving patch:
diff --git a/app/api/events.py b/app/api/events.py
--- a/app/api/events.py
+++ b/app/api/events.py
@@ -42,6 +42,7 @@
 from app.models.faq import Faq
 from app.models.faq_type import FaqType
 from app.models.feedback import Feedback
+from app.models.group import Group
 from app.models.microlocation import Microlocation
 from app.models.order import Order
 from app.models.role import Role
@@ -349,6 +350,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')
             query_ = self.session.query(Event).filter(
                 getattr(Event, 'group_id') == view_kwargs['group_id']
             )


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

Issue:
CSV Session Export: Show Average Rating and Number of Ratings
The CSV export file of sessions currently does not show "Average Rating" and "Number of Ratings". Please add these two columns into the CSV.

![Screenshot from 2021-06-03 21-57-13](https://user-images.githubusercontent.com/1583873/120704439-dfa29c00-c4b6-11eb-8c88-99f5a311af05.png)



Discussion:

Resolving patch:
diff --git a/app/api/helpers/csv_jobs_util.py b/app/api/helpers/csv_jobs_util.py
--- a/app/api/helpers/csv_jobs_util.py
+++ b/app/api/helpers/csv_jobs_util.py
@@ -109,6 +109,8 @@ def export_sessions_csv(sessions):
         'Slides',
         'Audio',
         'Video',
+        'Average Rating',
+        'Number of Ratings',
     ]
     rows = [headers]
     for session in sessions:
@@ -162,6 +164,8 @@ def export_sessions_csv(sessions):
             column.append(session.slides_url if session.slides_url else '')
             column.append(session.audio_url if session.audio_url else '')
             column.append(session.video_url if session.video_url else '')
+            column.append(session.average_rating)
+            column.append(session.rating_count)
             rows.append(column)
 
     return rows


Test patch:
diff --git a/tests/all/integration/api/helpers/test_csv_jobs_util.py b/tests/all/integration/api/helpers/test_csv_jobs_util.py
--- a/tests/all/integration/api/helpers/test_csv_jobs_util.py
+++ b/tests/all/integration/api/helpers/test_csv_jobs_util.py
@@ -68,6 +68,8 @@ def test_export_sessions_with_details_csv(self):
                 comments='comment',
                 level='level',
                 created_at=common.date_,
+                average_rating=common.average_rating_,
+                rating_count=common.rating_count_,
             )
             db.session.commit()
             field_data = export_sessions_csv([test_session])
@@ -99,6 +101,8 @@ def test_export_sessions_with_details_csv(self):
                     common.url_,
                     common.url_,
                     common.url_,
+                    common.average_rating_,
+                    common.rating_count_,
                 ],
             )
 
diff --git a/tests/factories/common.py b/tests/factories/common.py
--- a/tests/factories/common.py
+++ b/tests/factories/common.py
@@ -23,6 +23,8 @@
 environment_ = 'testing'
 secret_ = 'ABCDefghIJKLmnop'
 fee_ = 1.23
+average_rating_ = 3
+rating_count_ = 1
 slug_ = factory.Sequence(lambda n: f'example_slug{n}')
Repository: fossasia/open-event-server

Issue:
Send email in loop for event announcement.
Send email in loop for event announcement.


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
@@ -276,29 +276,39 @@ def send_email_announce_event(event, group, emails):
     action = MailType.ANNOUNCE_EVENT
     mail = MAILS[action]
 
+    event_name=event.name
+    group_name=group.name
+    event_date=event.starts_at.strftime('%d %B %Y')
+    event_description=event.description
+    event_url=event.site_link
+    event_location=event.normalized_location
+    event_time=event.starts_at.strftime("%H:%M (%Z)")
+    group_url=group.view_page_link
+    app_name=get_settings()['app_name']
+
     if len(emails) > 0:
-        send_email(
-            to=emails[0],
-            action=action,
-            subject=mail['subject'].format(
-                event_name=event.name,
-                group_name=group.name,
-                event_date=event.starts_at.strftime('%d %B %Y'),
-            ),
-            html=render_template(
-                mail['template'],
-                event_name=event.name,
-                event_description=event.description,
-                event_url=event.site_link,
-                event_location=event.normalized_location,
-                event_date=event.starts_at.strftime('%d %B %Y'),
-                event_time=event.starts_at.strftime("%H:%M (%Z)"),
-                group_name=group.name,
-                group_url=group.view_page_link,
-                app_name=get_settings()['app_name'],
-            ),
-            bcc=emails[1:],
-        )
+        for email in emails:
+            send_email(
+                to=email,
+                action=action,
+                subject=mail['subject'].format(
+                    event_name=event_name,
+                    group_name=group_name,
+                    event_date=event_date,
+                ),
+                html=render_template(
+                    mail['template'],
+                    event_name=event_name,
+                    event_description=event_description,
+                    event_url=event_url,
+                    event_location=event_location,
+                    event_date=event_date,
+                    event_time=event_time,
+                    group_name=group_name,
+                    group_url=group_url,
+                    app_name=app_name,
+                ),
+            )
 
 
 def send_email_for_monthly_fee_payment(
diff --git a/app/models/group.py b/app/models/group.py
--- a/app/models/group.py
+++ b/app/models/group.py
@@ -45,4 +45,4 @@ def follower(self):
     @property
     def view_page_link(self):
         frontend_url = get_settings()['frontend_url']
-        return f"{frontend_url}/groups/{self.id}"
+        return f"{frontend_url}/g/{self.id}"


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

Issue:
Fix and improve confirmation email for ticket orders.
Please change the ticket order email as follows:
- Change subject as in the below example
- Update text as below. There are some small changes.
- Add quotation marks for event
- make the entire following text into a link to the ticket page "tickets or registration information here"
- If event is on same day, only show date once
- Behind time show the timezone
- Add "Location info" - online, to be announced or event address
   - for online events show: Online (Please login to the platform to access the video room on the event page)
   - for onsite events show address here
- Add "URL:" in front of event link
- Move "message to organizer" above and slightly change text as below and add two horizontal lines
- Only show "message from the organizer" if the organizer actually added a message


--

Subject: See you at "event_name" (Order_number)

```
Hello,

Thank you for signing up for "event_name_with_link".

This is your confirmation. You can now download your tickets or registration information here_with_link.

Order Summary:
Name: Mario Behling
Ticket/Registration: Kostenlose Teilnahme
Quantity: 1
Order number: O1628510987-22009

About this event:
Date: August 17, 2021 05:00 PM - 06:00 PM (CET)
Location: Online (Please login to the platform to access the video room on the event page)
URL: event_URL

-- horizontal line --

Here is a message from the organizer:

organizer_message_here

-- horizontal line --

Best regards,
eventyay Team

--
Login to manage your orders at https://eventyay.com

```

Previous confirmation email looked like that:

![Screenshot from 2021-08-09 15-17-15](https://user-images.githubusercontent.com/1583873/128718752-4ed12516-e2a0-4ebc-9acc-6e95ba9ff4db.png)



Discussion:

Resolving patch:
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
@@ -172,7 +172,7 @@ def entries():
     },
     MailType.TICKET_PURCHASED: {
         'recipient': 'User',
-        'subject': 'Your order invoice and tickets for {event_name} ({invoice_id}) ',
+        'subject': 'See you at {event_name} ({invoice_id}) ',
         'template': 'email/ticket_purchased.html',
     },
     MailType.TICKET_PURCHASED_ATTENDEE: {
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -453,6 +453,15 @@ def normalized_location(self):
             return self.site_link
         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)'
+        elif self.location_name:
+            return self.location_name
+        else:
+            return 'Location Not Announced'
+
     @property
     def has_coordinates(self):
         return self.latitude and self.longitude


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

Issue:
Ticket Invoices - add invoice number
Add an invoice number to ticket invoices into the heading - same as in organizer invoices and show "app name" above the invoice.

Please implement this as follows:

* Display app name, e.g. eventyay on top
* Then show heading "Invoice" and invoice number
* Make the top heading "Invoice" translatable
* Add an invoice number behind "Invoice" in the following format: YYYYE-[eventID]000001 (show the actual event ID in the event ID area)
* Make the numbers according to the event only (e.g. if an organizer has two different events each event starts with 000001.
* On the first of January the format is starting again with 00001.

![Screenshot from 2021-09-03 18-30-12](https://user-images.githubusercontent.com/1583873/132038773-a257ea07-0591-47f1-8d1d-c5b88d7402e8.png)



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
@@ -25,6 +25,7 @@
 from app.models.ticket import Ticket
 from app.models.ticket_fee import TicketFees
 from app.models.ticket_holder import TicketHolder
+from app.models.setting import Setting
 from app.settings import get_settings
 
 
@@ -99,6 +100,8 @@ 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()
@@ -110,6 +113,7 @@ def create_pdf_tickets_for_holder(order):
                 event=order.event,
                 tax=order.event.tax,
                 order_tickets=order_tickets,
+                admin_info=admin_info,
             ),
             UPLOAD_PATHS['pdf']['order'],
             dir_path='/static/uploads/pdf/tickets/',


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

Issue:
Unify tax calculation at one place
Right now tax calculation of the system is distributed in different places in different files. There is also repetition of code and some of this calculation is in frontend also. This creates confusion while editing tax info in one place. Also there in `/calculate-amount` endpoint in API for calculating `order_amount`. The idea is to unify tax calculation at one place, preferably `/calculate-amount` endpoint in API
PDF Invoice: Show Discounts in the invoice
The PDF invoice for ticket buyers does not show discount codes clearly. Please implement the following:
* Add the discount code into the description with "Discount code: samplecodehere, Discount: 10% or USD 2.00 etc."
* Show the discount in the item price list with the original price strike through


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
@@ -222,6 +222,7 @@ def calculate_order_amount(tickets, discount_code=None):
     total_amount = total_tax = total_discount = 0.0
     ticket_list = []
     for ticket in fetched_tickets:
+        ticket_tax = discounted_tax = 0.0
         ticket_info = ticket_map[ticket.id]
         discount_amount = 0.0
         discount_data = None
@@ -253,6 +254,12 @@ def calculate_order_amount(tickets, discount_code=None):
         else:
             price = ticket.price if ticket.type != 'free' else 0.0
 
+        if tax:
+            if tax_included:
+                ticket_tax = price - price / (1 + tax.rate / 100)
+            else:
+                ticket_tax = price * tax.rate / 100
+
         if discount_code and ticket.type != 'free':
             code = (
                 DiscountCode.query.with_parent(ticket)
@@ -266,6 +273,8 @@ def calculate_order_amount(tickets, discount_code=None):
                         discount_percent = (discount_amount / price) * 100
                     else:
                         discount_amount = (price * code.value) / 100
+                        if tax:
+                            discounted_tax = ticket_tax - (ticket_tax * code.value / 100)
                         discount_percent = code.value
                     discount_data = {
                         'code': discount_code.code,
@@ -290,6 +299,8 @@ def calculate_order_amount(tickets, discount_code=None):
                 'discount': discount_data,
                 'ticket_fee': round(ticket_fee, 2),
                 'sub_total': round(sub_total, 2),
+                'ticket_tax': round(ticket_tax, 2),
+                'discounted_tax': round(discounted_tax, 2)
             }
         )
 


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

Issue:
Add event date & time to subject of attendee ticket email
Event date & time should be added to the subject of TICKET_PURCHASED_ATTENDEE email.


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
@@ -583,6 +583,8 @@ def send_email_to_attendees(order):
             subject=mail['subject'].format(
                 event_name=event.name,
                 invoice_id=order.invoice_number,
+                event_date=event_date,
+                event_time=event_time,
             ),
             html=render_template(
                 mail['template'],
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
@@ -197,7 +197,7 @@ def entries():
     },
     MailType.TICKET_PURCHASED_ATTENDEE: {
         'recipient': 'Attendee',
-        'subject': 'Your tickets for {event_name} ({invoice_id}) ',
+        'subject': 'Your tickets for {event_name} on {event_date} at {event_time} ({invoice_id}) ',
         'template': 'email/ticket_purchased_attendee.html',
     },
     MailType.TICKET_PURCHASED_ORGANIZER: {


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

Issue:
PDF Invoice: Show Discounts in the invoice
The PDF invoice for ticket buyers does not show discount codes clearly. Please implement the following:
* Add the discount code into the description with "Discount code: samplecodehere, Discount: 10% or USD 2.00 etc."
* Show the discount in the item price list with the original price strike through


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,6 +283,7 @@ def calculate_order_amount(tickets, discount_code=None):
                         'percent': round(discount_percent, 2),
                         'amount': round(discount_amount, 2),
                         'total': round(discount_amount * quantity, 2),
+                        'type': code.type
                     }
 
         total_discount += round(discount_amount * quantity, 2)


Test patch:
diff --git a/tests/all/integration/api/helpers/order/test_calculate_order_amount.py b/tests/all/integration/api/helpers/order/test_calculate_order_amount.py
--- a/tests/all/integration/api/helpers/order/test_calculate_order_amount.py
+++ b/tests/all/integration/api/helpers/order/test_calculate_order_amount.py
@@ -331,6 +331,7 @@ def _assert_tax_data_discount(amount_data):
         'percent': 10.0,
         'amount': 45.63,
         'total': 182.52,
+        'type': 'percent',
     }
     assert amount_data['tickets'][1]['sub_total'] == 1642.68
     assert amount_data['tickets'][2]['discount'] == {
@@ -338,6 +339,7 @@ def _assert_tax_data_discount(amount_data):
         'percent': 10.0,
         'amount': 78.97,
         'total': 236.91,
+        'type': 'percent',
     }
     assert amount_data['tickets'][2]['sub_total'] == 2132.19
     assert amount_data['tickets'][3]['discount'] is None
Repository: fossasia/open-event-server

Issue:
Send out tickets and invoices do not have proper name
When a user receives emails with their ticket and invoice the documents have the name of the email address of the user. On the platform the naming is, e.g. Stripe test event-Tickets-9c440e6c-3e0b-48ae-9b50-2b4ba291caea.pdf. Please also send out the documents with the same name as they are if users download it from the website.

![Screenshot from 2021-10-29 11-17-37](https://user-images.githubusercontent.com/1583873/139411111-3f99e196-7bde-4e46-8596-d85542b9a018.png)




Discussion:

Resolving patch:
diff --git a/app/api/helpers/tasks.py b/app/api/helpers/tasks.py
--- a/app/api/helpers/tasks.py
+++ b/app/api/helpers/tasks.py
@@ -130,7 +130,7 @@ def send_email_task_sendgrid(payload):
             attachment.disposition = Disposition('attachment')
             if filename.endswith('.pdf'):
                 attachment.file_type = FileType('application/pdf')
-                attachment.file_name = FileName(payload['to'])
+                attachment.file_name = FileName(filename)
             elif filename.endswith('.ics'):
                 attachment.file_type = FileType('text/calendar')
                 attachment.file_name = FileName('ical.ics')


Test patch: