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

Issue:
Add language for SASS
Like coalib/bearlib/languages/definitions/CSS.py


Discussion:
@jayvdb Please assign this issue to me .I think @Prince-sharma is not active on this issue.
@jayvdb please assign this issue to me.
Unassigning due to inactivity.
Can I be assigned to this please

Resolving patch:
diff --git a/coalib/bearlib/languages/__init__.py b/coalib/bearlib/languages/__init__.py
--- a/coalib/bearlib/languages/__init__.py
+++ b/coalib/bearlib/languages/__init__.py
@@ -36,6 +36,7 @@
 from .definitions.PowerShell import PowerShell
 from .definitions.Python import Python
 from .definitions.Ruby import Ruby
+from .definitions.SASS import SASS
 from .definitions.Scala import Scala
 from .definitions.SCSS import SCSS
 from .definitions.Shell import Shell
diff --git a/coalib/bearlib/languages/definitions/SASS.py b/coalib/bearlib/languages/definitions/SASS.py
new file mode 100644
--- /dev/null
+++ b/coalib/bearlib/languages/definitions/SASS.py
@@ -0,0 +1,15 @@
+from coalib.bearlib.languages.Language import Language
+
+
+@Language
+class SASS:
+    extensions = '.sass',
+    comment_delimiters = '//',
+    multiline_comment_delimiters = {'/*': '*/'}
+    encapsulators = {'(': ')', '[': ']'}
+    interpolation = {'{': '}'}
+    keywords = [
+        'include', 'not', 'to', 'through', 'if', 'for', 'each',
+        'while', 'mixin', 'import', 'media', 'extend', 'at-root',
+        'debug', 'warn', 'error']
+    special_chars = list('{}()&/@*,;>')


Test patch:
diff --git a/tests/TestUtilities.py b/tests/TestUtilities.py
--- a/tests/TestUtilities.py
+++ b/tests/TestUtilities.py
@@ -63,6 +63,7 @@
     'Python 2.7, 3.3, 3.4, 3.5, 3.6',
     'Ruby',
     'Scala',
+    'SASS',
     'SCSS 3.1, 3.2, 3.3, 3.4, 3.5, 4.0',
     'Shell',
     'Swift',
Repository: saleor/saleor

Issue:
Make sure all address fields have the same i18n context



Discussion:

Resolving patch:
diff --git a/saleor/userprofile/models.py b/saleor/userprofile/models.py
--- a/saleor/userprofile/models.py
+++ b/saleor/userprofile/models.py
@@ -7,7 +7,7 @@
 from django.db import models
 from django.utils import timezone
 from django.utils.safestring import mark_safe
-from django.utils.translation import ugettext_lazy, pgettext_lazy
+from django.utils.translation import pgettext_lazy
 from unidecode import unidecode
 
 from ..core.countries import COUNTRY_CHOICES
@@ -18,11 +18,11 @@ class AddressBook(models.Model):
     user = models.ForeignKey('User', related_name='address_book')
     address = models.ForeignKey('Address', related_name='+', unique=True)
     alias = models.CharField(
-        ugettext_lazy('short alias'),
+        pgettext_lazy('Address book entry', 'short alias'),
         max_length=30,
-        default=pgettext_lazy('Default value for alias field', 'Home'),
+        default=pgettext_lazy('Address book entry', 'Home'),
         help_text=pgettext_lazy(
-            'help text',
+            'Address book entry',
             'User-defined alias which identifies this address'))
 
     class Meta:
@@ -56,14 +56,17 @@ class Address(models.Model):
         pgettext_lazy('Address field', 'company name'),
         max_length=256, blank=True)
     street_address_1 = models.CharField(
-        pgettext_lazy('Address field', 'street address 1'), max_length=256)
+        pgettext_lazy('Address field', 'street address 1'),
+        max_length=256)
     street_address_2 = models.CharField(
         pgettext_lazy('Address field', 'street address 2'),
         max_length=256, blank=True)
-    city = models.CharField(pgettext_lazy('Address field', 'city'),
-                            max_length=256)
+    city = models.CharField(
+        pgettext_lazy('Address field', 'city'),
+        max_length=256)
     postal_code = models.CharField(
-        pgettext_lazy('Address field', 'postal code'), max_length=20)
+        pgettext_lazy('Address field', 'postal code'),
+        max_length=20)
     country = models.CharField(
         pgettext_lazy('Address field', 'country'),
         choices=COUNTRY_CHOICES, max_length=2)
@@ -119,10 +122,14 @@ class User(models.Model):
     addresses = models.ManyToManyField(Address, through=AddressBook)
 
     is_staff = models.BooleanField(
-        pgettext_lazy('User field', 'staff status'), default=False)
-    is_active = models.BooleanField(pgettext_lazy('active'), default=False)
-    password = models.CharField(pgettext_lazy('User field', 'password'),
-                                max_length=128, editable=False)
+        pgettext_lazy('User field', 'staff status'),
+        default=False)
+    is_active = models.BooleanField(
+        pgettext_lazy('User field', 'active'),
+        default=False)
+    password = models.CharField(
+        pgettext_lazy('User field', 'password'),
+        max_length=128, editable=False)
     date_joined = models.DateTimeField(
         pgettext_lazy('User field', 'date joined'),
         default=timezone.now, editable=False)


Test patch:
Repository: saleor/saleor

Issue:
Save delivery name in DeliveryGroup



Discussion:

Resolving patch:
diff --git a/saleor/checkout/steps.py b/saleor/checkout/steps.py
--- a/saleor/checkout/steps.py
+++ b/saleor/checkout/steps.py
@@ -4,6 +4,7 @@
 from django.core.exceptions import ValidationError
 from django.db import models
 from django.shortcuts import redirect
+from django.utils.encoding import smart_text
 from satchless.process import InvalidData
 
 from .forms import DigitalDeliveryForm, DeliveryForm
@@ -190,7 +191,8 @@ def add_to_order(self, order):
         delivery_method = self.group['delivery_method']
         group = ShippedDeliveryGroup.objects.create(
             order=order, address=self.address,
-            price=delivery_method.get_price())
+            price=delivery_method.get_price(),
+            method=smart_text(delivery_method))
         group.add_items_from_partition(self.delivery_group)
 
     def is_default_address(self, entry, user):
@@ -236,7 +238,8 @@ def add_to_order(self, order):
         delivery_method = self.group['delivery_method']
         group = DigitalDeliveryGroup.objects.create(
             order=order, email=self.group['email'],
-            price=delivery_method.get_price())
+            price=delivery_method.get_price(),
+            method=smart_text(delivery_method))
         group.add_items_from_partition(self.delivery_group)
 
     def process(self, extra_context=None):
diff --git a/saleor/delivery/__init__.py b/saleor/delivery/__init__.py
--- a/saleor/delivery/__init__.py
+++ b/saleor/delivery/__init__.py
@@ -28,4 +28,5 @@ def get_price_per_item(self, **kwargs):
 
 class DigitalDelivery(BaseDelivery):
 
-    pass
+    def __unicode__(self):
+        return 'Digital delivery'
diff --git a/saleor/order/models.py b/saleor/order/models.py
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -122,6 +122,9 @@ class DeliveryGroup(Subtyped, ItemSet):
     status = models.CharField(
         pgettext_lazy('Delivery group field', 'Delivery status'),
         max_length=32, default='new', choices=STATUS_CHOICES)
+    method = models.CharField(
+        pgettext_lazy('Delivery group field', 'Delivery method'),
+        max_length=255)
     order = models.ForeignKey(Order, related_name='groups', editable=False)
     price = PriceField(
         pgettext_lazy('Delivery group field', 'unit price'),


Test patch:
Repository: saleor/saleor

Issue:
Improve payments templates
Use Bootstrap 3 classes.



Discussion:

Resolving patch:
diff --git a/saleor/core/templatetags/bootstrap.py b/saleor/core/templatetags/bootstrap.py
--- a/saleor/core/templatetags/bootstrap.py
+++ b/saleor/core/templatetags/bootstrap.py
@@ -30,6 +30,8 @@ def render_field(bound_field, show_label, template):
         input_type = 'textarea'
     elif isinstance(widget, forms.CheckboxInput):
         input_type = 'checkbox'
+    elif issubclass(type(widget), forms.MultiWidget):
+        input_type = 'multi_widget'
     else:
         input_type = 'input'
 
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -91,13 +91,6 @@
     'django.contrib.admin',
     'django.contrib.webdesign',
 
-    # External apps
-    'django_images',
-    'django_prices',
-    'mptt',
-    'payments',
-    'south',
-
     # Local apps
     'saleor.cart',
     'saleor.checkout',
@@ -106,7 +99,14 @@
     'saleor.payment',
     'saleor.product',
     'saleor.registration',
-    'saleor.userprofile'
+    'saleor.userprofile',
+
+    # External apps
+    'django_images',
+    'django_prices',
+    'mptt',
+    'payments',
+    'south'
 ]
 
 LOGGING = {


Test patch:
Repository: saleor/saleor

Issue:
Collections are returned even if empty
Django saves CharField as empty string instead of null. This causes get_products_from_collection method to return objects, which don't have collection specified, as it only checks for null



Discussion:

Resolving patch:
diff --git a/saleor/product/models/base_products.py b/saleor/product/models/base_products.py
--- a/saleor/product/models/base_products.py
+++ b/saleor/product/models/base_products.py
@@ -46,8 +46,7 @@ class Product(Subtyped, ItemRange):
     description = models.TextField(
         verbose_name=pgettext_lazy('Product field', 'description'))
 
-    collection = models.CharField(db_index=True, max_length=100,
-                                  null=True, blank=True)
+    collection = models.CharField(db_index=True, max_length=100, blank=True)
 
     class Meta:
         app_label = 'product'
@@ -66,8 +65,8 @@ def get_slug(self):
         return mark_safe(re.sub(r'[-\s]+', '-', value))
 
     def get_products_from_collection(self):
-        return Product.objects.filter(collection=self.collection,
-                                      collection__isnull=False)
+        return Product.objects.filter(
+            collection=self.collection) if self.collection else None
 
     def __iter__(self):
         return iter(self.variants.all())


Test patch:
Repository: saleor/saleor

Issue:
Use Babel for i18n
At least for price display. Need to investigate whether Babel has official Python 3 support.



Discussion:
Babel support for python 3 was introduced in v1.0 as you can read in http://babel.pocoo.org/docs/changelog/#version-1-0, yes it would be nice since I have to change every single template that display prices to localize them :S

Oh, that does not sound pleasant at all. Thanks for mentioning Python 3 support, we'll switch to `prices_i18n`.

oh this solves a lot of probs


Resolving patch:
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -62,6 +62,8 @@
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.locale.LocaleMiddleware',
+    'babeldjango.middleware.LocaleMiddleware',
     'saleor.cart.middleware.CartMiddleware',
     'saleor.core.middleware.GoogleAnalytics',
     'saleor.core.middleware.CheckHTML'
@@ -101,6 +103,7 @@
     'saleor.userprofile',
 
     # External apps
+    'babeldjango',
     'django_images',
     'django_prices',
     'mptt',
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,19 +32,21 @@ def run(self):
     packages=find_packages(),
     include_package_data=True,
     install_requires=[
+        'Babel>=1.3,<1.4a0',
+        'BabelDjango>=0.2,<0.3a0',
         'Django>=1.6',
         'django-images>=0.4,<0.5a0',
+        'google-measurement-protocol>=0.1.2,<0.2a0',
         'django-mptt>=0.5',
         'django-payments>=0.4,<0.5a0',
-        'django-prices>=0.3,<0.4a0',
-        'google-measurement-protocol>=0.1.2,<0.2a0',
+        'django-prices>=0.3.3,<0.4a0',
+        'django-selectable==0.8.0',
+        'fake-factory>=0.3.2',
         'prices>=0.5,<0.6a0',
         'satchless>=1.1.2,<1.2a0',
         'South>=0.7.6',
         'requests>=1.2.0',
-        'unidecode',
-        'django-selectable==0.8.0',
-        'fake-factory>=0.3.2'
+        'unidecode'
     ],
     entry_points={
         'console_scripts': ['saleor = saleor:manage']},


Test patch:
Repository: saleor/saleor

Issue:
Removing category redirects to category update view 
Confirmation modal contains "update" button that redirects to update view, instead of sending a POST request to remove the category.



Discussion:

Resolving patch:
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.py
--- a/saleor/dashboard/category/views.py
+++ b/saleor/dashboard/category/views.py
@@ -1,4 +1,6 @@
 from django.contrib import messages
+from django.core.urlresolvers import reverse
+from django.http import JsonResponse
 from django.shortcuts import get_object_or_404, redirect
 from django.template.response import TemplateResponse
 from django.utils.translation import ugettext_lazy as _
@@ -66,12 +68,19 @@ def category_delete(request, pk):
         if category.parent:
             root_pk = category.parent.pk
         if root_pk:
+            if request.is_ajax():
+                response = {'redirectUrl': reverse(
+                    'dashboard:category-list', kwargs={'root_pk': root_pk})}
+                return JsonResponse(response)
             return redirect('dashboard:category-list', root_pk=root_pk)
         else:
+            if request.is_ajax():
+                response = {'redirectUrl': reverse('dashboard:category-list')}
+                return JsonResponse(response)
             return redirect('dashboard:category-list')
     ctx = {'category': category,
            'descendants': list(category.get_descendants()),
            'products_count': len(category.products.all())}
     return TemplateResponse(request,
-                            'dashboard/category/modal_category_confirm_delete.html',
+                            'dashboard/category/modal_delete.html',
                             ctx)


Test patch:
Repository: saleor/saleor

Issue:
Move py.test config to tox.ini
Pytest (like many tools) can read its configuration from `tox.ini`. There is no need to keep a separate `pytest.ini`.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -70,7 +70,7 @@ def run_tests(self):
     entry_points={
         'console_scripts': ['saleor = saleor:manage']},
     tests_require=[
-        'mock==1.0.1',
+        'mock==1.3.0',
         'purl>=0.4.1',
         'pytest',
         'pytest-django'])


Test patch:
diff --git a/saleor/registration/test_registration.py b/saleor/registration/test_registration.py
--- a/saleor/registration/test_registration.py
+++ b/saleor/registration/test_registration.py
@@ -141,7 +141,15 @@ def test_token_is_obtained_on_construction(self):
         """OAuth2 client asks for access token if interim code is available"""
         self.access_token_response.status_code = sentinel.ok
         Client(local_host='http://localhost', code=sentinel.code)
-        self.requests_mock.post.assert_called_once()
+        self.requests_mock.post.assert_called_once_with(
+            sentinel.token_uri,
+            data={'grant_type': 'authorization_code',
+                  'client_id': sentinel.client_id,
+                  'client_secret': sentinel.client_secret,
+                  'code': sentinel.code,
+                  'redirect_uri': sentinel.redirect_uri,
+                  'scope': sentinel.scope},
+            auth=None)
 
     def test_token_success(self):
         """OAuth2 client properly obtains access token"""
Repository: saleor/saleor

Issue:
Just curious why you using whitenoise with uwsgi?
Why do you using whitenoise with uWSGI?
uWSGI can serve static assets much faster than whitenoise! 
Just look for options: "static-map" or "static-map2" in uWSGI docs.
http://uwsgi-docs.readthedocs.org/en/latest/StaticFiles.html



Discussion:

Resolving patch:
diff --git a/saleor/wsgi/static.py b/saleor/wsgi/static.py
deleted file mode 100644
--- a/saleor/wsgi/static.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import os
-
-os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'saleor.settings')
-
-from django.core.wsgi import get_wsgi_application
-from whitenoise.django import DjangoWhiteNoise
-
-application = get_wsgi_application()
-application = DjangoWhiteNoise(application)


Test patch:
Repository: saleor/saleor

Issue:
User accounts are not made active after they confirm their email addresses and set their password
Using the latest code 3aa172375bd494a728518de5f41134160da49d59

A user can register an account. Once they have confirmed their email address and set a password, they are logged in.

If they then logout - they can't log back in because the account is not marked as active.

![Login flow](http://i.imgur.com/ODkKpqF.gif)



Discussion:
My solution is to activate the account after they confirm their email address the PR is #482


Resolving patch:
diff --git a/saleor/registration/models.py b/saleor/registration/models.py
--- a/saleor/registration/models.py
+++ b/saleor/registration/models.py
@@ -51,7 +51,10 @@ class EmailConfirmationRequest(AbstractToken):
 
     def get_authenticated_user(self):
         user, dummy_created = get_user_model().objects.get_or_create(
-            email=self.email)
+            email=self.email, defaults={'is_active': True})
+        if not user.is_active:
+            # you shouldn't be able to log in if your account is disabled
+            return
         return authenticate(user=user)
 
     def get_confirmation_url(self):
diff --git a/saleor/registration/views.py b/saleor/registration/views.py
--- a/saleor/registration/views.py
+++ b/saleor/registration/views.py
@@ -100,6 +100,8 @@ def confirm_email(request, token):
         except EmailConfirmationRequest.DoesNotExist:
             return TemplateResponse(request, 'registration/invalid_token.html')
         user = email_confirmation_request.get_authenticated_user()
+        if user is None:
+            return TemplateResponse(request, 'registration/invalid_token.html')
         email_confirmation_request.delete()
         auth_login(request, user)
         messages.success(request, _('You are now logged in.'))


Test patch:
Repository: saleor/saleor

Issue:
302 Status in Shipping Method. 
**TD;LR** When I enter the "Shipping Address" entire as anonymous or create a new address. It makes me submit it again and again.

Using c79bdbb13c399b253e3a26480d01f1cb219b4700

I get this most annoying bug. I can't solve from days. It only happens in the production site, not on the test as well as development. I really don't understand where I am going wrong.

What should really happen `Shipping Address(302) -> Shipping Method(200)`

Problem:
`Shipping Address(302) -> Shipping Method(302) -> Shipping Address(200)`.
This mean the users has to submit the form again and again.

Cases when `Shipping Method(200)` 
- 3 to 5 attempts of submitting the form.
- 2 to 5 minutes of waiting to submit again.

I have even done an attempt using the `old checkout`, when the billing address was the first form, Still result is the same.



Discussion:
Are you using multiple processes to run the site? I would assume so as this makes the most sense.

Do you have Django cache configured? If not, it will default to local process memory which means each of the web worker processes has a private cache that is not shared between them. This leads to a situation where every worker process has its own version of the user's current session. It could mean that submitting the shipping address saves it to session in process #1 but when you get redirected to the next step, you are served by process #2 that does not have the address so it asks you to provide it. If you are really unlucky you could keep sending data to process #1 and then get handled by any of the other processes so you'd be stuck in an infinite loop.

If this sounds like the problem at hand, consider using Redis or memcached to allow user sessions to be shared between workers. Or you could change the session storage backend that Django uses to a purely database-driven one but it hurt the performance slightly.


Resolving patch:
diff --git a/saleor/core/__init__.py b/saleor/core/__init__.py
--- a/saleor/core/__init__.py
+++ b/saleor/core/__init__.py
@@ -2,6 +2,7 @@
 
 from babel.numbers import get_territory_currencies
 from django.conf import settings
+from django.core.checks import register, Tags, Warning
 from django_countries import countries
 from django_countries.fields import Country
 from geolite2 import geolite2
@@ -27,3 +28,19 @@ def get_currency_for_country(country):
         if main_currency in settings.AVAILABLE_CURRENCIES:
             return main_currency
     return settings.DEFAULT_CURRENCY
+
+
+@register()
+def check_session_caching(app_configs, **kwargs):
+    errors = []
+    cached_engines = {
+        'django.contrib.sessions.backends.cache',
+        'django.contrib.sessions.backends.cached_db'}
+    if ('locmem' in settings.CACHES['default']['BACKEND'] and
+            settings.SESSION_ENGINE in cached_engines):
+        errors.append(
+            Warning(
+                'Session caching cannot work with locmem backend',
+                'User sessions need to be globally shared, use a cache server like Redis.',
+                'saleor.W001'))
+    return errors


Test patch:
Repository: saleor/saleor

Issue:
Drop cart partitioner from cart view
Currently the cart is partitioned every time it'd displayed. We really only need to do this when creating an order/payment. We do call it every time the cart is rendered but we then merge all of the partitions back into a single list.
- [ ] identify places where cart partitioner is called
- [ ] remove the unnecessary calls from places that don't absolutely need partitioning to work (checkout)
- [ ] simplify templates so they iterate over the cart instead of walking through a list of partitions that in turn contain items
- [ ] provide a brief description of the changes for the next release changelog



Discussion:

Resolving patch:
diff --git a/saleor/cart/views.py b/saleor/cart/views.py
--- a/saleor/cart/views.py
+++ b/saleor/cart/views.py
@@ -48,7 +48,6 @@ def index(request, product_id=None):
             if request.is_ajax():
                 response = {'error': form.errors}
                 return JsonResponse(response, status=400)
-    cart_partitioner = cart.partition()
     return TemplateResponse(
         request, 'cart/index.html', {
-            'cart': cart_partitioner})
+            'cart': cart})


Test patch: