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

Issue:
Warning: NullBooleanField is deprecated in Django 3.1
### Issue Summary

NullBooleanField is deprecated in Django 3.1. Running any manage.py command throughs a non-critical warning.

```
WARNINGS:
catalogue.ProductAttributeValue.value_boolean: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
	HINT: Use BooleanField(null=True) instead.
```

### Suggested solution

The fix seems pretty straightforward
https://github.com/django-oscar/django-oscar/blob/master/src/oscar/apps/catalogue/abstract_models.py#L1043

```
-    value_boolean = models.NullBooleanField(_('Boolean'), blank=True, db_index=True)
+   value_boolean = models.BooleanField(_('Boolean'), blank=True, null=True, db_index=True)
```

But I am not sure of the impact to the migrations, etc. In my limited testing I have not yet been able to override and test this.

### Technical details

* Python version: Python 3.9.1
* Django version: Version: 3.1.6
* Oscar version: Version: 3.0


Discussion:

Resolving patch:
diff --git a/src/oscar/apps/catalogue/abstract_models.py b/src/oscar/apps/catalogue/abstract_models.py
--- a/src/oscar/apps/catalogue/abstract_models.py
+++ b/src/oscar/apps/catalogue/abstract_models.py
@@ -1040,7 +1040,7 @@ class AbstractProductAttributeValue(models.Model):
 
     value_text = models.TextField(_('Text'), blank=True, null=True)
     value_integer = models.IntegerField(_('Integer'), blank=True, null=True, db_index=True)
-    value_boolean = models.NullBooleanField(_('Boolean'), blank=True, db_index=True)
+    value_boolean = models.BooleanField(_('Boolean'), blank=True, null=True, db_index=True)
     value_float = models.FloatField(_('Float'), blank=True, null=True, db_index=True)
     value_richtext = models.TextField(_('Richtext'), blank=True, null=True)
     value_date = models.DateField(_('Date'), blank=True, null=True, db_index=True)
diff --git a/src/oscar/apps/catalogue/migrations/0022_auto_20210210_0539.py b/src/oscar/apps/catalogue/migrations/0022_auto_20210210_0539.py
new file mode 100644
--- /dev/null
+++ b/src/oscar/apps/catalogue/migrations/0022_auto_20210210_0539.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.1.6 on 2021-02-10 05:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0021_auto_20201005_0844'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='productattributevalue',
+            name='value_boolean',
+            field=models.BooleanField(blank=True, db_index=True, null=True, verbose_name='Boolean'),
+        ),
+    ]


Test patch:
Repository: django-oscar/django-oscar

Issue:
AutoSlugField fails to properly validate unicode slugs when they are permitted
Hi friends, I'm using unicode slug in product (`OSCAR_SLUG_ALLOW_UNICODE = True`). When I create the product it's  created successfully, but when I'm trying to update it, the slug field fails to validate.


Discussion:

Resolving patch:
diff --git a/src/oscar/apps/catalogue/abstract_models.py b/src/oscar/apps/catalogue/abstract_models.py
--- a/src/oscar/apps/catalogue/abstract_models.py
+++ b/src/oscar/apps/catalogue/abstract_models.py
@@ -375,7 +375,7 @@ class AbstractProduct(models.Model):
     # Title is mandatory for canonical products but optional for child products
     title = models.CharField(pgettext_lazy('Product title', 'Title'),
                              max_length=255, blank=True)
-    slug = models.SlugField(_('Slug'), max_length=255, unique=False)
+    slug = SlugField(_('Slug'), max_length=255, unique=False)
     description = models.TextField(_('Description'), blank=True)
     meta_title = models.CharField(_('Meta title'), max_length=255, blank=True, null=True)
     meta_description = models.TextField(_('Meta description'), blank=True, null=True)
diff --git a/src/oscar/apps/catalogue/migrations/0023_auto_20210824_1414.py b/src/oscar/apps/catalogue/migrations/0023_auto_20210824_1414.py
new file mode 100644
--- /dev/null
+++ b/src/oscar/apps/catalogue/migrations/0023_auto_20210824_1414.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.1.4 on 2021-08-24 13:14
+
+from django.db import migrations
+import oscar.models.fields.slugfield
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0022_auto_20210210_0539'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='product',
+            name='slug',
+            field=oscar.models.fields.slugfield.SlugField(max_length=255, verbose_name='Slug'),
+        ),
+    ]


Test patch:
Repository: django-oscar/django-oscar

Issue:
RangeDetailView should have pagination 
The page RangeDetailView (oscar/offer/range.html) should show products in pagination.
Because there might be too many products in a Range


Discussion:
Hi @solarissmoke 
I'm a first time contributor. I've gone through the contribution docs and setup the project locally.

If no one is working on this issue, may I take it up?
Yes, please do!

Resolving patch:
diff --git a/src/oscar/apps/offer/views.py b/src/oscar/apps/offer/views.py
--- a/src/oscar/apps/offer/views.py
+++ b/src/oscar/apps/offer/views.py
@@ -55,6 +55,7 @@ def get_queryset(self):
 class RangeDetailView(ListView):
     template_name = 'oscar/offer/range.html'
     context_object_name = 'products'
+    paginate_by = settings.OSCAR_PRODUCTS_PER_PAGE
 
     def dispatch(self, request, *args, **kwargs):
         self.range = get_object_or_404(


Test patch:
Repository: django-oscar/django-oscar

Issue:
Streamline handling of links in email templates
### Issue Summary
Nearly all email templates expect an endpoint e.g. something like `/account/order/<order_number>/` and use the template tag `absolute_url` to construct the fully qualified URL. I.e. the protocol and the domain can be adjusted in the template code instead of overwriting views or mixins. See here:
https://github.com/django-oscar/django-oscar/blob/master/src/oscar/templates/oscar/communication/emails/commtype_email_changed_body.html#L20

The one exception to this is the order placed email. Here a fully-qualified URL is passed to the template that is then just rendered. See here:
https://github.com/django-oscar/django-oscar/blob/master/src/oscar/apps/checkout/mixins.py#L294

This has the obvious disadvantage that the protocol is hard-coded to HTTP and the domain always refers to the sites framework.

Please let me know if this is inconsistent for a reason. In that case, additional documentation of the reasons would be great.

I'm happy to submit a PR for this ✌️


Discussion:

Resolving patch:
diff --git a/src/oscar/apps/checkout/mixins.py b/src/oscar/apps/checkout/mixins.py
--- a/src/oscar/apps/checkout/mixins.py
+++ b/src/oscar/apps/checkout/mixins.py
@@ -290,6 +290,9 @@ def get_message_context(self, order):
             # We don't care that much if we can't resolve the URL
             pass
         else:
+            ctx['status_path'] = path
+
+            # status_url is deprecated, see https://github.com/django-oscar/django-oscar/issues/3826
             site = Site.objects.get_current(self.request)
             ctx['status_url'] = 'http://%s%s' % (site.domain, path)
         return ctx


Test patch:
Repository: django-oscar/django-oscar

Issue:
Large number of baskets makes Order Admin page slow to load
Found a bug? Please fill out the sections below.

### Issue Summary

A summary of the issue.

Our shop has a large number of baskets now.  This mean that the basket dropdown in the order admin page takes about a minute to load.

### Steps to Reproduce

Create 2000+ baskets, submit one order, and then view that order in Django Admin

Is there a way we should be purging baskets, can we add Select2 (or otherwise) or make this read only?

### Technical details
Python 3.9, Django 3.2, Oscar 3.1



Discussion:
I think the simplest fix here is to change the basket to use a [raw id](https://docs.djangoproject.com/en/4.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields) in the admin instead of a dropdown - PR welcome if you have time.

Resolving patch:
diff --git a/src/oscar/apps/order/admin.py b/src/oscar/apps/order/admin.py
--- a/src/oscar/apps/order/admin.py
+++ b/src/oscar/apps/order/admin.py
@@ -29,7 +29,7 @@ class OrderAdmin(admin.ModelAdmin):
     raw_id_fields = ['user', 'billing_address', 'shipping_address', ]
     list_display = ('number', 'total_incl_tax', 'site', 'user',
                     'billing_address', 'date_placed')
-    readonly_fields = ('number', 'total_incl_tax', 'total_excl_tax',
+    readonly_fields = ('number', 'basket', 'total_incl_tax', 'total_excl_tax',
                        'shipping_incl_tax', 'shipping_excl_tax')
     inlines = [LineInline]
 


Test patch:
Repository: django-oscar/django-oscar

Issue:
Error on ProfileForm when using a Profile model
It only happens when a Profile model is specified through `AUTH_PROFILE_MODULE`:
https://github.com/django-oscar/django-oscar/blob/41efb274b0ff6ce674e7142f5d09b2001614f7f3/src/oscar/apps/customer/forms.py#L272-L276

The problem is that UserAndProfileForm is using SortedDict that is deprecated since Django 1.9

This is the problematic line:
https://github.com/django-oscar/django-oscar/blob/41efb274b0ff6ce674e7142f5d09b2001614f7f3/src/oscar/apps/customer/forms.py#L314

Link to django docs where it says that it's been removed in Django 1.9:
https://docs.djangoproject.com/en/1.8/ref/utils/#django.utils.datastructures.SortedDict



Discussion:

Resolving patch:
diff --git a/src/oscar/apps/customer/forms.py b/src/oscar/apps/customer/forms.py
--- a/src/oscar/apps/customer/forms.py
+++ b/src/oscar/apps/customer/forms.py
@@ -311,7 +311,8 @@ def __init__(self, user, *args, **kwargs):
                 self.fields[field_name].initial = getattr(user, field_name)
 
             # Ensure order of fields is email, user fields then profile fields
-            self.fields.keyOrder = user_field_names + profile_field_names
+            self.field_order = user_field_names + profile_field_names
+            self.order_fields(self.field_order)
 
         class Meta:
             model = Profile


Test patch:
Repository: django-oscar/django-oscar

Issue:
Offer order export from offer detail view only includes page 1 in export.
If you go to the offer detail view in the dashboard, and this offer has been used in orders, you can generate an export.

See:
https://github.com/django-oscar/django-oscar/blob/1d1590f2a69ee75723482afb135b24c5c3523838/src/oscar/apps/dashboard/offers/views.py#L407-L412

However, if you got multiple pages of orders, only the first page will be in the export.
It makes more sense when you generate an export, it will include all the orders.



Discussion:

Resolving patch:
diff --git a/src/oscar/apps/dashboard/offers/views.py b/src/oscar/apps/dashboard/offers/views.py
--- a/src/oscar/apps/dashboard/offers/views.py
+++ b/src/oscar/apps/dashboard/offers/views.py
@@ -407,6 +407,6 @@ def get_context_data(self, **kwargs):
     def render_to_response(self, context):
         if self.request.GET.get('format') == 'csv':
             formatter = OrderDiscountCSVFormatter()
-            return formatter.generate_response(context['order_discounts'],
+            return formatter.generate_response(self.get_queryset(),
                                                offer=self.offer)
         return super().render_to_response(context)


Test patch:
diff --git a/tests/functional/dashboard/test_offer.py b/tests/functional/dashboard/test_offer.py
--- a/tests/functional/dashboard/test_offer.py
+++ b/tests/functional/dashboard/test_offer.py
@@ -2,6 +2,7 @@
 from django.utils import timezone
 
 from oscar.apps.offer import models
+from oscar.apps.order.models import OrderDiscount
 from oscar.test import factories, testcases
 
 
@@ -248,6 +249,20 @@ def test_remove_offer_from_combinations(self):
 
         self.assertNotIn(offer_a, offer_b.combinations.all())
 
+    def test_create_offer_order_report(self):
+        order1 = factories.create_order(number="100001")
+        order2 = factories.create_order(number="100002")
+        offer = factories.create_offer()
+        OrderDiscount.objects.create(order=order1, offer_id=offer.id)
+        OrderDiscount.objects.create(order=order2, offer_id=offer.id)
+
+        report_url = "%s%s" % (reverse("dashboard:offer-detail", kwargs={'pk': offer.pk}), "?format=csv")
+        response = self.get(report_url)
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.headers["Content-Type"], "text/csv")
+        self.assertIn("100001", response.content.decode("utf-8"))
+        self.assertIn("100002", response.content.decode("utf-8"))
+
 
 class TestOfferListSearch(testcases.WebTestCase):
     is_staff = True
Repository: django-oscar/django-oscar

Issue:
 Is active filter on offers not included suspend offer
### Issue Summary
 suspend offer doesn't display when a filter with 'NO' option on is_active

### Steps to Reproduce
1. create suspend offer
2. select 'NO' option on is_active filter

![slack_jtj6oOsA0i](https://user-images.githubusercontent.com/52238281/148913506-ebe09742-b74a-4ddd-b6e7-053cef375145.gif)

### Technical details

* Python 3.8.10
* Django version: Version: 3.1
* Oscar version: Version: 3.1

 Is active filter on offers not included suspend offer
### Issue Summary
 suspend offer doesn't display when a filter with 'NO' option on is_active

### Steps to Reproduce
1. create suspend offer
2. select 'NO' option on is_active filter

![slack_jtj6oOsA0i](https://user-images.githubusercontent.com/52238281/148913506-ebe09742-b74a-4ddd-b6e7-053cef375145.gif)

### Technical details

* Python 3.8.10
* Django version: Version: 3.1
* Oscar version: Version: 3.1



Discussion:

Resolving patch:
diff --git a/src/oscar/apps/dashboard/offers/views.py b/src/oscar/apps/dashboard/offers/views.py
--- a/src/oscar/apps/dashboard/offers/views.py
+++ b/src/oscar/apps/dashboard/offers/views.py
@@ -95,7 +95,11 @@ def get_queryset(self):
                 )
                 self.search_filters.append(_("Is active"))
             else:
-                qs = qs.filter(Q(end_datetime__lt=now) | Q(start_datetime__gt=now))
+                qs = qs.filter(
+                    Q(start_datetime__gt=now)
+                    | Q(end_datetime__lt=now)
+                    | Q(status=ConditionalOffer.SUSPENDED)
+                )
                 self.search_filters.append(_("Is inactive"))
         if offer_type:
             qs = qs.filter(offer_type=offer_type)


Test patch:
Repository: django-oscar/django-oscar

Issue:
There is no link from the dashboard to Attribute Option Group list page
I found the page `/dashboard/catalogue/attribute-option-group/` useful to manage option groups (insert / delete options from groups), but I see no link from the dashboard to this page, is it missing?



Discussion:
It is missing indeed, you can only create them in the django admin.
should I propose a PR to add the link to `/dashboard/catalogue/attribute-option-group/` in the "Catalogue" menu of the dashboard?
That would very generous!

Resolving patch:
diff --git a/src/oscar/defaults.py b/src/oscar/defaults.py
--- a/src/oscar/defaults.py
+++ b/src/oscar/defaults.py
@@ -133,6 +133,10 @@
                 "label": _("Options"),
                 "url_name": "dashboard:catalogue-option-list",
             },
+            {
+                "label": _("Attribute Option Groups"),
+                "url_name": "dashboard:catalogue-attribute-option-group-list",
+            },
         ],
     },
     {


Test patch:
Repository: CTPUG/wafer

Issue:
Add management command for generating a list of speakers without tickets.
See #40 for where the ticket tracking functionality was added.



Discussion:

Resolving patch:
diff --git a/wafer/management/commands/pycon_speaker_tickets.py b/wafer/management/commands/pycon_speaker_tickets.py
new file mode 100644
--- /dev/null
+++ b/wafer/management/commands/pycon_speaker_tickets.py
@@ -0,0 +1,46 @@
+import sys
+import csv
+from optparse import make_option
+
+from django.core.management.base import BaseCommand
+
+from django.contrib.auth.models import User
+from wafer.talks.models import ACCEPTED
+
+
+class Command(BaseCommand):
+    help = ("List speakers and associated tickets. By default, only lists"
+            " speakers for accepted talk, but this can be overriden by"
+            " the --all option")
+
+    option_list = BaseCommand.option_list + tuple([
+        make_option('--all', action="store_true", default=False,
+                    help='List speakers and tickets (for all talks)'),
+    ])
+
+    def _speaker_tickets(self, options):
+        people = User.objects.filter(talks__isnull=False).distinct()
+
+        csv_file = csv.writer(sys.stdout)
+        for person in people:
+            # We query talks to filter out the speakers from ordinary
+            # accounts
+            if options['all']:
+                titles = [x.title for x in person.talks.all()]
+            else:
+                titles = [x.title for x in
+                          person.talks.filter(status=ACCEPTED)]
+            if not titles:
+                continue
+            tickets = person.ticket.all()
+            if tickets:
+                ticket = u'%d' % tickets[0].barcode
+            else:
+                ticket = u'NO TICKET PURCHASED'
+            row = [x.encode("utf-8") for x in (person.get_full_name(),
+                   person.email,
+                   ticket)]
+            csv_file.writerow(row)
+
+    def handle(self, *args, **options):
+        self._speaker_tickets(options)


Test patch:
Repository: CTPUG/wafer

Issue:
Wafer page editing fails on Django 1.8 with ImproperlyConfigured: error
As seen on Travis, and confirmed locally, attempting to edit a page bombs out, ending with

"Specifying both 'fields' and 'form_class' is not permitted."
ImproperlyConfigured: Specifying both 'fields' and 'form_class' is not permitted.



Discussion:

Resolving patch:
diff --git a/wafer/pages/views.py b/wafer/pages/views.py
--- a/wafer/pages/views.py
+++ b/wafer/pages/views.py
@@ -15,7 +15,6 @@ class EditPage(UpdateView):
     template_name = 'wafer.pages/page_form.html'
     model = Page
     form_class = PageForm
-    fields = ['name', 'content']
 
 
 def slug(request, url):


Test patch:
Repository: CTPUG/wafer

Issue:
Remove'unicode' calls from wafer
Current wafer using python 3 fails on several admin tasks because `UserProfile.__str__` tries to call `unicode`, which is obviously not defined.

We should handle the difference between python 2 and python 3 correctly in this situation.

There are a couple of other calls to unicode() that look dangerous in the error paths in /registration/views.py that should probably be fixed as well.



Discussion:

Resolving patch:
diff --git a/wafer/registration/views.py b/wafer/registration/views.py
--- a/wafer/registration/views.py
+++ b/wafer/registration/views.py
@@ -40,7 +40,7 @@ def github_login(request):
 
         user = github_sso(request.GET['code'])
     except SSOError as e:
-        messages.error(request, unicode(e))
+        messages.error(request, u'%s' % e)
         return HttpResponseRedirect(reverse('auth_login'))
 
     login(request, user)
@@ -54,7 +54,7 @@ def debian_login(request):
     try:
         user = debian_sso(request.META)
     except SSOError as e:
-        messages.error(request, unicode(e))
+        messages.error(request, u'%s' % e)
         return HttpResponseRedirect(reverse('auth_login'))
 
     login(request, user)
diff --git a/wafer/users/models.py b/wafer/users/models.py
--- a/wafer/users/models.py
+++ b/wafer/users/models.py
@@ -26,7 +26,7 @@ class UserProfile(models.Model):
     github_username = models.CharField(max_length=32, null=True, blank=True)
 
     def __str__(self):
-        return unicode(self.user)
+        return u'%s' % self.user
 
     def accepted_talks(self):
         return self.user.talks.filter(status=ACCEPTED)


Test patch:
diff --git a/wafer/users/tests/test_models.py b/wafer/users/tests/test_models.py
new file mode 100644
--- /dev/null
+++ b/wafer/users/tests/test_models.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4
+"""Tests for wafer.user.models"""
+
+from django.contrib.auth import get_user_model
+from django.test import TestCase
+
+import sys
+PY2 = sys.version_info[0] == 2
+
+
+class UserModelTestCase(TestCase):
+
+    def test_str_method_issue192(self):
+        """Test that str(user) works correctly"""
+        create = get_user_model().objects.create_user
+        user = create('test', 'test@example.com', 'test_pass')
+        self.assertEqual(str(user.userprofile), 'test')
+        user = create(u'tést', 'test@example.com', 'test_pass')
+        if PY2:
+            self.assertEqual(unicode(user.userprofile), u'tést')
+        else:
+            self.assertEqual(str(user.userprofile), u'tést')
Repository: CTPUG/wafer

Issue:
Fix Python 3 regressions
There are a couple places we use `.iteritems()` on dictionaries in the code:

https://github.com/CTPUG/wafer/blob/a120735a20ff67c6f863c6ca89cc6dfd9b0fc16e/wafer/schedule/templates/admin/scheduleitem_list.html#L14

https://github.com/CTPUG/wafer/blob/a120735a20ff67c6f863c6ca89cc6dfd9b0fc16e/wafer/schedule/templates/admin/scheduleitem_list.html#L50

https://github.com/CTPUG/wafer/blob/a120735a20ff67c6f863c6ca89cc6dfd9b0fc16e/wafer/registration/sso.py#L69

https://github.com/CTPUG/wafer/blob/2dbf7020ef0c7f7d7541b68b1423fcbe5cb8ad8f/wafer/users/views.py#L173

Since `six` is bundled with Django, we can probably use that instead of using `.items()` across the board because of the performance issues on Python 2.

I'm not sure what the simplest solution for the `iteritems` uses in the templates though.



Discussion:
The non-template cases here are both only called during user registration. I don't think either is likely to be enough of a bottleneck that the difference between using dict.items and dict.iteritems will actually matter.

The use in the schedule admin template is iterating over the error results - those should hopefully be small or empty in most cases, so the distinction between items and iteritems shouldn't be significant there either.


Resolving patch:
diff --git a/wafer/registration/sso.py b/wafer/registration/sso.py
--- a/wafer/registration/sso.py
+++ b/wafer/registration/sso.py
@@ -66,7 +66,7 @@ def _configure_user(user, name, email, profile_fields):
 
     profile = user.userprofile
     if profile_fields:
-        for k, v in profile_fields.iteritems():
+        for k, v in profile_fields.items():
             setattr(profile, k, v)
     profile.save()
 
diff --git a/wafer/users/views.py b/wafer/users/views.py
--- a/wafer/users/views.py
+++ b/wafer/users/views.py
@@ -170,7 +170,7 @@ def form_valid(self, form):
         user = self.get_user()
         group = self.get_kv_group()
 
-        for key, value in form.cleaned_data.iteritems():
+        for key, value in form.cleaned_data.items():
             try:
                 pair = saved.get(key=key)
                 pair.value = value


Test patch: