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

Issue:
'PhoneNumber' object has no attribute 'find'
### What I'm trying to achieve
Update Shipping Address in Order page

### Steps to reproduce the problem
1. Dashboard->Order->Shipping Address->Edit
2. Update phone number

### What I expected to happen
Update successfully

### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
![Screenshot from 2019-05-04 18-33-34](https://user-images.githubusercontent.com/6357274/57178528-cd02a680-6e9b-11e9-8852-68081ab23a8d.png)

**System information**
Operating system: 
Browser:



Discussion:

Resolving patch:
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -5,8 +5,7 @@
 from django.utils.translation import npgettext_lazy, pgettext_lazy
 
 from ...account.i18n import (
-    AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField,
-    clean_phone_for_country)
+    AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)
 from ...account.models import User
 from ...checkout.forms import QuantityField
 from ...core.exceptions import InsufficientStock
@@ -591,13 +590,6 @@ class AddressForm(StorefrontAddressForm):
 
     def clean(self):
         data = super().clean()
-        phone = data.get('phone')
-        country = data.get('country')
-        if phone:
-            try:
-                data['phone'] = clean_phone_for_country(phone, country)
-            except forms.ValidationError as error:
-                self.add_error('phone', error)
         return data
 
 


Test patch:
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -3,6 +3,7 @@
 
 import pytest
 from django.urls import reverse
+from phonenumber_field.phonenumber import PhoneNumber
 from prices import Money
 
 from saleor.checkout import AddressType
@@ -750,6 +751,33 @@ def test_view_order_shipping_edit_not_draft_order(
     assert response.status_code == 404
 
 
+def test_view_order_address_edit(
+        admin_client, order_with_lines, address_other_country):
+
+    order = order_with_lines
+    new_address = address_other_country
+
+    new_address.phone = PhoneNumber.from_string(
+        region=new_address.country.code, phone_number='+33.600000000')
+
+    address_data = new_address.as_data()
+    address_data.pop('phone')
+
+    address_data.update({
+        'phone_0': '+33',
+        'phone_1': '600000000'})
+
+    url = reverse(
+        'dashboard:address-edit',
+        kwargs={'order_pk': order.pk, 'address_type': 'shipping'})
+
+    response = admin_client.post(url, address_data)
+    assert response.status_code == 302
+
+    order.refresh_from_db(fields=['shipping_address'])
+    assert new_address.as_data() == order.shipping_address.as_data()
+
+
 def test_view_order_shipping_remove(admin_client, draft_order):
     url = reverse(
         'dashboard:order-shipping-remove', kwargs={'order_pk': draft_order.pk})
Repository: saleor/saleor

Issue:
The voucher form doesn't show selected products
### Steps to reproduce the problem
1. Open Voucher form.
2. Set Discount type to specific product.
3. Choose the products you want.
4. Create the voucher.
5. Open the created voucher from the list of vouchers.

What happens is the products field goes blank.

### What I expected to happen
The chosen products must show up when viewing the created voucher.

**System information**
Operating system:  Ubuntu 16.04
Browser:  Chrome.



Discussion:
Hi thanks for reporting!

After reproducing I see what you mean. When a voucher has selected products, the form doesn't show them. We can only see the products when we add them but not after saving or after a form error.

But, the products are saved, as we can see in the voucher list, it shows the correct number of products for the given voucher.

So the issue is most likely that the products are not being sent to the form for rendering.

Resolving patch:
diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py
--- a/saleor/dashboard/discount/forms.py
+++ b/saleor/dashboard/discount/forms.py
@@ -173,6 +173,11 @@ class Meta:
         model = Voucher
         fields = ['products', 'apply_once_per_order']
 
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        if self.instance.pk:
+            self.fields['products'].set_initial(self.instance.products.all())
+
 
 class CollectionVoucherForm(CommonVoucherForm):
 


Test patch:
Repository: saleor/saleor

Issue:
The payments migrations are out of date
The payments transaction kind dropped the charge kind in #4098, we should migrate them to `CAPTURE`.


Discussion:

Resolving patch:
diff --git a/saleor/payment/migrations/0011_auto_20190516_0901.py b/saleor/payment/migrations/0011_auto_20190516_0901.py
new file mode 100644
--- /dev/null
+++ b/saleor/payment/migrations/0011_auto_20190516_0901.py
@@ -0,0 +1,24 @@
+# Generated by Django 2.2.1 on 2019-05-16 14:01
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [("payment", "0010_auto_20190220_2001")]
+
+    operations = [
+        migrations.AlterField(
+            model_name="transaction",
+            name="kind",
+            field=models.CharField(
+                choices=[
+                    ("auth", "Authorization"),
+                    ("refund", "Refund"),
+                    ("capture", "Capture"),
+                    ("void", "Void"),
+                ],
+                max_length=10,
+            ),
+        )
+    ]


Test patch:
Repository: saleor/saleor

Issue:
Typo in Payment Gateway 'razorpay'
### What I'm trying to achieve
…
Typo in Payment razorpay. https://github.com/mirumee/saleor/blob/0cf515b36501f341fda8f3310c6f0f570e6a5350/saleor/payment/gateways/razorpay/forms.py#L13

https://github.com/mirumee/saleor/blob/0cf515b36501f341fda8f3310c6f0f570e6a5350/saleor/payment/gateways/razorpay/forms.py#L16
### Steps to reproduce the problem
1. N/A

### What I expected it to be
…
Razorpay instead of Rozorpay
### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->

**System information**
Operating system: N/A
Browser: N/A

Typo in Payment Gateway 'razorpay'
### What I'm trying to achieve
…
Typo in Payment razorpay. https://github.com/mirumee/saleor/blob/0cf515b36501f341fda8f3310c6f0f570e6a5350/saleor/payment/gateways/razorpay/forms.py#L13

https://github.com/mirumee/saleor/blob/0cf515b36501f341fda8f3310c6f0f570e6a5350/saleor/payment/gateways/razorpay/forms.py#L16
### Steps to reproduce the problem
1. N/A

### What I expected it to be
…
Razorpay instead of Rozorpay
### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->

**System information**
Operating system: N/A
Browser: N/A



Discussion:
Hi!

Thanks for finding the typo. Maybe you could open a PR for it?
Hi!

Thanks for finding the typo. Maybe you could open a PR for it?

Resolving patch:
diff --git a/saleor/payment/gateways/razorpay/forms.py b/saleor/payment/gateways/razorpay/forms.py
--- a/saleor/payment/gateways/razorpay/forms.py
+++ b/saleor/payment/gateways/razorpay/forms.py
@@ -10,10 +10,10 @@
 CHECKOUT_SCRIPT_URL = "https://checkout.razorpay.com/v1/checkout.js"
 
 PRIMARY_BTN_TEXT = pgettext_lazy(
-    "Rozorpay payment gateway primary button", "Pay now with Razorpay"
+    "Razorpay payment gateway primary button", "Pay now with Razorpay"
 )
 SECONDARY_TITLE = pgettext_lazy(
-    "Rozorpay payment gateway secondary title", "Total payment"
+    "Razorpay payment gateway secondary title", "Total payment"
 )
 
 


Test patch:
Repository: saleor/saleor

Issue:
Drop django_celery_results pkg
Saleor does not use celery task results, but uses `django_celery_results`. 

DoD:
- drop `django_celery_results` from requirements
- remove `CELERY_RESULT_BACKEND` setting
- ~~globally drop storing task results. I don't think we need to add manually `ignore_result=True` to every task (correct me if thats not good idea)~~ - changing global celery settings can interfere with existing systems 


Discussion:
Not sure if it's a good idea to globally disable storing results. Imagine trying to add an external app that depends on the default being true.

Resolving patch:
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -258,7 +258,6 @@ def get_bool_from_env(name, default_value):
     "social_django",
     "django_countries",
     "django_filters",
-    "django_celery_results",
     "impersonate",
     "phonenumber_field",
     "captcha",
@@ -530,7 +529,7 @@ def get_host():
 CELERY_ACCEPT_CONTENT = ["json"]
 CELERY_TASK_SERIALIZER = "json"
 CELERY_RESULT_SERIALIZER = "json"
-CELERY_RESULT_BACKEND = "django-db"
+CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", None)
 
 # Impersonate module settings
 IMPERSONATE = {


Test patch:
Repository: saleor/saleor

Issue:
Drop the static files panel from Django Debug Toolbar
This panel is mostly useless and having it enabled in DEBUG mode slows everything down to a crawl.


Discussion:

Resolving patch:
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -272,18 +272,10 @@ def get_bool_from_env(name, default_value):
     DEBUG_TOOLBAR_PANELS = [
         # adds a request history to the debug toolbar
         "ddt_request_history.panels.request_history.RequestHistoryPanel",
-        "debug_toolbar.panels.versions.VersionsPanel",
         "debug_toolbar.panels.timer.TimerPanel",
-        "debug_toolbar.panels.settings.SettingsPanel",
         "debug_toolbar.panels.headers.HeadersPanel",
         "debug_toolbar.panels.request.RequestPanel",
         "debug_toolbar.panels.sql.SQLPanel",
-        "debug_toolbar.panels.templates.TemplatesPanel",
-        "debug_toolbar.panels.staticfiles.StaticFilesPanel",
-        "debug_toolbar.panels.cache.CachePanel",
-        "debug_toolbar.panels.signals.SignalsPanel",
-        "debug_toolbar.panels.logging.LoggingPanel",
-        "debug_toolbar.panels.redirects.RedirectsPanel",
         "debug_toolbar.panels.profiling.ProfilingPanel",
     ]
     DEBUG_TOOLBAR_CONFIG = {"RESULTS_CACHE_SIZE": 100}


Test patch:
Repository: saleor/saleor

Issue:
Add query to filter attributes by IDs
Add a query to filter attributes by IDs. We should try to extend the `AttributeFilterInput` with the following field `ids: [ID!]` so that we can send a query like `attributes(filter: {ids: []})`.

We need this query to render attributes column names in the refactored product list view in the dashboard.


Discussion:

Resolving patch:
diff --git a/saleor/graphql/product/filters.py b/saleor/graphql/product/filters.py
--- a/saleor/graphql/product/filters.py
+++ b/saleor/graphql/product/filters.py
@@ -223,6 +223,7 @@ class Meta:
 class AttributeFilter(django_filters.FilterSet):
     # Search by attribute name and slug
     search = django_filters.CharFilter(method=filter_attributes_search)
+    ids = GlobalIDMultipleChoiceFilter(field_name="id")
 
     class Meta:
         model = Attribute


Test patch:
diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.py
--- a/tests/api/test_attributes.py
+++ b/tests/api/test_attributes.py
@@ -1755,6 +1755,27 @@ def test_filter_attributes_if_available_in_grid(
     assert attributes[0]["node"]["slug"] == "size"
 
 
+def test_filter_attributes_by_global_id_list(api_client, attribute_list):
+    global_ids = [
+        graphene.Node.to_global_id("Attribute", attribute.pk)
+        for attribute in attribute_list[:2]
+    ]
+    variables = {"filters": {"ids": global_ids}}
+
+    expected_slugs = sorted([attribute_list[0].slug, attribute_list[1].slug])
+
+    attributes = get_graphql_content(
+        api_client.post_graphql(ATTRIBUTES_FILTER_QUERY, variables)
+    )["data"]["attributes"]["edges"]
+
+    assert len(attributes) == 2
+    received_slugs = sorted(
+        [attributes[0]["node"]["slug"], attributes[1]["node"]["slug"]]
+    )
+
+    assert received_slugs == expected_slugs
+
+
 ATTRIBUTES_SORT_QUERY = """
     query($sortBy: AttributeSortingInput) {
       attributes(first: 10, sortBy: $sortBy) {
Repository: saleor/saleor

Issue:
Wrong AddressForm for Ireland
### What I'm trying to achieve
I tried to use address form validation for Ireland. Unfortunately, our API returns for that country that `country_area` is not required, but `AddressFormIE` requires it. 

### Steps to reproduce the problem
1. Send `CheckoutShippingAddressUpdate` without `country_area` - API returns validation error.

Another way to expect that problem is adding `IE` to the `test_address_form_for_country` test function - it fails.

### What I expected to happen
API and form validation should be consistent - if `i18naddress` says that field is not required, it is not required.

### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
n/a

**System information**
Operating system: n/a
Browser: n/a



Discussion:

Resolving patch:
diff --git a/saleor/account/i18n.py b/saleor/account/i18n.py
--- a/saleor/account/i18n.py
+++ b/saleor/account/i18n.py
@@ -236,8 +236,9 @@ def update_base_fields(form_class, i18n_rules):
         field.placeholder = placeholder_value
 
     if i18n_rules.country_area_choices:
+        required = "country_area" in i18n_rules.required_fields
         form_class.base_fields["country_area"] = CountryAreaChoiceField(
-            choices=i18n_rules.country_area_choices
+            choices=i18n_rules.country_area_choices, required=required
         )
 
     labels_map = {


Test patch:
diff --git a/tests/test_account.py b/tests/test_account.py
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -27,7 +27,7 @@
 from saleor.account.validators import validate_possible_number
 
 
-@pytest.mark.parametrize("country", ["CN", "PL", "US"])
+@pytest.mark.parametrize("country", ["CN", "PL", "US", "IE"])
 def test_address_form_for_country(country):
     data = {
         "first_name": "John",
Repository: saleor/saleor

Issue:
Order status remains as UNFULFILLED for dummy payment method
### What I'm trying to achieve
When I place an order as customer, and try to fulfill that order as admin, the status of order remains UNFULFILLED.

I am doing a default docker installation on MacOS

### Steps to reproduce the problem
1. Install Saleor via docker development (with default configurations)
2. Login as customer and add items to cart
3. Select payment option as Dummy Payment
4. Place the order using Not Charged/Fully Charged as payment option
5. Now Login as admin
6. Click on Fullfill order and click submit (All the items are selected)
7. The order status in customer's My Orders does not change to Fulfilled

### What I expected to happen
I excpected the Order Status to be changed to Fulfilled, but it stays as UnFulfilled

### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
Admin Screen (I have fulfilled the order)
<img width="678" alt="Screenshot 2019-10-03 at 1 22 46 AM" src="https://user-images.githubusercontent.com/24311194/66076936-7b5e6500-e57c-11e9-9414-87b62d28c52e.png">

Customer Screen (After fulfilling the order)
<img width="1044" alt="Screenshot 2019-10-03 at 1 24 26 AM" src="https://user-images.githubusercontent.com/24311194/66077006-a6e14f80-e57c-11e9-8336-73ae5fcd78ea.png">


**System information**
Operating system: MacOS
Browser: Safari (Admin User)/Chrome (Customer)
Saleor Env: Docker



Discussion:

Resolving patch:
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -637,6 +637,7 @@ def fulfill_order_lines(request, order_pk):
                 number="quantity_fulfilled",
             ) % {"quantity_fulfilled": quantity_fulfilled}
 
+            fulfillment.refresh_from_db()
             order_fulfilled(
                 fulfillment,
                 request.user,


Test patch:
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -1129,6 +1129,7 @@ def test_view_fulfill_order_lines(
     for line in order_with_lines.lines.all():
         assert line.quantity_unfulfilled == 0
     assert mock_email_fulfillment.call_count == 1
+    assert order_with_lines.status == OrderStatus.FULFILLED
 
 
 def test_view_fulfill_order_lines_with_empty_quantity(admin_client, order_with_lines):
Repository: saleor/saleor

Issue:
Check whether the GraphQL query is a string before executing

### Steps to reproduce the problem
1. Craft an invalid request that submits a non-string object as a GraphQL query
2. An Internal Error should occur

```shell
curl 'https://demo.getsaleor.com/graphql/' \
    -H 'content-type: application/json' \
    --data '{"variables":{},"query":{"test": 123}}'
``` 

### What I expected to happen
400 - Bad Request


### What happened instead
```
  File "saleor/graphql/views.py", line 95, in dispatch
    response = self.handle_query(request, *args, **kwargs)
  File "saleor/graphql/views.py", line 120, in handle_query
    result, status_code = self.get_response(request, data)
  File "saleor/graphql/views.py", line 124, in get_response
    execution_result = self.execute_graphql_request(request, data)
  File "saleor/graphql/views.py", line 168, in execute_graphql_request
    document, error = self.parse_query(query)
  File "saleor/graphql/views.py", line 161, in parse_query
    return self.backend.document_from_string(self.schema, query), None
  File "graphql/backend/core.py", line 51, in document_from_string
    ), "The query must be a string"
```



Discussion:

Resolving patch:
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -113,11 +113,11 @@ def get_root_value(self):
     def parse_query(self, query: str) -> (GraphQLDocument, ExecutionResult):
         """Attempt to parse a query (mandatory) to a gql document object.
 
-        If no query was given, it returns an error.
+        If no query was given or query is not a string, it returns an error.
         If the query is invalid, it returns an error as well.
         Otherwise, it returns the parsed gql document.
         """
-        if not query:
+        if not query or not isinstance(query, str):
             return (
                 None,
                 ExecutionResult(


Test patch:
diff --git a/tests/api/test_view.py b/tests/api/test_view.py
--- a/tests/api/test_view.py
+++ b/tests/api/test_view.py
@@ -108,6 +108,14 @@ def test_no_query(client):
     assert content["errors"][0]["message"] == "Must provide a query string."
 
 
+def test_query_is_dict(client):
+    data = {"query": {"type": "dict"}}
+    response = client.post(API_PATH, data, content_type="application/json")
+    assert response.status_code == 400
+    content = _get_graphql_content_from_response(response)
+    assert content["errors"][0]["message"] == "Must provide a query string."
+
+
 def test_graphql_execution_exception(monkeypatch, api_client):
     def mocked_execute(*args, **kwargs):
         raise IOError("Spanish inquisition")
Repository: saleor/saleor

Issue:
Unify templates naming
template `templates/dashboard/staff/detail.html` should be called `form.html` not `detail.html`


Discussion:
Some others:
```
templates/dashboard/order/fulfillment.html -> fulfillment_form.html
templates/dashboard/staff/detail.html -> form.html
templates/dashboard/collection/detail.html -> form.html
```


Resolving patch:
diff --git a/saleor/dashboard/collection/views.py b/saleor/dashboard/collection/views.py
--- a/saleor/dashboard/collection/views.py
+++ b/saleor/dashboard/collection/views.py
@@ -55,7 +55,7 @@ def collection_create(request):
         messages.success(request, msg)
         return redirect("dashboard:collection-list")
     ctx = {"collection": collection, "form": form}
-    return TemplateResponse(request, "dashboard/collection/detail.html", ctx)
+    return TemplateResponse(request, "dashboard/collection/form.html", ctx)
 
 
 @staff_member_required
@@ -79,7 +79,7 @@ def collection_update(request, pk=None):
         "form": form,
         "is_unpublish_restricted": is_unpublish_restricted,
     }
-    return TemplateResponse(request, "dashboard/collection/detail.html", ctx)
+    return TemplateResponse(request, "dashboard/collection/form.html", ctx)
 
 
 @staff_member_required
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -658,7 +658,7 @@ def fulfill_order_lines(request, order_pk):
         "order": order,
         "unfulfilled_lines": unfulfilled_lines,
     }
-    template = "dashboard/order/fulfillment.html"
+    template = "dashboard/order/fulfillment_form.html"
     return TemplateResponse(request, template, ctx, status=status)
 
 
diff --git a/saleor/dashboard/staff/views.py b/saleor/dashboard/staff/views.py
--- a/saleor/dashboard/staff/views.py
+++ b/saleor/dashboard/staff/views.py
@@ -48,7 +48,7 @@ def staff_details(request, pk):
         messages.success(request, msg)
         return redirect("dashboard:staff-list")
     ctx = {"staff_member": staff_member, "form": form}
-    return TemplateResponse(request, "dashboard/staff/detail.html", ctx)
+    return TemplateResponse(request, "dashboard/staff/form.html", ctx)
 
 
 @staff_member_required
@@ -76,7 +76,7 @@ def staff_create(request):
             send_promote_customer_to_staff_email.delay(staff.pk)
         return redirect("dashboard:staff-list")
     ctx = {"form": form}
-    return TemplateResponse(request, "dashboard/staff/detail.html", ctx)
+    return TemplateResponse(request, "dashboard/staff/form.html", ctx)
 
 
 @staff_member_required


Test patch:
Repository: saleor/saleor

Issue:
Add description and deprecation support to filters
`FilterInputObjectType` doesn't provide a way to document fields. We could add two fields to the meta-class: `descriptions = {field: description}` and `deprecations = {field: reason}`.


Discussion:
Hi @NyanKiyoshi @maarcingebala I'd happy to work on this issue. Let me know if you have any pressing questions or information you'd like to share with me!

Resolving patch:
diff --git a/saleor/graphql/core/types/filter_input.py b/saleor/graphql/core/types/filter_input.py
--- a/saleor/graphql/core/types/filter_input.py
+++ b/saleor/graphql/core/types/filter_input.py
@@ -58,7 +58,7 @@ def get_filtering_args_from_filterset(cls):
                 field_type = convert_form_field(filter_field)
             else:
                 field_type = convert_form_field(filter_field.field)
-                field_type.description = filter_field.label
+                field_type.description = getattr(filter_field, "help_text", "")
             kwargs = getattr(field_type, "kwargs", {})
             field_type.kwargs = kwargs
             args[name] = field_type


Test patch: