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

Issue:
Add album to event foreign key to api
Feature request (I'm making this via the Github app so the template doesn't work) 


See title, Julian wants this :)


Discussion:

Resolving patch:
diff --git a/website/photos/api/v2/serializers/album.py b/website/photos/api/v2/serializers/album.py
--- a/website/photos/api/v2/serializers/album.py
+++ b/website/photos/api/v2/serializers/album.py
@@ -15,7 +15,15 @@ class Meta:
         """Meta class for the serializer."""
 
         model = Album
-        fields = ("slug", "title", "accessible", "shareable", "cover", "photos")
+        fields = (
+            "slug",
+            "title",
+            "accessible",
+            "shareable",
+            "cover",
+            "photos",
+            "event",
+        )
 
     cover = PhotoSerializer()
     accessible = serializers.SerializerMethodField("_accessible")
@@ -30,4 +38,4 @@ class Meta:
         """Meta class for the serializer."""
 
         model = Album
-        fields = ("slug", "title", "accessible", "shareable", "cover")
+        fields = ("slug", "title", "accessible", "shareable", "cover", "event")


Test patch:
Repository: svthalia/concrexit

Issue:
Untranslated email subject
### Describe the bug

We just got an email from Cato:

<img width="655" alt="image" src="https://user-images.githubusercontent.com/1576660/191570837-0b3bf3e8-4c38-4113-8351-b505d83e97ea.png">




Discussion:

Resolving patch:
diff --git a/website/members/emails.py b/website/members/emails.py
--- a/website/members/emails.py
+++ b/website/members/emails.py
@@ -230,7 +230,7 @@ def send_email_change_completion_message(change_request):
     :param change_request the email change request entered by the user
     """
     change_request.member.email_user(
-        "[THALIA] {_('Your email address has been changed')}",
+        f"[THALIA] {_('Your email address has been changed')}",
         loader.render_to_string(
             "members/email/email_change_completed.txt",
             {"name": change_request.member.first_name},


Test patch:
Repository: svthalia/concrexit

Issue:
Partner page partner blocks keep showing the loading animation
### Describe the bug
Partner page partner blocks keep showing the loading animation.

### How to reproduce
Steps to reproduce the behaviour:
1. Go to [the Thalia partner page](https://thalia.nu/career/).
2. Scroll down and see the loading animation on the partner blocks.

### Expected behaviour
The loading animation should stop when the partners have been loaded.



Discussion:

Resolving patch:
diff --git a/website/partners/templatetags/partner_cards.py b/website/partners/templatetags/partner_cards.py
--- a/website/partners/templatetags/partner_cards.py
+++ b/website/partners/templatetags/partner_cards.py
@@ -27,6 +27,7 @@ def partner_card(partner):
         url=partner.get_absolute_url,
         image_url=image_url,
         class_name="partner-card contain-logo",
+        show_loading_animation=False,
     )
 
 
diff --git a/website/thaliawebsite/templatetags/grid_item.py b/website/thaliawebsite/templatetags/grid_item.py
--- a/website/thaliawebsite/templatetags/grid_item.py
+++ b/website/thaliawebsite/templatetags/grid_item.py
@@ -12,6 +12,7 @@ def grid_item(
     ribbon=None,
     class_name="",
     anchor_attrs="",
+    show_loading_animation=True,
 ):
     return {
         "title": title,
@@ -21,4 +22,5 @@ def grid_item(
         "ribbon": ribbon,
         "class_name": class_name,
         "anchor_attrs": anchor_attrs,
+        "show_loading_animation": show_loading_animation,
     }


Test patch:
Repository: svthalia/concrexit

Issue:
Thumbnailing of transparent images seems to break
### Describe the bug
<img width="1119" alt="image" src="https://user-images.githubusercontent.com/7915741/191974542-041bdb37-f2e0-4181-9267-9a24d5df66b3.png">

### How to reproduce
<img width="1119" alt="image" src="https://user-images.githubusercontent.com/7915741/191974542-041bdb37-f2e0-4181-9267-9a24d5df66b3.png">

### Expected behaviour
Not <img width="1119" alt="image" src="https://user-images.githubusercontent.com/7915741/191974542-041bdb37-f2e0-4181-9267-9a24d5df66b3.png">

### Screenshots
<img width="1119" alt="image" src="https://user-images.githubusercontent.com/7915741/191974542-041bdb37-f2e0-4181-9267-9a24d5df66b3.png">

### Additional context



Discussion:

Resolving patch:
diff --git a/website/utils/media/services.py b/website/utils/media/services.py
--- a/website/utils/media/services.py
+++ b/website/utils/media/services.py
@@ -12,7 +12,7 @@
 
 def save_image(storage, image, path, format):
     buffer = io.BytesIO()
-    image.convert("RGB").save(fp=buffer, format=format)
+    image.convert("RGB" if format == "JPEG" else "RGBA").save(fp=buffer, format=format)
     buff_val = buffer.getvalue()
     content = ContentFile(buff_val)
     file = InMemoryUploadedFile(


Test patch:
Repository: svthalia/concrexit

Issue:
Fix fixtures (and test them in CI)
### Describe the bug
`./manage.py createfixtures` always breaks. It's time to fix that, and prevent it from happening.




Discussion:

Resolving patch:
diff --git a/website/utils/management/commands/createfixtures.py b/website/utils/management/commands/createfixtures.py
--- a/website/utils/management/commands/createfixtures.py
+++ b/website/utils/management/commands/createfixtures.py
@@ -21,7 +21,12 @@
 )
 from documents.models import Document
 from education.models import Course, Category
-from events.models import Event, EventRegistration, EVENT_CATEGORIES
+from events.models import (
+    Event,
+    EventRegistration,
+    EVENT_CATEGORIES,
+    registration_member_choices_limit,
+)
 from members.models import Profile, Member, Membership
 from newsletters.models import NewsletterItem, NewsletterEvent, Newsletter
 from partners.models import Partner, Vacancy, VacancyCategory
@@ -523,7 +528,8 @@ def create_event_registration(self, event_to_register_for=None):
         self.stdout.write("Creating an event registration")
         registration = EventRegistration()
 
-        registration.member = Member.objects.order_by("?")[0]
+        eligible = Member.objects.filter(registration_member_choices_limit())
+        registration.member = eligible.order_by("?")[0]
 
         possible_event = (
             event_to_register_for


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -151,6 +151,47 @@ jobs:
           name: coverage-html
           path: covhtml
 
+  run-fixtures:
+    name: Run fixtures
+    runs-on: ubuntu-latest
+    services:
+      postgres:
+        image: postgres:latest
+        env:
+          POSTGRES_DB: thalia
+          POSTGRES_USER: postgres
+          POSTGRES_PASSWORD: postgres
+        ports:
+          - 5432:5432
+    env:
+      DJANGO_ENV: testing
+    steps:
+      - name: Setup python
+        uses: actions/setup-python@v4
+        with:
+          python-version: '3.9'
+
+      - name: Setup Poetry
+        uses: snok/install-poetry@v1
+
+      - name: Checkout repository
+        uses: actions/checkout@v3
+
+      - name: Restore any cached Poetry dependencies
+        uses: actions/cache@v3
+        with:
+          path: ~/.cache/pypoetry/virtualenvs
+          key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
+          restore-keys: |
+            ${{ runner.os }}-poetry-
+
+      - name: Install any new dependencies
+        run: poetry install --extras "postgres"
+        if: steps.cache.outputs.cache-hit != 'true'
+
+      - name: Run create fixtures
+        run: make fixtures
+
   documentation-tests:
     name: Documentation Tests
     runs-on: ubuntu-latest
Repository: svthalia/concrexit

Issue:
Vacancies without partner page on homepage lead to 404 errors
### Describe the bug
The vacancy view on the homepage leads to a 404 for vacancies without partner pages, as it tries to go to that page anyway.

### How to reproduce
Steps to reproduce the behaviour:
1. Create an inactive partner
2. Create a vacancy with them
3. Make it appear on the homepage
4. Click it

### Expected behaviour
Going to the vacancy in some way, e.g. on the general vacancy page.

### Screenshots
If applicable, add screenshots to help explain your problem.

### Additional context
I think I sort of fixed this for the main vacancy list, so we can probably share the code there. (Although I believe that that is currently broken too.)



Discussion:

Resolving patch:
diff --git a/website/partners/templatetags/frontpage_vacancies.py b/website/partners/templatetags/frontpage_vacancies.py
--- a/website/partners/templatetags/frontpage_vacancies.py
+++ b/website/partners/templatetags/frontpage_vacancies.py
@@ -12,7 +12,7 @@ def render_frontpage_vacancies():
 
     for vacancy in Vacancy.objects.order_by("?")[:6]:
         url = "{}#vacancy-{}".format(reverse("partners:vacancies"), vacancy.id)
-        if vacancy.partner:
+        if vacancy.partner and vacancy.partner.is_active:
             url = "{}#vacancy-{}".format(vacancy.partner.get_absolute_url(), vacancy.id)
 
         vacancies.append(


Test patch:
Repository: svthalia/concrexit

Issue:
Cannot add events on staging/master
### Describe the bug
`KeyError at /admin/events/event/add/`

### How to reproduce
Steps to reproduce the behaviour:
1. Go to admin
2. Try to add event
3. See error mentioned above

### Expected behaviour
Get the actual admin page


Discussion:

Resolving patch:
diff --git a/website/events/admin/event.py b/website/events/admin/event.py
--- a/website/events/admin/event.py
+++ b/website/events/admin/event.py
@@ -246,12 +246,15 @@ def get_urls(self):
         return custom_urls + urls
 
     def get_field_queryset(self, db, db_field, request):
-        """Members without the can view as organiser permission can only assign their own groups as organiser."""
-        pk = resolve(request.path_info).kwargs["object_id"]
+        """Members without the 'can view as organiser' permission can only assign their own groups as organiser."""
+        pk = resolve(request.path_info).kwargs.get("object_id")
         if db_field.name == "organisers" and not request.user.has_perm(
             "events.override_organiser"
         ):
-            return request.member.get_member_groups().union(
-                MemberGroup.objects.filter(event_organiser__pk=pk)
-            )
+            if pk is None:
+                return request.member.get_member_groups()
+            else:
+                return request.member.get_member_groups().union(
+                    MemberGroup.objects.filter(event_organiser__pk=pk)
+                )
         return super().get_field_queryset(db, db_field, request)


Test patch:
Repository: svthalia/concrexit

Issue:
It is possible to delete bank account for user with open thalia pay payments via data minimisation
### Describe the bug
It is possible to delete bank account for user with open thalia pay payments via data minimisation

### How to reproduce
have a user pay with Thalia Pay
Minimise account data
Try to process batch
No bank account, crash 

### Expected behaviour
Minimizing should not be possible

### Screenshots
 
### Additional context
 


Discussion:

Resolving patch:
diff --git a/website/members/services.py b/website/members/services.py
--- a/website/members/services.py
+++ b/website/members/services.py
@@ -236,7 +236,6 @@ def execute_data_minimisation(dry_run=False, members=None) -> List[Member]:
             profile.birthday = datetime(1900, 1, 1)
             profile.emergency_contact_phone_number = None
             profile.emergency_contact = None
-            member.bank_accounts.all().delete()
             if not dry_run:
                 profile.save()
 
diff --git a/website/payments/services.py b/website/payments/services.py
--- a/website/payments/services.py
+++ b/website/payments/services.py
@@ -202,11 +202,23 @@ def send_tpay_batch_processing_emails(batch):
 def execute_data_minimisation(dry_run=False):
     """Anonymizes payments older than 7 years."""
     # Sometimes years are 366 days of course, but better delete 1 or 2 days early than late
-    deletion_period = timezone.now().date() - timezone.timedelta(days=(365 * 7))
-
-    queryset = Payment.objects.filter(created_at__lte=deletion_period).exclude(
-        paid_by__isnull=True
+    payment_deletion_period = timezone.now().date() - timezone.timedelta(days=(365 * 7))
+    bankaccount_deletion_period = timezone.now() - datetime.timedelta(days=(31 * 13))
+
+    queryset_payments = Payment.objects.filter(
+        created_at__lte=payment_deletion_period
+    ).exclude(paid_by__isnull=True)
+
+    queryset_bankaccounts = BankAccount.objects.filter(
+        Q(owner__paid_payment_set__type=Payment.TPAY),
+        Q(owner__paid_payment_set__batch__isnull=True)
+        | Q(owner__paid_payment_set__batch__processed=False)
+        | Q(
+            owner__paid_payment_set__batch__processing_date__gt=bankaccount_deletion_period
+        ),
     )
+
     if not dry_run:
-        queryset.update(paid_by=None, processed_by=None)
-    return queryset
+        queryset_payments.update(paid_by=None, processed_by=None)
+        queryset_bankaccounts.delete()
+    return queryset_payments


Test patch:
Repository: svthalia/concrexit

Issue:
Time/Date picking window is underneath the description styling 
### Describe the bug
When adding an event to the site the window, which pops up when you select a date or a time, appears underneath the text styling bar of the description. The z index of the description text styling bar should be lower then that of the time/date selection window.

### How to reproduce
Steps to reproduce the behaviour:
1. Go to 'thalia.nu/admin'
2. Click on 'events'
3. Click on add event
4. Go to details
5. Go to 'End time'
6. Click on the clock icon
7. See error

### Expected behaviour
 The z index of the description text styling bar should be lower then that of the time/date selection window.

### Screenshots
[screenshot of the problem](https://imgur.com/a/sYT13lL)



Discussion:
![Urbx5bs](https://user-images.githubusercontent.com/7915741/191544381-9708dd55-76ff-494e-9489-fd8563c12f03.png)


Resolving patch:
diff --git a/website/thaliawebsite/settings.py b/website/thaliawebsite/settings.py
--- a/website/thaliawebsite/settings.py
+++ b/website/thaliawebsite/settings.py
@@ -761,6 +761,14 @@ def from_env(
     "remove_script_host": False,
     "autoresize_bottom_margin": 50,
 }
+TINYMCE_EXTRA_MEDIA = {
+    "css": {
+        "all": [
+            "css/tinymce.css",
+        ],
+    },
+}
+
 
 BOOTSTRAP5 = {"required_css_class": "required-field"}
 


Test patch:
Repository: svthalia/concrexit

Issue:
Some deletes in the sales app fail
We are using distinct in some places and those general querysets are probably also used for deletion.

Sentry Issue: [CONCREXIT-G3](https://sentry.io/organizations/thalia/issues/3592435888/?referrer=github_integration)

```
TypeError: Cannot call delete() after .distinct().
(9 additional frame(s) were not displayed)
...
  File "django/contrib/admin/options.py", line 1983, in changelist_view
    response = self.response_action(
  File "django/contrib/admin/options.py", line 1588, in response_action
    response = func(self, request, queryset)
  File "django/contrib/admin/actions.py", line 51, in delete_selected
    modeladmin.delete_queryset(request, queryset)
  File "django/contrib/admin/options.py", line 1230, in delete_queryset
    queryset.delete()
  File "django/db/models/query.py", line 809, in delete
    raise TypeError("Cannot call delete() after .distinct().")
```


Discussion:

Resolving patch:
diff --git a/website/sales/admin/order_admin.py b/website/sales/admin/order_admin.py
--- a/website/sales/admin/order_admin.py
+++ b/website/sales/admin/order_admin.py
@@ -253,7 +253,7 @@ def get_queryset(self, request):
         elif not request.member.has_perm("sales.override_manager"):
             queryset = queryset.filter(
                 shift__managers__in=request.member.get_member_groups()
-            ).distinct()
+            )
 
         queryset = queryset.select_properties(
             "total_amount", "subtotal", "num_items", "age_restricted"
@@ -335,7 +335,7 @@ def formfield_for_dbfield(self, db_field, request, obj=None, **kwargs):
             elif not request.member.has_perm("sales.override_manager"):
                 field.queryset = field.queryset.filter(
                     managers__in=request.member.get_member_groups()
-                )
+                ).distinct()
         return field
 
     def changelist_view(self, request, extra_context=None):


Test patch:
Repository: svthalia/concrexit

Issue:
AttributeError: 'Event' object has no attribute 'number_regs'
Sentry Issue: [CONCREXIT-HC](https://sentry.io/organizations/thalia/issues/3639420824/?referrer=github_integration)

```
AttributeError: 'Event' object has no attribute 'number_regs'
(11 additional frame(s) were not displayed)
...
  File "rest_framework/serializers.py", line 253, in data
    self._data = self.to_representation(self.instance)
  File "rest_framework/serializers.py", line 522, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "rest_framework/serializers.py", line 522, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "rest_framework/fields.py", line 1838, in to_representation
    return method(value)
  File "events/api/v2/serializers/event.py", line 86, in _num_participants
    participant_count = instance.number_regs
```


Discussion:

Resolving patch:
diff --git a/website/events/api/v2/serializers/event.py b/website/events/api/v2/serializers/event.py
--- a/website/events/api/v2/serializers/event.py
+++ b/website/events/api/v2/serializers/event.py
@@ -83,10 +83,7 @@ def _user_registration(self, instance):
         return None
 
     def _num_participants(self, instance):
-        participant_count = instance.number_regs
-        if instance.max_participants and participant_count > instance.max_participants:
-            return instance.max_participants
-        return participant_count
+        return instance.participants.count()
 
     def _user_permissions(self, instance):
         member = self.context["request"].member


Test patch:
Repository: svthalia/concrexit

Issue:
TypeError: PromotionRequestAdmin.mark_finished() takes 2 positional arguments but 3 were given
Sentry Issue: [CONCREXIT-JD](https://sentry.io/organizations/thalia/issues/3668103253/?referrer=github_integration)

```
TypeError: PromotionRequestAdmin.mark_finished() takes 2 positional arguments but 3 were given
(5 additional frame(s) were not displayed)
...
  File "django/contrib/admin/sites.py", line 242, in inner
    return view(request, *args, **kwargs)
  File "django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "django/utils/decorators.py", line 133, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1959, in changelist_view
    response = self.response_action(
  File "django/contrib/admin/options.py", line 1588, in response_action
    response = func(self, request, queryset)
```


Discussion:

Resolving patch:
diff --git a/website/promotion/admin.py b/website/promotion/admin.py
--- a/website/promotion/admin.py
+++ b/website/promotion/admin.py
@@ -27,25 +27,25 @@ def has_change_permission(self, request, obj=None):
             return False
         return super().has_change_permission(request, obj)
 
-    def mark_not_started(self, queryset):
+    def mark_not_started(self, request, queryset):
         """Change the status of the event to published."""
         self._change_published(queryset, PromotionRequest.NOT_STARTED)
 
     mark_not_started.short_description = "Mark requests as not started"
 
-    def mark_started(self, queryset):
+    def mark_started(self, request, queryset):
         """Change the status of the event to published."""
         self._change_published(queryset, PromotionRequest.STARTED)
 
     mark_started.short_description = "Mark requests as started"
 
-    def mark_finished(self, queryset):
+    def mark_finished(self, request, queryset):
         """Change the status of the event to published."""
         self._change_published(queryset, PromotionRequest.FINISHED)
 
     mark_finished.short_description = "Mark requests as finished"
 
-    def mark_published(self, queryset):
+    def mark_published(self, request, queryset):
         """Change the status of the event to published."""
         self._change_published(queryset, PromotionRequest.PUBLISHED)
 


Test patch:
Repository: svthalia/concrexit

Issue:
Updating promo requests 
**Describe the bug**
It is not possible to update the promo request within a week of the publish date 

**How to reproduce** 
Create a promo request 
Try to update the designer within a week to publish date 

**Expected behavior** 
The request can only be created more than a week before the publishing date, but assigned to, status and drive folder can always be edited. 


Discussion:

Resolving patch:
diff --git a/website/promotion/forms.py b/website/promotion/forms.py
--- a/website/promotion/forms.py
+++ b/website/promotion/forms.py
@@ -20,11 +20,6 @@ class Meta:
 
     def clean_publish_date(self):
         publish_date = self.cleaned_data.get("publish_date")
-        create_time_minimum = publish_date - PROMO_PUBLISH_DATE_TIMEDELTA
-        if timezone.localdate() > create_time_minimum:
-            raise forms.ValidationError(
-                "Publish date cannot be within a week from now."
-            )
         if "publish_date" in self.changed_data:
             create_time_minimum = publish_date - PROMO_PUBLISH_DATE_TIMEDELTA
             if timezone.localdate() > create_time_minimum:


Test patch:
Repository: svthalia/concrexit

Issue:
Do not throw away bank accounts that may not be deleted during member data minimisation
Closes #2539 

### Summary
Moves bank account minimization to the payments app. This will keep bank accounts 13 months after last usage for collecting a Thalia Pay batch, as is required.


### How to test
1. Do data minimisation
2. Bank accounts will only be removed 13 months after last usage


Discussion:
Code Climate has analyzed commit 6de3e988 and detected **0 issues** on this pull request.

View more on [Code Climate](https://codeclimate.com/github/svthalia/concrexit/pull/2549).


Resolving patch:
diff --git a/website/payments/services.py b/website/payments/services.py
--- a/website/payments/services.py
+++ b/website/payments/services.py
@@ -209,12 +209,24 @@ def execute_data_minimisation(dry_run=False):
         created_at__lte=payment_deletion_period
     ).exclude(paid_by__isnull=True)
 
-    queryset_bankaccounts = BankAccount.objects.filter(
-        Q(owner__paid_payment_set__type=Payment.TPAY),
-        Q(owner__paid_payment_set__batch__isnull=True)
-        | Q(owner__paid_payment_set__batch__processed=False)
+    # Delete bank accounts that are not valid anymore, and have not been used in the last 13 months
+    # (13 months is the required time we need to keep the mandates for)
+    queryset_bankaccounts = BankAccount.objects.all()
+    queryset_bankaccounts = queryset_bankaccounts.filter(
+        valid_until__lt=timezone.now()
+    )  # Keep valid bank accounts
+    queryset_bankaccounts = queryset_bankaccounts.exclude(  # Also keep bank accounts that
+        Q(
+            owner__paid_payment_set__type=Payment.TPAY
+        ),  # are used for Thalia Pay payments, AND
+        Q(
+            owner__paid_payment_set__batch__isnull=True
+        )  # have a payment that is in no batch, OR
         | Q(
-            owner__paid_payment_set__batch__processing_date__gt=bankaccount_deletion_period
+            owner__paid_payment_set__batch__processed=False
+        )  # have an unprocessed batch, OR
+        | Q(
+            owner__paid_payment_set__batch__processing_date__gt=bankaccount_deletion_period  # or have a processed batch that is not older than 13 months
         ),
     )
 


Test patch: