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

Issue:
Vouchers that have expired since adding cause error without explanation on order creation
While the basket ignores vouchers that are expired since the order was created, the OrderPlacementMixin raises an error with an empty explanation.



Discussion:

Resolving patch:
diff --git a/src/oscar/apps/order/utils.py b/src/oscar/apps/order/utils.py
--- a/src/oscar/apps/order/utils.py
+++ b/src/oscar/apps/order/utils.py
@@ -66,9 +66,12 @@ def place_order(self, basket, total,  # noqa (too complex (12))
                 self.update_stock_records(line)
 
             for voucher in basket.vouchers.select_for_update():
-                available_to_user, msg = voucher.is_available_to_user(user=user)
-                if not voucher.is_active() or not available_to_user:
-                    raise ValueError(msg)
+                if not voucher.is_active():  # basket ignores inactive vouchers
+                    basket.vouchers.remove(voucher)
+                else:
+                    available_to_user, msg = voucher.is_available_to_user(user=user)
+                    if not available_to_user:
+                        raise ValueError(msg)
 
             # Record any discounts associated with this order
             for application in basket.offer_applications:


Test patch:
diff --git a/tests/integration/order/test_creator.py b/tests/integration/order/test_creator.py
--- a/tests/integration/order/test_creator.py
+++ b/tests/integration/order/test_creator.py
@@ -1,3 +1,4 @@
+import datetime
 import threading
 import time
 from decimal import Decimal as D
@@ -7,6 +8,7 @@
 from django.http import HttpRequest
 from django.test import TestCase, TransactionTestCase
 from django.test.utils import override_settings
+from django.utils import timezone
 
 from oscar.apps.catalogue.models import Product, ProductClass
 from oscar.apps.checkout import calculators
@@ -266,6 +268,19 @@ def test_single_usage(self):
         with pytest.raises(ValueError):
             place_order(creator, basket=basket, order_number='12347', user=user)
 
+    def test_expired_voucher(self):
+        user = AnonymousUser()
+        basket = factories.create_basket()
+        creator = OrderCreator()
+
+        voucher = factories.VoucherFactory(usage=Voucher.SINGLE_USE)
+        voucher.offers.add(factories.create_offer(offer_type='Voucher'))
+        basket.vouchers.add(voucher)
+        voucher.end_datetime = timezone.now() - datetime.timedelta(days=100)
+        voucher.save()
+        place_order(creator, basket=basket, order_number='12346', user=user)
+        assert voucher.applications.count() == 0
+
 
 class TestConcurrentOrderPlacement(TransactionTestCase):
Repository: django-oscar/django-oscar

Issue:
Add date_updated field to basketline
Logic behind this proposal:

It is very fairly common for customers to change and fiddle with basketlines(i.e change quantities), so I think adding `date_updated` field to AbstractBaskeLine would be good.

I know forking the basket app and overriding basketline is trivial, but the Line model having `date_updated` field as default would be more flexible. I think most people would like to use Oscar as it is and make changes only when it is absolutely necessary for forward-compatibility reasons.

The docstring even advises users to do this, if someone wants to order the basket lines like Amazon(=`Last modified on top`), which I presume would be the case for quite a number of people including myself.

Thanks.


Discussion:
I don't have any objections, how about you @solarissmoke @craigloftus ?
No objection here either. PR is welcome.

Resolving patch:
diff --git a/src/oscar/apps/basket/abstract_models.py b/src/oscar/apps/basket/abstract_models.py
--- a/src/oscar/apps/basket/abstract_models.py
+++ b/src/oscar/apps/basket/abstract_models.py
@@ -599,11 +599,10 @@ class AbstractLine(models.Model):
            another one, and new items are added to the top as well.  Amazon
            mostly does this, but doesn't change the position when you update
            the quantity in the basket view.
-           To get this behaviour, add a date_updated field, change
-           Meta.ordering and optionally do something similar on wishlist lines.
-           Order lines should already be created in the order of the basket
-           lines, and are sorted by their primary key, so no changes should be
-           necessary there.
+           To get this behaviour, change Meta.ordering and optionally do
+           something similar on wishlist lines. Order lines should already
+           be created in the order of the basket lines, and are sorted by
+           their primary key, so no changes should be necessary there.
 
     """
     basket = models.ForeignKey(
@@ -646,6 +645,7 @@ class AbstractLine(models.Model):
 
     # Track date of first addition
     date_created = models.DateTimeField(_("Date Created"), auto_now_add=True, db_index=True)
+    date_updated = models.DateTimeField(_("Date Updated"), auto_now=True, db_index=True)
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
diff --git a/src/oscar/apps/basket/migrations/0009_line_date_updated.py b/src/oscar/apps/basket/migrations/0009_line_date_updated.py
new file mode 100644
--- /dev/null
+++ b/src/oscar/apps/basket/migrations/0009_line_date_updated.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.3 on 2020-03-03 09:36
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('basket', '0008_auto_20181115_1953'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='line',
+            name='date_updated',
+            field=models.DateTimeField(auto_now=True, db_index=True, verbose_name='Date Updated'),
+        ),
+    ]


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

Issue:
Setting `required` on a ProductAttribute with type boolean is non-sensical
### Issue Summary
When a `ProductAttribute` with type `boolean` is set to `required=True`, it requires any underlying`ProductAttributeValue` to be set to `True`, otherwise the Product you're trying to create/change won't save in the dashboard. I don't think the `required` field makes sense for a boolean field in this case. A Boolean field could still be `False` but be required to be filled in as `False`. It's all a bit confusing. 

It makes sense purely on a form, where you might need to check a checkbox to submit the form. But in this case it's a field in a database that's required. 

### Steps to Reproduce
1. Go to dashboard
1. On any `ProductType` defined, add an Attribute with type `True / False` and set the `Required` field to `True`.
1. Create a new product with this `ProductType` and set the attribute on the product to `False`

The dashboard interface says it's required to be set to `True` and as such the option for `False` is not possible.

### Proposed solution
Don't allow `ProductAttribute`'s with type `boolean` to be set to `required=True`.

### Technical details
I've tested this on an older Python version. But couldn't find any reference of a fix for this in the latest version.

* Python version: `2.7.17`
* Django version: `1.11.23`
* Oscar version: `1.6.7 `



Discussion:
Thanks for this - your proposed fix makes sense, PR welcome if you have time.

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
@@ -851,6 +851,10 @@ def is_file(self):
     def __str__(self):
         return self.name
 
+    def clean(self):
+        if self.type == self.BOOLEAN and self.required:
+            raise ValidationError(_("Boolean attribute should not be required."))
+
     def _save_file(self, value_obj, value):
         # File fields in Django are treated differently, see
         # django.db.models.fields.FileField and method save_form_data


Test patch:
diff --git a/tests/integration/catalogue/test_models.py b/tests/integration/catalogue/test_models.py
--- a/tests/integration/catalogue/test_models.py
+++ b/tests/integration/catalogue/test_models.py
@@ -19,3 +19,9 @@ def test_product_attributes_cant_be_python_keywords():
     attr = models.ProductAttribute(name="A", code="import")
     with pytest.raises(ValidationError):
         attr.full_clean()
+
+
+def test_product_boolean_attribute_cant_be_required():
+    attr = models.ProductAttribute(name="A", code="a", type=models.ProductAttribute.BOOLEAN, required=True)
+    with pytest.raises(ValidationError):
+        attr.full_clean()
Repository: django-oscar/django-oscar

Issue:
product-lookup not working
### Issue Summary
Can't select related products

### Steps to Reproduce

1. run sandbox
2. in Dashboard->products select any product eg. The shellcoder's handbook
3. in product's upselling click text field `Recommended product:`
4. dropdown contains `The results could not be loaded.` and console throws ` Internal Server Error: /en-gb/dashboard/catalogue/product-lookup/`
with traceback ending
```
django-oscar/src/oscar/apps/dashboard/catalogue/views.py", line 649, in get_queryset
    return self.model.browsable.all()
AttributeError: type object 'Product' has no attribute 'browsable'
```

### Technical details

* Python version: 3.7.5
* Django version: 2.2.11
* Oscar version: commit  5de733e



Discussion:

Resolving patch:
diff --git a/src/oscar/apps/dashboard/catalogue/views.py b/src/oscar/apps/dashboard/catalogue/views.py
--- a/src/oscar/apps/dashboard/catalogue/views.py
+++ b/src/oscar/apps/dashboard/catalogue/views.py
@@ -646,7 +646,7 @@ class ProductLookupView(ObjectLookupView):
     model = Product
 
     def get_queryset(self):
-        return self.model.browsable.all()
+        return self.model.objects.browsable().all()
 
     def lookup_filter(self, qs, term):
         return qs.filter(Q(title__icontains=term)


Test patch:
diff --git a/tests/functional/dashboard/test_catalogue.py b/tests/functional/dashboard/test_catalogue.py
--- a/tests/functional/dashboard/test_catalogue.py
+++ b/tests/functional/dashboard/test_catalogue.py
@@ -30,7 +30,8 @@ class TestCatalogueViews(WebTestCase):
     def test_exist(self):
         urls = [reverse('dashboard:catalogue-product-list'),
                 reverse('dashboard:catalogue-category-list'),
-                reverse('dashboard:stock-alert-list')]
+                reverse('dashboard:stock-alert-list'),
+                reverse('dashboard:catalogue-product-lookup')]
         for url in urls:
             self.assertIsOk(self.get(url))
Repository: django-oscar/django-oscar

Issue:
Support for Django 3.0
Hi,

Just a low life dev wondering if you have an expected time frame for Django 3.0 support to be released ? 
I saw #3303 got merged into master a couple month ago. 

Anything I can do to help the delivery process ? 
Should I copy master if I want to use Django 3.0 for the time being ? 

Thanks for all the wonderful work you guys do on this project ! :) 

Update Readme first page of quickstart
This is what works on windows 10


Discussion:

Resolving patch:
diff --git a/src/oscar/__init__.py b/src/oscar/__init__.py
--- a/src/oscar/__init__.py
+++ b/src/oscar/__init__.py
@@ -1,5 +1,5 @@
 # Use 'alpha', 'beta', 'rc' or 'final' as the 4th element to indicate release type.
-VERSION = (2, 0, 1, 'final')
+VERSION = (2, 1, 0, 'beta')
 
 
 def get_short_version():


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

Issue:
is_public flag is not respected when listing child products
### Issue Summary

When rendering product variants (e.g., in the detail view for a parent product), Oscar does not check whether those variants are public. It uses `product.children.all`.

### Steps to Reproduce

1. Set `is_public=False` on a child product!
2. Notice that it is still listed in the parent product detail view.


Discussion:

Resolving patch:
diff --git a/src/oscar/apps/basket/forms.py b/src/oscar/apps/basket/forms.py
--- a/src/oscar/apps/basket/forms.py
+++ b/src/oscar/apps/basket/forms.py
@@ -148,7 +148,7 @@ def _create_parent_product_fields(self, product):
         """
         choices = []
         disabled_values = []
-        for child in product.children.all():
+        for child in product.children.public():
             # Build a description of the child, including any pertinent
             # attributes
             attr_summary = child.attribute_summary
diff --git a/src/oscar/apps/catalogue/managers.py b/src/oscar/apps/catalogue/managers.py
--- a/src/oscar/apps/catalogue/managers.py
+++ b/src/oscar/apps/catalogue/managers.py
@@ -107,6 +107,12 @@ def browsable(self):
         """
         return self.filter(parent=None, is_public=True)
 
+    def public(self):
+        """
+        Excludes non-public products
+        """
+        return self.filter(is_public=True)
+
     def browsable_dashboard(self):
         """
         Products that should be browsable in the dashboard.
diff --git a/src/oscar/apps/partner/strategy.py b/src/oscar/apps/partner/strategy.py
--- a/src/oscar/apps/partner/strategy.py
+++ b/src/oscar/apps/partner/strategy.py
@@ -150,7 +150,7 @@ def select_children_stockrecords(self, product):
         Select appropriate stock record for all children of a product
         """
         records = []
-        for child in product.children.all():
+        for child in product.children.public():
             # Use tuples of (child product, stockrecord)
             records.append((child, self.select_stockrecord(child)))
         return records


Test patch:
diff --git a/tests/unit/catalogue/test_managers.py b/tests/unit/catalogue/test_managers.py
new file mode 100644
--- /dev/null
+++ b/tests/unit/catalogue/test_managers.py
@@ -0,0 +1,11 @@
+import pytest
+
+from oscar.apps.catalogue.models import Product
+from oscar.test.factories import ProductFactory
+
+
+@pytest.mark.django_db
+def test_public_queryset_method_filters():
+    ProductFactory(is_public=True)
+    ProductFactory(is_public=False)
+    assert Product.objects.public().count() == 1
Repository: django-oscar/django-oscar

Issue:
Allow a category slug to be edited
Follow up to https://github.com/tangentlabs/django-oscar/pull/322

Category slugs are currently not editable, but generated from names.  We should allow them to be edited.  

We will probably need a new field to track which categories have customised names.

Category slug doesn't get updated
### Issue Summary

When changing the title of a category in the dashboard, the slug doesn't get regenerated.

### Technical details

* Python 3.6.10
* Django version: 2.2.15
* Oscar version: 2.1



Discussion:

I think it's the expected behaviour. If you update the slug it will have a new url and the previous one will raise 404. And it's bad thing for seo.
Maybe could be implemented this feature with django redirects. What do you think @solarissmoke? i could work for that as i implemented this feature in a couple of projects.
Oscar doesn't change the slug if it already exists to avoid altering URLs - this was because original the default URLs for category views used only slugs, and altering the slug would break old URLs. Now though, the URLs include the category ID and the view will redirect automatically if the slug portion is wrong, so it would be less problematic to change them. 

That said, I don't think slugs should be updated automatically, and would prefer instead to address #561 - i.e., allow manual editing of slugs. This shouldn't be particularly difficult - just requires exposing the slug field in the dashboard form. PR for this is welcome.

Resolving patch:
diff --git a/src/oscar/apps/dashboard/catalogue/forms.py b/src/oscar/apps/dashboard/catalogue/forms.py
--- a/src/oscar/apps/dashboard/catalogue/forms.py
+++ b/src/oscar/apps/dashboard/catalogue/forms.py
@@ -24,12 +24,22 @@
                                                   ('RelatedFieldWidgetWrapper',
                                                    'RelatedMultipleFieldWidgetWrapper'))
 
-CategoryForm = movenodeform_factory(
+
+BaseCategoryForm = movenodeform_factory(
     Category,
-    fields=['name', 'description', 'image', 'is_public'],
+    fields=['name', 'slug', 'description', 'image', 'is_public'],
     exclude=['ancestors_are_public'])
 
 
+class CategoryForm(BaseCategoryForm):
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        if 'slug' in self.fields:
+            self.fields['slug'].required = False
+            self.fields['slug'].help_text = _('Leave blank to generate from category name')
+
+
 class ProductClassSelectForm(forms.Form):
     """
     Form which is used before creating a product to select it's product class


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

Issue:
The postal Code validation for Israel should also take 5 digit numbers
In oscar.apps.address.abstract_models.AbstractAddress:

`'IL': r'^[0-9]{7}$',`

Should be:
`'IL': r'^([0-9]{5}|[0-9]{7})$',`

For more info: https://en.wikipedia.org/wiki/Postal_codes_in_Israel


Discussion:
Right, but seems 5-digit postal codes are not officially used any more, could you please mention working 5-digit postal code?
But they are used by our customers. So sure I can just overwrite it, which we have. 

To me the key sentence in the wiki article is: "they continue to be widely used". As we are dealing with people and not machines, then what is official is to me not as important as what is used by our customers :)
@ckaalund grateful if you can make a PR to address this.
Or if you could quote working 5-digit postal code - that also would be helpful.
Ok, found reference by myself of https://en.youbianku.com/Israel.

PR is coming as well.


Resolving patch:
diff --git a/src/oscar/apps/address/abstract_models.py b/src/oscar/apps/address/abstract_models.py
--- a/src/oscar/apps/address/abstract_models.py
+++ b/src/oscar/apps/address/abstract_models.py
@@ -103,7 +103,7 @@ class AbstractAddress(models.Model):
         'HT': r'^[0-9]{4}$',
         'HU': r'^[0-9]{4}$',
         'ID': r'^[0-9]{5}$',
-        'IL': r'^[0-9]{7}$',
+        'IL': r'^([0-9]{5}|[0-9]{7})$',
         'IM': r'^IM[0-9]{2,3}[A-Z]{2}$$',
         'IN': r'^[0-9]{6}$',
         'IO': r'^[A-Z]{4}[0-9][A-Z]{2}$',


Test patch:
diff --git a/tests/integration/address/test_models.py b/tests/integration/address/test_models.py
--- a/tests/integration/address/test_models.py
+++ b/tests/integration/address/test_models.py
@@ -225,6 +225,8 @@ def test_summary_is_property(self):
     ('BN', 'BC3615'),
     ('TW', '104'),
     ('TW', '10444'),
+    ('IL', '1029200'),
+    ('IL', '94142'),
     # It works for small cases as well
     ('GB', 'sw2 1rw'),
 ]
Repository: django-oscar/django-oscar

Issue:
Make inactive products and categories identifiable in dashboard list views
Currently, non-public products are not easy to identify in the dashboard list views - there is nothing to distinguish them from public products and you have to view the edit form to determine whether the item is public or not. 

I think it would be useful to have a column in the table to indicate whether the product is active. Same applies for categories.


Discussion:

Resolving patch:
diff --git a/src/oscar/apps/dashboard/catalogue/tables.py b/src/oscar/apps/dashboard/catalogue/tables.py
--- a/src/oscar/apps/dashboard/catalogue/tables.py
+++ b/src/oscar/apps/dashboard/catalogue/tables.py
@@ -44,9 +44,9 @@ class ProductTable(DashboardTable):
 
     class Meta(DashboardTable.Meta):
         model = Product
-        fields = ('upc', 'date_updated')
+        fields = ('upc', 'is_public', 'date_updated')
         sequence = ('title', 'upc', 'image', 'product_class', 'variants',
-                    'stock_records', '...', 'date_updated', 'actions')
+                    'stock_records', '...', 'is_public', 'date_updated', 'actions')
         order_by = '-date_updated'
 
 
@@ -71,7 +71,8 @@ class CategoryTable(DashboardTable):
 
     class Meta(DashboardTable.Meta):
         model = Category
-        fields = ('name', 'description')
+        fields = ('name', 'description', 'is_public')
+        sequence = ('name', 'description', '...', 'is_public', 'actions')
 
 
 class AttributeOptionGroupTable(DashboardTable):


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

Issue:
static_src and image_not_found.jpg
In oscar 3.0 (beta & master), when image_not_found.jpg is not found, I am getting

> ImproperlyConfigured("Please copy/symlink the 'missing image' image at /path/to/project/public/media/image_not_found.jpg into your MEDIA_ROOT at /path/to/project/public/media. This exception was raised because Oscar was unable to symlink it for you.")

The message is illogical.

Digging around I find my existing symlink is broken, pointing to `/path/to/oscar_repo/../static/oscar/img/image_not_found.jpg` when it should be pointing to `static_src`.

It would be nice if the `MissingProductImage` was able to detect a broken symlink and deletes it before trying to recreate it.


Discussion:
> The message is illogical.

Yeah, the first argument to that string is wrong - I'll fix that shortly.

> When it should be pointing to `static_src`.

No, the path it's trying to use is correct - all of `static_src` is copied into `oscar/static` when the build is packaged for PyPi (or if you run `make assets` on a local copy of Oscar, which you need to do to access any of it's static assets).

> It would be nice if the `MissingProductImage` was able to detect a broken symlink and deletes it before trying to recreate it.

I'm not sure that it is a good idea for Oscar to make potentially desctructive changes to the host filesystem - even if the symlink is broken we cannot assume that it used to point to Oscar's image instead of something else. I think we should still just report an exception in this case (and hopefully a corrected exception message will help).

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
@@ -1292,13 +1292,11 @@ def symlink_missing_image(self, media_file_path):
                     "Please copy/symlink the "
                     "'missing image' image at %s into your MEDIA_ROOT at %s. "
                     "This exception was raised because Oscar was unable to "
-                    "symlink it for you.") % (media_file_path,
-                                              settings.MEDIA_ROOT))
+                    "symlink it for you.") % (static_file_path, settings.MEDIA_ROOT))
             else:
                 logging.info((
                     "Symlinked the 'missing image' image at %s into your "
-                    "MEDIA_ROOT at %s") % (media_file_path,
-                                           settings.MEDIA_ROOT))
+                    "MEDIA_ROOT at %s") % (static_file_path, settings.MEDIA_ROOT))
 
 
 class AbstractProductImage(models.Model):


Test patch: