internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: kartoza/prj.app

Issue:
Download issue certificate link is broken
I get a 500 error when trying to download issued certificates from a course. Example link https://changelog.qgis.org/en/qgis/certifyingorganisation/spatial-thoughts/course/qgis_custimizing-qgis-with-python_2020-02-15-2020-02-15/download_zip/

<img width="1440" alt="download_error" src="https://user-images.githubusercontent.com/5227506/74597702-7ad8ed80-5089-11ea-9908-bb0990c7af65.png">



Discussion:

Resolving patch:
diff --git a/django_project/certification/views/certificate.py b/django_project/certification/views/certificate.py
--- a/django_project/certification/views/certificate.py
+++ b/django_project/certification/views/certificate.py
@@ -477,7 +477,7 @@ def download_certificates_zip(request, **kwargs):
             course_slug=course_slug, organisation_slug=organisation_slug)
 
         with open('/tmp/%s.pdf' % certificate.certificateID, 'wb') as pdf:
-            pdf.write(pdf_file.content)
+            pdf.write(pdf_file.getvalue())
 
         filenames.append('/tmp/%s.pdf' % certificate.certificateID)
 


Test patch:
Repository: kartoza/prj.app

Issue:
Sign up link for certification is broken when not logged in
IF a user visits https://changelog.qgis.org/en/qgis/create-certifyingorganisation/ and they are not logged in, they get redirected to the front page. They should instead get shown a page asking them to log / create an account first and then get redirected back to the create page. They should also be shown the help link so they can find out how the certification system works.


Discussion:
cc @andreasneumann @geomenke 
Yes, happens to me as well if I sign out and pretend to be a new user who knows nothing about the system. Quite confusing. Thanks for improving this!
Same issue with sustating member sign up

Resolving patch:
diff --git a/django_project/core/settings/project.py b/django_project/core/settings/project.py
--- a/django_project/core/settings/project.py
+++ b/django_project/core/settings/project.py
@@ -84,3 +84,4 @@
 ]
 
 EMAIL_HOST_USER = 'noreply@kartoza.com'
+LOGIN_URL = '/en/accounts/login/'


Test patch:
Repository: kartoza/prj.app

Issue:
rst export currently broken for QGIS 3.12
Somebody with the right permissions should be able to download the rst+images in a zip:

https://changelog.qgis.org/en/qgis/version/3.12/download/

This morning it throws a 500 error.


Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -603,10 +603,13 @@ def _prepare_zip_archive(self, document, version_obj):
         with zipfile.ZipFile(temp_path, 'w') as zip_file:
             # write all of the image files (read from disk)
             for image in images:
-                zip_file.write(
-                    '../media/{0}'.format(image),
-                    '{0}'.format(image)
-                )
+                try:
+                    zip_file.write(
+                        '../media/{0}'.format(image),
+                        '{0}'.format(image)
+                    )
+                except FileNotFoundError:
+                    pass
             # write the actual RST document
             zip_file.writestr(
                 'index.rst',


Test patch:
Repository: kartoza/prj.app

Issue:
rst export currently broken for QGIS 3.12
Somebody with the right permissions should be able to download the rst+images in a zip:

https://changelog.qgis.org/en/qgis/version/3.12/download/

This morning it throws a 500 error.


Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -12,6 +12,7 @@
 from io import BytesIO
 import pypandoc
 from bs4 import BeautifulSoup
+from django.conf import settings
 from django.urls import reverse
 from django.http import Http404
 from django.shortcuts import get_object_or_404
@@ -604,8 +605,9 @@ def _prepare_zip_archive(self, document, version_obj):
             # write all of the image files (read from disk)
             for image in images:
                 try:
+                    image_url = '{}/{}'.format(settings.MEDIA_ROOT, image)
                     zip_file.write(
-                        '../media/{0}'.format(image),
+                        image_url,
                         '{0}'.format(image)
                     )
                 except FileNotFoundError:


Test patch:
Repository: kartoza/prj.app

Issue:
Changelog still refers to sponsors
![image](https://user-images.githubusercontent.com/178003/84606550-024f3580-ae9f-11ea-8f81-747aab03f11b.png)

Reame sponsors to sustaining members in the changelog please

CC @andreasneumann


Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -744,7 +744,7 @@ def render_to_response(self, context, **response_kwargs):
             zip_file.getvalue(), content_type="application/x-zip-compressed")
         # ..and correct content-disposition
         response['Content-Disposition'] = (
-            'attachment; filename="{}-Sponsor-{}.zip"'.format(
+            'attachment; filename="{}-SustainingMember-{}.zip"'.format(
                 version_obj.project.name, version_obj.name)
         )
 
@@ -780,7 +780,7 @@ def _prepare_zip_archive(self, document, version_obj):
                 )
             # write the actual html document
             zip_file.writestr(
-                '{}-Sponsor-{}.html'.format(
+                '{}-SustainingMember-{}.html'.format(
                     version_obj.project.name, version_obj.name),
                 document)
 


Test patch:
Repository: kartoza/prj.app

Issue:
Order categories view shows duplicates
<img width="1213" alt="image" src="https://user-images.githubusercontent.com/178003/82647677-77b44700-9c0e-11ea-9d7f-de3c4da8a5d2.png">


https://changelog.qgis.org/en/qgis/category/order/

Should only show one of each unique value.


Discussion:

Resolving patch:
diff --git a/django_project/changes/admin.py b/django_project/changes/admin.py
--- a/django_project/changes/admin.py
+++ b/django_project/changes/admin.py
@@ -23,6 +23,9 @@
 class CategoryAdmin(reversion.admin.VersionAdmin):
     """Category admin model."""
 
+    list_filter = ('project',)
+    search_fields = ('name',)
+
     def queryset(self, request):
         """Ensure we use the correct manager.
 
diff --git a/django_project/changes/views/category.py b/django_project/changes/views/category.py
--- a/django_project/changes/views/category.py
+++ b/django_project/changes/views/category.py
@@ -226,7 +226,7 @@ def get_queryset(self, queryset=None):
                     Q(project=project) &
                     (Q(project__owner=self.request.user) |
                      Q(project__changelog_managers=self.request.user))
-                ).order_by('sort_number')
+                ).order_by('sort_number').distinct()
                 return queryset
             else:
                 raise Http404(


Test patch:
Repository: kartoza/prj.app

Issue:
Unable to edit Online training center
I created a training center 'Online' but unable to edit it. Might have something to do with the address.
https://changelog.qgis.org/en/qgis/certifyingorganisation/spatial-thoughts/trainingcenter/online/update/


Discussion:
<img width="852" alt="Screen Shot 2020-04-24 at 7 49 07 PM" src="https://user-images.githubusercontent.com/5227506/80222599-bb924b80-8664-11ea-8f3e-c7b5de012801.png">

![image](https://user-images.githubusercontent.com/178003/80289796-09788380-8739-11ea-93da-0d1716ba6912.png)

@ann26 can you look into this please? Also more generally we need to figure out a nicer way to accommodate 'online' as a training center.

See https://changelog.qgis.org/en/site-admin/certification/trainingcenter/91/change/ - the recrod seems to have been created properly.



Resolving patch:
diff --git a/django_project/certification/forms.py b/django_project/certification/forms.py
--- a/django_project/certification/forms.py
+++ b/django_project/certification/forms.py
@@ -229,7 +229,7 @@ class TrainingCenterForm(geoforms.ModelForm):
             'default_zoom': 5,
             'default_lat': -30.559482,
             'default_lon': 22.937506
-        }), )
+        }), required=False)
 
     class Meta:
         model = TrainingCenter
diff --git a/django_project/certification/migrations/0005_auto_20200724_0935.py b/django_project/certification/migrations/0005_auto_20200724_0935.py
new file mode 100644
--- /dev/null
+++ b/django_project/certification/migrations/0005_auto_20200724_0935.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2 on 2020-07-24 07:35
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('certification', '0004_auto_20191204_0516'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='trainingcenter',
+            name='address',
+            field=models.TextField(help_text='Address of the training center. If your training center is online, you can put your web address of your training center.', max_length=250),
+        ),
+    ]
diff --git a/django_project/certification/models/training_center.py b/django_project/certification/models/training_center.py
--- a/django_project/certification/models/training_center.py
+++ b/django_project/certification/models/training_center.py
@@ -33,7 +33,10 @@ class TrainingCenter(SlugifyingMixin, models.Model):
     )
 
     address = models.TextField(
-        help_text=_('Address of the training center.'),
+        help_text=_(
+            'Address of the training center. '
+            'If your training center is online, '
+            'you can put your web address of your training center.'),
         max_length=250,
         null=False,
         blank=False,


Test patch:
Repository: kartoza/prj.app

Issue:
training centre location entry improvement
The default map position is 0,0 with edit mode active. 

It would be better to default to navigation mode so the user doesn't inadvertently add a point while trying to navigate

It would be even better to default to the organisation's address, or at least to their country


Discussion:
Low priority for now @ann26 - maybe just try to default the OL widget to use pan mode 

Resolving patch:
diff --git a/django_project/certification/forms.py b/django_project/certification/forms.py
--- a/django_project/certification/forms.py
+++ b/django_project/certification/forms.py
@@ -1,6 +1,10 @@
 # coding=utf-8
 from __future__ import unicode_literals
+import json
+import os
 from django import forms
+from django.conf import settings
+from django.contrib.gis.geos import Point
 from django.contrib.admin import widgets
 from django.contrib.auth.models import User
 from django.contrib.gis import forms as geoforms
@@ -259,6 +263,21 @@ def __init__(self, *args, **kwargs):
         self.helper.layout = layout
         self.helper.html5_required = False
         super(TrainingCenterForm, self).__init__(*args, **kwargs)
+
+        json_file = settings.STATIC_ROOT + '/json/geo.json'
+        found = os.path.exists(json_file)
+        lat = -30.559482
+        lon = 22.937506
+        if found:
+            with open(json_file) as file:
+                datas = json.load(file)
+                for data in datas['features']:
+                    if data['properties'][
+                            'ISO2'] == self.certifying_organisation.country:
+                        lat = data['properties']['LAT']
+                        lon = data['properties']['LON']
+        point = Point(x=lon, y=lat, srid=4326)
+        self.fields['location'].initial = point
         self.helper.add_input(Submit('submit', 'Submit'))
 
     def save(self, commit=True):


Test patch:
Repository: kartoza/prj.app

Issue:
Sustaining member cloud broken
![image](https://user-images.githubusercontent.com/178003/75789422-961e4b00-5d61-11ea-961a-14665de1b3b4.png)


Gives 500 error


Discussion:
Lower priority - fix other issues first

Resolving patch:
diff --git a/django_project/changes/views/sponsor.py b/django_project/changes/views/sponsor.py
--- a/django_project/changes/views/sponsor.py
+++ b/django_project/changes/views/sponsor.py
@@ -5,6 +5,7 @@
 import time
 import logging
 
+from django.conf import settings
 from django.urls import reverse
 from django.db.models import Q
 from django.shortcuts import get_object_or_404, render
@@ -796,7 +797,7 @@ def generate_sponsor_cloud(request, **kwargs):
             if max_y <= y:
                 max_y = y + xy_size
             background.paste(
-                im, box=(x, y + ((xy_size - height) / 2)), mask=im)
+                im, box=(x, y + int((xy_size - height) / 2)), mask=im)
             x += xy_size
 
     image_path = 'none'
@@ -809,7 +810,8 @@ def generate_sponsor_cloud(request, **kwargs):
             (0, 0, max_x, max_y)).save(
             filepath + '{}.png'.format(project_name))
 
-        image_path = '/images/sponsors/{}.png'.format(project_name)
+        image_path = \
+            settings.MEDIA_URL + 'images/sponsors/{}.png'.format(project_name)
 
     return render(
         request, 'sponsor/sponsor_cloud.html',


Test patch:
Repository: kartoza/prj.app

Issue:
Fix the name encoding for sample data in lessons
# Problem

Currently, all sample data is being downloaded with some encoding issues

i.e 
![adding-vector-data](https://user-images.githubusercontent.com/2510900/113675753-fa75b180-96bb-11eb-9dbf-22af0c2f8c34.png)

This has been fixed for the content in the sheets but we need to fix the names as well



Discussion:

Resolving patch:
diff --git a/django_project/lesson/views/worksheet.py b/django_project/lesson/views/worksheet.py
--- a/django_project/lesson/views/worksheet.py
+++ b/django_project/lesson/views/worksheet.py
@@ -90,7 +90,6 @@ def get_context_data(self, **kwargs):
         context['file_title'] = \
             context['worksheet'].section.name \
             + '-' + context['worksheet'].module
-        context['file_title'] = context['file_title'].encode("utf8")
 
         context['funded_by'] = self.object.funder_info_html()
         return context
@@ -128,7 +127,7 @@ def render_to_response(self, context, **response_kwargs):
         pdf_response = HttpResponse(content_type='application/pdf')
         pdf_response['Content-Disposition'] = \
             'filename={}. {}.pdf'.format(
-                numbering, context['file_title'].decode("utf-8"))
+                numbering, context['file_title'])
         # Need to improve for URL outside of the dev env.
         html_object = HTML(
             string=response.content,
@@ -152,7 +151,7 @@ def render_to_response(self, context, **response_kwargs):
         response = super(WorksheetPDFZipView, self).render_to_response(
             context, **response_kwargs)
         response.render()
-        file_title = context['file_title'].decode('utf-8')
+        file_title = context['file_title']
         # return response
         pdf_response = HttpResponse(content_type='application/pdf')
         pdf_response['Content-Disposition'] = \


Test patch:
Repository: kartoza/prj.app

Issue:
Buying credits : EUR versus USD
It seems there is a bug with currencies on https://changelog.qgis.org/en/

1 : When I want to buy some credits : 
![ksnip_20220509-165805](https://user-images.githubusercontent.com/1609292/167441076-8959dc64-2ffc-4652-bec9-8c84b17bbbd8.png)

It's in EUR

2 : Clicking on the "Pay with strip" button : 

![ksnip_20220509-165840](https://user-images.githubusercontent.com/1609292/167441220-2ae2bb0f-ab9e-4f01-92b9-61b8d32f0caf.png)

Strip is mentioning USD when paying.
It's a straight conversion 20 EUR = 20 USD.
There is a bug.

Can you confirm which currency is used on the bank side ?



Discussion:

Resolving patch:
diff --git a/django_project/certification/views/certificate.py b/django_project/certification/views/certificate.py
--- a/django_project/certification/views/certificate.py
+++ b/django_project/certification/views/certificate.py
@@ -1497,7 +1497,7 @@ def get_context_data(self, **kwargs):
                 line_items=[
                     {
                         "price_data": {
-                            "currency": "usd",
+                            "currency": "eur",
                             "unit_amount": unit_amount,
                             "product_data": {
                                 "name": "Top up credits",


Test patch:
Repository: uccser/cs-unplugged

Issue:
Add Bootstrap 4 SCSS



Discussion:

Resolving patch:
diff --git a/csunplugged/config/settings.py b/csunplugged/config/settings.py
--- a/csunplugged/config/settings.py
+++ b/csunplugged/config/settings.py
@@ -126,5 +126,5 @@
 
 STATIC_URL = '/static/'
 STATICFILES_DIRS = (
-        os.path.join(BASE_DIR, 'static'),
+        os.path.join(BASE_DIR, 'build'),
         )


Test patch:
Repository: uccser/cs-unplugged

Issue:
Add django-debug-toolbar for debugging



Discussion:

Resolving patch:
diff --git a/csunplugged/config/settings.py b/csunplugged/config/settings.py
--- a/csunplugged/config/settings.py
+++ b/csunplugged/config/settings.py
@@ -44,9 +44,11 @@
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'debug_toolbar',
 ]
 
 MIDDLEWARE = [
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.locale.LocaleMiddleware',
@@ -128,3 +130,7 @@
 STATICFILES_DIRS = (
         os.path.join(BASE_DIR, 'build'),
         )
+
+# Internal IPs for Django Debug Toolbar
+# https://docs.djangoproject.com/en/1.10/ref/settings/#internal-ips
+INTERNAL_IPS = ['127.0.0.1']
diff --git a/csunplugged/config/urls.py b/csunplugged/config/urls.py
--- a/csunplugged/config/urls.py
+++ b/csunplugged/config/urls.py
@@ -26,3 +26,9 @@
     url(r'^admin/', include(admin.site.urls)),
 )
 # ] + static(settings.STATIC_URL, documnet_root=settings.STATIC_ROOT)
+
+if settings.DEBUG:
+    import debug_toolbar
+    urlpatterns += [
+        url(r'^__debug__/', include(debug_toolbar.urls)),
+    ]


Test patch:
Repository: uccser/cs-unplugged

Issue:
Always ask for page size and copies for resource generation
Add these questions to `base-resource.html` template


Discussion:

Resolving patch:
diff --git a/csunplugged/resources/views/generate_resource_pdf.py b/csunplugged/resources/views/generate_resource_pdf.py
--- a/csunplugged/resources/views/generate_resource_pdf.py
+++ b/csunplugged/resources/views/generate_resource_pdf.py
@@ -23,6 +23,7 @@ def generate_resource_pdf(request, resource, module_path):
     get_request = request.GET
     context['paper_size'] = get_request['paper_size']
     context['resource'] = resource
+    context['header_text'] = get_request['header_text']
 
     resource_image_generator = importlib.import_module(module_path)
     filename = '{} ({})'.format(resource.name, resource_image_generator.subtitle(get_request, resource))
diff --git a/csunplugged/resources/views/sorting_network.py b/csunplugged/resources/views/sorting_network.py
--- a/csunplugged/resources/views/sorting_network.py
+++ b/csunplugged/resources/views/sorting_network.py
@@ -56,10 +56,12 @@ def number_range(get_request):
     for the requested resource.
     """
     prefilled_values = get_request['prefilled_values']
+    range_min = 0
+    range_max = 0
+    font_size = 150
     if prefilled_values == 'easy':
         range_min = 1
         range_max = 10
-        font_size = 150
     elif prefilled_values == 'medium':
         range_min = 10
         range_max = 100


Test patch:
Repository: uccser/cs-unplugged

Issue:
Change loaddata command name to avoid conflict with existing Django command
See https://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata


Discussion:

Resolving patch:
diff --git a/csunplugged/general/management/commands/loaddata.py b/csunplugged/general/management/commands/updatedata.py
similarity index 66%
rename from csunplugged/general/management/commands/loaddata.py
rename to csunplugged/general/management/commands/updatedata.py
--- a/csunplugged/general/management/commands/loaddata.py
+++ b/csunplugged/general/management/commands/updatedata.py
@@ -2,10 +2,10 @@
 
 
 class Command(management.base.BaseCommand):
-    help = 'Flush and load data for all applications'
+    help = 'Update all data from content folders for all applications'
 
     def handle(self, *args, **options):
-        """The function called when the loaddata command is given"""
+        """The function called when the updatedata command is given"""
         management.call_command('flush', interactive=False)
         management.call_command('loadresources')
         management.call_command('loadtopics')


Test patch:
Repository: uccser/cs-unplugged

Issue:
Move programming exercise expected results within language implementation
The result/output of a programming exercise should be generic, with specific language implementations separate. This should be noted in author documentation.

Example: Embedded Scratch result should be within Scratch language implementation.


Discussion:

Resolving patch:
diff --git a/csunplugged/topics/management/commands/_ProgrammingExercisesLoader.py b/csunplugged/topics/management/commands/_ProgrammingExercisesLoader.py
--- a/csunplugged/topics/management/commands/_ProgrammingExercisesLoader.py
+++ b/csunplugged/topics/management/commands/_ProgrammingExercisesLoader.py
@@ -48,6 +48,9 @@ def load(self):
                     language_object = ProgrammingExerciseLanguage.objects.get(
                         slug=language
                     )
+                    expected_result_path = self.BASE_PATH.format(language_solutions[language]['expected_result'])
+                    expected_result_content = self.convert_md_file(expected_result_path).html_string
+
                     hint_path = self.BASE_PATH.format(language_solutions[language]['hints'])
                     hint_content = self.convert_md_file(hint_path).html_string
 
@@ -55,6 +58,7 @@ def load(self):
                     solution_content = self.convert_md_file(solution_path).html_string
 
                     solution = ProgrammingExerciseLanguageImplementation.objects.create(
+                        expected_result=expected_result_content,
                         hints=hint_content,
                         solution=solution_content,
                         language=language_object,
diff --git a/csunplugged/topics/migrations/0028_programmingexerciselanguageimplementation_expected_result.py b/csunplugged/topics/migrations/0028_programmingexerciselanguageimplementation_expected_result.py
new file mode 100644
--- /dev/null
+++ b/csunplugged/topics/migrations/0028_programmingexerciselanguageimplementation_expected_result.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2017-03-16 00:59
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('topics', '0027_auto_20170316_0033'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='programmingexerciselanguageimplementation',
+            name='expected_result',
+            field=models.TextField(default=''),
+            preserve_default=False,
+        ),
+    ]
diff --git a/csunplugged/topics/models.py b/csunplugged/topics/models.py
--- a/csunplugged/topics/models.py
+++ b/csunplugged/topics/models.py
@@ -175,6 +175,7 @@ class ProgrammingExerciseLanguageImplementation(models.Model):
         on_delete=models.CASCADE,
         related_name='implementations'
     )
+    expected_result = models.TextField()
     hints = models.TextField()
     solution = models.TextField()
 


Test patch: