internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pretix/pretix

Issue:
Mark required question fields at checkout
e.g. with a `*`



Discussion:
Hi I'm new to this and am looking to make my first contributions.

Do you have any specific advice or objections to me giving this ticket a shot?

Thanks!

Hi! Did you alread work with Python or Django or is it your first time in this whole field? I'd be glad to give you some pointers here and there if you help me estimate your prior experience :)

I thought about it and now I'm unsure whether this is a good start because while the task sounds really simple (just put a \* next to the description every field that is required) it could require you to dive into https://github.com/dyve/django-bootstrap3 to make this work.

I've worked with Python before but not with Django so this probably isn't the most suitable task as you said.

I have 18 months computing experience with Python and I actually teach at GCSE and A level... So a tremendous understanding of all the basics i'm just looking to push myself further, and I'd currently rate myself at CS degree graduate level, maybe a little beyond.

I suggest you look for a Django project that is smaller in terms of codebase because it will be easier to get an overview of everything. If you'd like to contribute to pretix, I suggest giving #104 a try, it will take you to various parts of the project with only small changes in every part necessary.

With a bit of luck, Django 2.0 will finally have template-based form rendering which will make this a lot easier.


Resolving patch:
diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py
--- a/src/pretix/presale/forms/checkout.py
+++ b/src/pretix/presale/forms/checkout.py
@@ -19,6 +19,7 @@
 
 
 class ContactForm(forms.Form):
+    required_css_class = 'required'
     email = forms.EmailField(label=_('E-mail'),
                              help_text=_('Make sure to enter a valid email address. We will send you an order '
                                          'confirmation including a link that you need in case you want to make '
@@ -48,6 +49,7 @@ def clean(self):
 
 
 class InvoiceAddressForm(forms.ModelForm):
+    required_css_class = 'required'
 
     class Meta:
         model = InvoiceAddress
@@ -61,6 +63,7 @@ class Meta:
     def __init__(self, *args, **kwargs):
         self.event = event = kwargs.pop('event')
         super().__init__(*args, **kwargs)
+        self.fields['name'].form_group_class = 'required'
         if not event.settings.invoice_address_vatid:
             del self.fields['vat_id']
         if not event.settings.invoice_address_required:
@@ -118,6 +121,7 @@ class QuestionsForm(forms.Form):
     the attendee name for admission tickets, if the corresponding setting is enabled,
     as well as additional questions defined by the organizer.
     """
+    required_css_class = 'required'
 
     def __init__(self, *args, **kwargs):
         """


Test patch:
Repository: pretix/pretix

Issue:
Ordering caret not working in orders page
URLs are correctly generated but `ordering` get requests handling is missed out in OrderList `get_queryset` method. 

![orderingcaret](https://user-images.githubusercontent.com/28383090/28318730-62cd1f80-6bfe-11e7-86fc-83a311af017f.png)



Discussion:

Resolving patch:
diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py
--- a/src/pretix/control/views/orders.py
+++ b/src/pretix/control/views/orders.py
@@ -59,6 +59,13 @@ def get_queryset(self):
         if self.filter_form.is_valid():
             qs = self.filter_form.filter_qs(qs)
 
+        if self.request.GET.get("ordering", "") != "":
+            p = self.request.GET.get("ordering", "")
+            p_admissable = ('-code', 'code', '-email', 'email', '-total', 'total', '-datetime',
+                            'datetime', '-status', 'status', 'pcnt', '-pcnt')
+            if p in p_admissable:
+                qs = qs.order_by(p)
+
         return qs.distinct()
 
     def get_context_data(self, **kwargs):


Test patch:
Repository: pretix/pretix

Issue:
Documentation of order_paid-signal unclear
This might be just me not being able to english, but I think that the documentation  at https://github.com/pretix/pretix/blob/a08cb3b8e4adaa300868e3f730e045bc8e6d0203/src/pretix/base/signals.py#L152-L154 is missing something.


Discussion:
I think just the ``it`` is too much

Resolving patch:
diff --git a/src/pretix/base/signals.py b/src/pretix/base/signals.py
--- a/src/pretix/base/signals.py
+++ b/src/pretix/base/signals.py
@@ -151,7 +151,7 @@ def connect(self, receiver, sender=None, weak=True, dispatch_uid=None):
 """
 This signal is sent out every time an order is paid. The order object is given
 as the first argument. This signal is *not* sent out if an order is marked as paid
-because it an already-paid order has been splitted.
+because an already-paid order has been split.
 
 As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
 """


Test patch:
Repository: pretix/pretix

Issue:
Download reminder email uses wrong logging ID
Not very important but: 
https://github.com/pretix/pretix/blob/master/src/pretix/base/services/orders.py#L649


Discussion:
Yep, this should be ``pretix.event.order.email.download_reminder_sent`` instead of ``pretix.event.order.email.expire_warning_sent``. Also, https://github.com/pretix/pretix/blob/master/src/pretix/control/logdisplay.py would need a proper human string for that then :)

Resolving patch:
diff --git a/src/pretix/base/services/orders.py b/src/pretix/base/services/orders.py
--- a/src/pretix/base/services/orders.py
+++ b/src/pretix/base/services/orders.py
@@ -646,7 +646,7 @@ def send_download_reminders(sender, **kwargs):
             try:
                 o.send_mail(
                     email_subject, email_template, email_context,
-                    'pretix.event.order.email.expire_warning_sent'
+                    'pretix.event.order.email.download_reminder_sent'
                 )
             except SendMailException:
                 logger.exception('Reminder email could not be sent')
diff --git a/src/pretix/control/logdisplay.py b/src/pretix/control/logdisplay.py
--- a/src/pretix/control/logdisplay.py
+++ b/src/pretix/control/logdisplay.py
@@ -127,6 +127,8 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs):
         'pretix.event.order.payment.changed': _('The payment method has been changed.'),
         'pretix.event.order.email.sent': _('An unidentified type email has been sent.'),
         'pretix.event.order.email.custom_sent': _('A custom email has been sent.'),
+        'pretix.event.order.email.download_reminder_sent': _('An email has been sent with a reminder that the ticket '
+                                                             'is available for download.'),
         'pretix.event.order.email.expire_warning_sent': _('An email has been sent with a warning that the order is about '
                                                           'to expire.'),
         'pretix.event.order.email.order_canceled': _('An email has been sent to notify the user that the order has been canceled.'),


Test patch:
Repository: pretix/pretix

Issue:
Error when adding item with no tax rule and custom price to order
I have an event series with a single product, for which I did not configure any tax rule. When trying to add a product to an order with a custom price, I get an Error. 

https://github.com/pretix/pretix/blob/fc7bafe3d98b499f9ae2b2fe4f17e79552b62e4c/src/pretix/base/services/orders.py#L777

`item.tax_rule` is `None`, so the function call fails.


Discussion:
That's bad, OrderChangeManager should respect that. Although I'm thinking about deprecating tax_rule=None at some point, it is too easy to forget setting one and having a tax problem…

Resolving patch:
diff --git a/src/pretix/base/services/orders.py b/src/pretix/base/services/orders.py
--- a/src/pretix/base/services/orders.py
+++ b/src/pretix/base/services/orders.py
@@ -812,7 +812,7 @@ def add_position(self, item: Item, variation: ItemVariation, price: Decimal, add
         if price is None:
             price = get_price(item, variation, subevent=subevent, invoice_address=self._invoice_address)
         else:
-            if item.tax_rule.tax_applicable(self._invoice_address):
+            if item.tax_rule and item.tax_rule.tax_applicable(self._invoice_address):
                 price = item.tax(price, base_price_is='gross')
             else:
                 price = TaxedPrice(gross=price, net=price, tax=Decimal('0.00'), rate=Decimal('0.00'), name='')


Test patch:
Repository: pretix/pretix

Issue:
Check-in list include unpaid option in subevent detail view
All properties of a check-in list linked to a subevent can be altered in the subevents detail view. The option `include unpaid` is new, but can't be edited there.

This also has the effect that when duplicating a subevent, the attribute value `include unpaid` of the check-in list isn't copied over to the form.


Discussion:
Good catch! Do you want to submit a PR? :wink: 
Yes :)

Resolving patch:
diff --git a/src/pretix/control/views/subevents.py b/src/pretix/control/views/subevents.py
--- a/src/pretix/control/views/subevents.py
+++ b/src/pretix/control/views/subevents.py
@@ -148,6 +148,7 @@ def cl_formset(self):
                     'name': cl.name,
                     'all_products': cl.all_products,
                     'limit_products': cl.limit_products.all(),
+                    'include_pending': cl.include_pending,
                 } for cl in self.copy_from.checkinlist_set.prefetch_related('limit_products')
             ]
             extra = len(kwargs['initial'])
@@ -156,6 +157,7 @@ def cl_formset(self):
                 {
                     'name': '',
                     'all_products': True,
+                    'include_pending': False,
                 }
             ]
             extra = 1


Test patch:
Repository: pretix/pretix

Issue:
Display remaining quota of add-on products
Currently if you enable "Show number of tickets left" on an event that only applies to products, not add-on products. In my opinion if there is an quota presend for add-on products it should also be displayed (if the quota is exceeded that is already displayed).
Display remaining quota of add-on products
Currently if you enable "Show number of tickets left" on an event that only applies to products, not add-on products. In my opinion if there is an quota presend for add-on products it should also be displayed (if the quota is exceeded that is already displayed).


Discussion:

Resolving patch:
diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py
--- a/src/pretix/presale/forms/checkout.py
+++ b/src/pretix/presale/forms/checkout.py
@@ -152,6 +152,9 @@ def _label(self, event, item_or_variation, avail, override_price=None):
             n += ' – {}'.format(_('SOLD OUT'))
         elif avail[0] < 100:
             n += ' – {}'.format(_('Currently unavailable'))
+        else:
+            if avail[1] is not None and event.settings.show_quota_left:
+                n += ' – {}'.format(_('%(num)s currently available') % {'num': avail[1]})
 
         return n
 


Test patch:
Repository: pretix/pretix

Issue:
Add event name to admin notification
When recieving an admin notification, e.g. when an order is placed, only the order number is displayed in the mail. It would be great to also see the event, right now you have to look it up in the "Detail" button url.

I thought this could be an easy task by adding `n.add_attribute(_('Event'), order.event.name)` to `src/pretix/base/notifications.py`, but unfortunately I was not successful.

Thanks for your work!


Discussion:
Good point.

What was your problem exactly? Can you try ``n.add_attribute(_('Event'), str(order.event.name))``?

Resolving patch:
diff --git a/src/pretix/base/notifications.py b/src/pretix/base/notifications.py
--- a/src/pretix/base/notifications.py
+++ b/src/pretix/base/notifications.py
@@ -174,6 +174,7 @@ def build_notification(self, logentry: LogEntry):
             title=self._title.format(order=order, event=logentry.event),
             url=order_url
         )
+        n.add_attribute(_('Event'), order.event.name)
         n.add_attribute(_('Order code'), order.code)
         n.add_attribute(_('Order total'), money_filter(order.total, logentry.event.currency))
         n.add_attribute(_('Order date'), date_format(order.datetime, 'SHORT_DATETIME_FORMAT'))


Test patch:
Repository: pretix/pretix

Issue:
rich_text: tel schema
When providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.


Discussion:

Resolving patch:
diff --git a/src/pretix/base/templatetags/rich_text.py b/src/pretix/base/templatetags/rich_text.py
--- a/src/pretix/base/templatetags/rich_text.py
+++ b/src/pretix/base/templatetags/rich_text.py
@@ -58,6 +58,8 @@
     # Update doc/user/markdown.rst if you change this!
 }
 
+ALLOWED_PROTOCOLS = ['http', 'https', 'mailto', 'tel']
+
 
 def safelink_callback(attrs, new=False):
     url = attrs.get((None, 'href'), '/')
@@ -86,7 +88,8 @@ def markdown_compile(source):
             ]
         ),
         tags=ALLOWED_TAGS,
-        attributes=ALLOWED_ATTRIBUTES
+        attributes=ALLOWED_ATTRIBUTES,
+        protocols=ALLOWED_PROTOCOLS,
     )
 
 


Test patch:
Repository: pretix/pretix

Issue:
rich_text: tel schema
When providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.
rich_text: tel schema
When providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.


Discussion:
Woo! Thank you :)
Woo! Thank you :)

Resolving patch:
diff --git a/src/pretix/base/templatetags/rich_text.py b/src/pretix/base/templatetags/rich_text.py
--- a/src/pretix/base/templatetags/rich_text.py
+++ b/src/pretix/base/templatetags/rich_text.py
@@ -63,7 +63,7 @@
 
 def safelink_callback(attrs, new=False):
     url = attrs.get((None, 'href'), '/')
-    if not is_safe_url(url) and not url.startswith('mailto:'):
+    if not is_safe_url(url) and not url.startswith('mailto:') and not url.startswith('tel:'):
         signer = signing.Signer(salt='safe-redirect')
         attrs[None, 'href'] = reverse('redirect') + '?url=' + urllib.parse.quote(signer.sign(url))
         attrs[None, 'target'] = '_blank'


Test patch:
Repository: pretix/pretix

Issue:
Widget code generator compatibility mode required 
Currently, it is required to check the checkbox for compatibility mode, because the form field definition doesn't include `required=False`. Therefore I cannot access the not compatibility widget code.

https://github.com/pretix/pretix/blob/ab67eea36e77104c9577a8be907066396acc6b60/src/pretix/control/forms/event.py#L985
Widget code generator compatibility mode required 
Currently, it is required to check the checkbox for compatibility mode, because the form field definition doesn't include `required=False`. Therefore I cannot access the not compatibility widget code.

https://github.com/pretix/pretix/blob/ab67eea36e77104c9577a8be907066396acc6b60/src/pretix/control/forms/event.py#L985


Discussion:
Oops! 
Oops! 

Resolving patch:
diff --git a/src/pretix/control/forms/event.py b/src/pretix/control/forms/event.py
--- a/src/pretix/control/forms/event.py
+++ b/src/pretix/control/forms/event.py
@@ -984,6 +984,7 @@ class WidgetCodeForm(forms.Form):
     )
     compatibility_mode = forms.BooleanField(
         label=_("Compatibility mode"),
+        required=False,
         help_text=_("Our regular widget doesn't work in all website builders. If you run into trouble, try using "
                     "this compatibility mode.")
     )


Test patch:
Repository: pretix/pretix

Issue:
Invoice information consistency
During checkout, if I choose "business customer", enter a company name, and then reconsider and switch to the individual customer interface, the "company name" name field gets hidden, but its value is still visible in the next step.


Discussion:

Resolving patch:
diff --git a/src/pretix/base/forms/questions.py b/src/pretix/base/forms/questions.py
--- a/src/pretix/base/forms/questions.py
+++ b/src/pretix/base/forms/questions.py
@@ -216,6 +216,8 @@ def __init__(self, *args, **kwargs):
 
     def clean(self):
         data = self.cleaned_data
+        if not data.get('is_business'):
+            data['company'] = ''
         if not data.get('name') and not data.get('company') and self.event.settings.invoice_address_required:
             raise ValidationError(_('You need to provide either a company name or your name.'))
 


Test patch:
Repository: pretix/pretix

Issue:
Not all Backend-Signals are displayed in documentation
I'm not sure why, but when looking at https://docs.pretix.eu/en/latest/development/api/general.html#backend, it seems to me like quite a few signals are not being displayed here...

Comparing to https://github.com/pretix/pretix/blob/master/doc/development/api/general.rst#backend, for example all the `html` and `navbar`-signals are missing...


Discussion:
Yeah, we're apparently not that good at consistently documenting them. Thanks for pointing it out!
Sorry, misread your issue. Instead, this is likely the source of the issue:

```
/home/raphael/proj/pretix/doc/development/api/general.rst:28: WARNING: missing attribute mentioned in :members: or __all__: module pretix.presale.signals, attribute footer_links
/home/raphael/proj/pretix/doc/development/api/general.rst:50: WARNING: Error in "automodule" directive:
invalid option block.

.. automodule:: pretix.control.signals
   :members: nav_event, html_head, html_page_start, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings,
   order_info, event_settings_widget, oauth_application_registered
```

Resolving patch:
diff --git a/src/pretix/presale/signals.py b/src/pretix/presale/signals.py
--- a/src/pretix/presale/signals.py
+++ b/src/pretix/presale/signals.py
@@ -26,7 +26,7 @@
     providing_args=["request"]
 )
 """
-The signal ``pretix.presale.signals.footer_links`` allows you to add links to the footer of an event page. You
+The signal ``pretix.presale.signals.footer_link`` allows you to add links to the footer of an event page. You
 are expected to return a dictionary containing the keys ``label`` and ``url``.
 
 As with all plugin signals, the ``sender`` keyword argument will contain the event.


Test patch:
Repository: pretix/pretix

Issue:
Include a link in "new voucher" notification
After creating a new voucher, you are shown a notification that a voucher of this specific code was created. It would be nice to make that code clickable, leading to the voucher's detail/edit page.


Discussion:

Resolving patch:
diff --git a/src/pretix/control/forms/vouchers.py b/src/pretix/control/forms/vouchers.py
--- a/src/pretix/control/forms/vouchers.py
+++ b/src/pretix/control/forms/vouchers.py
@@ -179,9 +179,7 @@ def clean(self):
         return data
 
     def save(self, commit=True):
-        super().save(commit)
-
-        return ['item']
+        return super().save(commit)
 
 
 class VoucherBulkForm(VoucherForm):
diff --git a/src/pretix/control/views/vouchers.py b/src/pretix/control/views/vouchers.py
--- a/src/pretix/control/views/vouchers.py
+++ b/src/pretix/control/views/vouchers.py
@@ -12,6 +12,7 @@
 from django.shortcuts import redirect, render
 from django.urls import resolve, reverse
 from django.utils.functional import cached_property
+from django.utils.html import format_html
 from django.utils.translation import ugettext_lazy as _
 from django.views.generic import (
     CreateView, DeleteView, ListView, TemplateView, UpdateView, View,
@@ -240,8 +241,15 @@ def get_form_kwargs(self):
     @transaction.atomic
     def form_valid(self, form):
         form.instance.event = self.request.event
-        messages.success(self.request, _('The new voucher has been created: {code}').format(code=form.instance.code))
         ret = super().form_valid(form)
+        url = reverse('control:event.voucher', kwargs={
+            'organizer': self.request.event.organizer.slug,
+            'event': self.request.event.slug,
+            'voucher': self.object.pk
+        })
+        messages.success(self.request, _('The new voucher has been created: {code}').format(
+            code=format_html('<a href="{url}">{code}</a>', url=url, code=self.object.code)
+        ))
         form.instance.log_action('pretix.voucher.added', data=dict(form.cleaned_data), user=self.request.user)
         return ret
 


Test patch:
Repository: pretix/pretix

Issue:
Required file question breaks validation on edit
Editing an order with a product with a required file question breaks when the customer tries to edit the order. In that case even if the customer already provided a file earlier the validation for the question fails on edit.
Required file question breaks validation on edit
Editing an order with a product with a required file question breaks when the customer tries to edit the order. In that case even if the customer already provided a file earlier the validation for the question fails on edit.


Discussion:
I had a closer look at this and it turns out it is the in-browser validation based on the `required` attribute of the `input` element that causes browsers to refuse to send the form. The backend validation works as expected.

I have working proof of concept but I'm not quite sure the place I fixed it is the best place to put the fix. I'll prepare a PR so that we can discuss this.
I had a closer look at this and it turns out it is the in-browser validation based on the `required` attribute of the `input` element that causes browsers to refuse to send the form. The backend validation works as expected.

I have working proof of concept but I'm not quite sure the place I fixed it is the best place to put the fix. I'll prepare a PR so that we can discuss this.

Resolving patch:
diff --git a/src/pretix/base/forms/widgets.py b/src/pretix/base/forms/widgets.py
--- a/src/pretix/base/forms/widgets.py
+++ b/src/pretix/base/forms/widgets.py
@@ -46,6 +46,14 @@ def __init__(self, attrs=None, time_format=None):
 
 class UploadedFileWidget(forms.ClearableFileInput):
     def __init__(self, *args, **kwargs):
+        # Browsers can't recognize that the server already has a file uploaded
+        # Don't mark this input as being required if we already have an answer
+        # (this needs to be done via the attrs, otherwise we wouldn't get the "required" star on the field label)
+        attrs = kwargs.get('attrs', {})
+        if kwargs.get('required') and kwargs.get('initial'):
+            attrs.update({'required': None})
+        kwargs.update({'attrs': attrs})
+
         self.position = kwargs.pop('position')
         self.event = kwargs.pop('event')
         self.answer = kwargs.pop('answer')


Test patch: