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

Issue:
List of Superusers
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Description

Making it possible to sort after lvel under /admin/users/ so admins shows up and you get a proper overview. 

Or: Make a list of users with superuser access to the website

### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->



Discussion:

Resolving patch:
diff --git a/src/members/models.py b/src/members/models.py
--- a/src/members/models.py
+++ b/src/members/models.py
@@ -191,7 +191,7 @@ class Member(SimpleEmailConfirmationUserMixin, AbstractUser):
 
     def __str__(self) -> str:
         if self.first_name and self.last_name:
-            return '%s %s' % (self.first_name, self.last_name)
+            return self.get_full_name()
         else:
             return self.username
 
diff --git a/src/members/signals.py b/src/members/signals.py
--- a/src/members/signals.py
+++ b/src/members/signals.py
@@ -12,7 +12,7 @@
 
 @receiver(unconfirmed_email_created, dispatch_uid='send_email_confirmation')
 def send_confirmation_email(sender, email, user=None, **kwargs):
-    user = user or sender
+    user = user or sender  # TODO: use user.send_email
     if user is not None:
         context = {
             'email': email,
diff --git a/src/members/wagtail_hooks.py b/src/members/wagtail_hooks.py
--- a/src/members/wagtail_hooks.py
+++ b/src/members/wagtail_hooks.py
@@ -1,12 +1,14 @@
 from django.forms import CheckboxSelectMultiple
+from django.template import loader
+from django.utils.translation import ugettext_lazy as _
 from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup, \
     modeladmin_register
 from wagtail.contrib.modeladmin.views import EditView, CreateView
 from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList, \
     FieldPanel
+from wagtail.wagtailcore import hooks
 
-from members.models import StudyProgram, Section
-from django.utils.translation import ugettext_lazy as _
+from members.models import StudyProgram, Section, Member
 
 
 class StudyProgramEditHandler:
@@ -90,3 +92,22 @@ class EducationAdminGroup(ModelAdminGroup):
 
 
 modeladmin_register(EducationAdminGroup)
+
+
+class SuperUserPanel(object):
+    order = 1000
+
+    def __init__(self, request):
+        self.request = request
+
+    def render(self):
+        c = {
+            'supers': Member.objects.filter(is_superuser=True),
+            'user': self.request.user
+        }
+        return loader.get_template('members/admin_panel.html').render(c)
+
+
+@hooks.register('construct_homepage_panels')
+def add_super_user_panel(request, panels):
+    return panels.append(SuperUserPanel(request))


Test patch:
Repository: UTNkar/moore

Issue:
Raw HTML content type
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Description
There is currently no content type for raw HTML that can be used for the Jexpo. A special content type could be created for Jexpo as it works right now but since the way Jexpo is initialized can change (according to themselves), they recommend using a raw HTML. 

There should be a content type for raw HTML.

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->

Forms are missing form introduction.
### Description

Creating a new form in Wagtail lets you specify an introduction to the form, which isn't displayed.



Discussion:

Resolving patch:
diff --git a/src/home/models/web_page.py b/src/home/models/web_page.py
--- a/src/home/models/web_page.py
+++ b/src/home/models/web_page.py
@@ -5,6 +5,7 @@
         TabbedInterface, ObjectList
 from wagtail.core.fields import StreamField
 from wagtail.core.models import Page
+from wagtail.core.blocks import RawHTMLBlock
 from blocks.models import WAGTAIL_STATIC_BLOCKTYPES
 from google.models import GoogleFormBlock, GoogleDriveBlock, \
     GoogleCalendarBlock
@@ -24,6 +25,7 @@ class WebPage(Page):
             ('google_drive', GoogleDriveBlock()),
             ('google_form', GoogleFormBlock()),
             ('news', LatestNewsBlock()),
+            ('html', RawHTMLBlock(group="Basic")),
         ],
         blank=True,
     )
@@ -33,6 +35,7 @@ class WebPage(Page):
             ('google_drive', GoogleDriveBlock()),
             ('google_form', GoogleFormBlock()),
             ('news', LatestNewsBlock()),
+            ('html', RawHTMLBlock(group="Basic")),
         ],
         blank=True,
     )


Test patch:
Repository: UTNkar/moore

Issue:
Fix navigation bar on laptop screens
On utn.se there are many items in the menu. On laptop screens (1366x768 pixels) the navigation bar splits into two rows which makes it unusable. To solve this, make the navigation bar scrollable if it's width gets to long. That way it will still be usable. This is done by setting `scroll: auto` on the container.

However, the navigation bar is built with the materialize library which adds a lot of css to the navigation bar. To get around this, we have to use `<div>` instead of `<nav>` and change the name of the class for the navigation bar


Discussion:

Resolving patch:
diff --git a/src/branding/templatetags/branding_tags.py b/src/branding/templatetags/branding_tags.py
--- a/src/branding/templatetags/branding_tags.py
+++ b/src/branding/templatetags/branding_tags.py
@@ -23,10 +23,19 @@ def structure_header(context, logo_color=''):
     logos = Logo.objects.exclude(belongs_to=site).all()
     committees = logos.filter(category='committee')
     sections = logos.filter(category='section')
+
+    committees_left = committees[:len(committees) // 2]
+    committees_right = committees[len(committees) // 2:]
+
+    sections_left = sections[:len(sections) // 2]
+    sections_right = sections[len(sections) // 2:]
+
     return {
-        'committees': committees,
-        'sections': sections,
         'color': logo_color,
+        'committees_left': committees_left,
+        'committees_right': committees_right,
+        'sections_left': sections_left,
+        'sections_right': sections_right,
     }
 
 


Test patch:
Repository: UTNkar/moore

Issue:
Fix cookies for Utnarm
Utnarm recently switched to utnarm.se instead of utnarm.utn.se. This lead to that you can’t sign in to utnarm.se. Per default, moore uses utn.se as cookie domain and since utnarm.se is a different top level domain the cookies can’t be used. 

We need to dynamically add utnarm.se as a cookie domain. This python package might be useful https://github.com/ViktorStiskala/django-shared-session


Discussion:

Resolving patch:
diff --git a/src/moore/settings/production.py b/src/moore/settings/production.py
--- a/src/moore/settings/production.py
+++ b/src/moore/settings/production.py
@@ -106,8 +106,6 @@
 
 CSRF_COOKIE_SECURE = True
 
-SESSION_COOKIE_DOMAIN = '.utn.se'
-
 SESSION_COOKIE_SECURE = True
 
 MELOS_URL = os.environ.get('MELOS_URL')


Test patch:
Repository: UTNkar/moore

Issue:
Applicant username should be switched to the users real name on applications
Currently when looking att all applications (`/admin/involvement/application/`) you see the username of the applicant. It should be the persons real name instead since the username does not always give you that much information about who the applicant is.



Discussion:

Resolving patch:
diff --git a/src/involvement/models/position.py b/src/involvement/models/position.py
--- a/src/involvement/models/position.py
+++ b/src/involvement/models/position.py
@@ -66,6 +66,23 @@ def __str__(self) -> str:
         else:
             return "%s %s" % (self.role.name, self.term_from.year)
 
+    @property
+    def long_name(self):
+        """
+        Return the long name of this position.
+
+        The long name contains the team_names that the positions role
+        is a part of
+        """
+        return '%(position)s %(separator)s %(teams)s' % {
+                'position': str(self),
+                'separator': _('in'),
+                'teams': self.role.team_names
+            }
+    # fget is a python thing that is needed since long_name is a property
+    long_name.fget.short_description = _('Position')
+    long_name.fget.admin_order_field = 'position'
+
     @property
     def appointed_applications(self):
         Application = apps.get_model('involvement', 'Application')
diff --git a/src/involvement/wagtail_hooks.py b/src/involvement/wagtail_hooks.py
--- a/src/involvement/wagtail_hooks.py
+++ b/src/involvement/wagtail_hooks.py
@@ -211,7 +211,7 @@ class PositionAdmin(ModelAdmin):
     menu_label = _('Positions')
     menu_icon = 'fa-address-card'
     menu_order = 300
-    list_display = ('role', 'appointments', 'term_from', 'term_to')
+    list_display = ('long_name', 'appointments', 'term_from', 'term_to')
     search_fields = ('role__teams__name_en', 'role__teams__name_sv',
                      'role__name_en', 'role__name_sv', 'comment_en',
                      'comment_sv')
@@ -242,7 +242,7 @@ class ApplicationAdmin(ModelAdmin):
     menu_label = _('Applications')
     menu_icon = 'mail'
     menu_order = 400
-    list_display = ('role', 'position', 'applicant', 'status')
+    list_display = ('position_long_name', 'applicant_name', 'status')
     list_filter = ('position__role__teams', 'status')
     search_fields = (
         'position__role__teams__name_en', 'position__role__teams__name_sv',
@@ -271,8 +271,16 @@ def get_queryset(self, request):
                 qs = qs.order_by(*ordering)
             return qs
 
-    def role(self, obj):
-        return obj.position.role
+    def position_long_name(self, obj):
+        return obj.position.long_name
+    position_long_name.short_description = _('Position')
+    position_long_name.admin_order_field = 'position'
+
+    def applicant_name(self, obj):
+        """Used by list_display since obj contains foreign keys."""
+        return obj.applicant.name
+    applicant_name.admin_order_field = 'applicant__name'
+    applicant_name.short_description = _('Name')
 
 
 class ContactCardAdmin(ModelAdmin):


Test patch:
Repository: UTNkar/moore

Issue:
Events: Can't mark tickets as paid for.
Expose the payment status field in the admin view.


Discussion:

Resolving patch:
diff --git a/src/events/views/admin_assign.py b/src/events/views/admin_assign.py
--- a/src/events/views/admin_assign.py
+++ b/src/events/views/admin_assign.py
@@ -15,7 +15,7 @@ def random_assignment(event, num_to_assign, priority):
     random_applications = random_applications[:num_to_assign]
 
     unassigned_tickets = Ticket.objects.filter(
-        event=event, owner=None).order_by('ticket_number')
+        event=event, owner=None).order_by('ticket_number')[:num_to_assign]
 
     for ticket, application in zip(unassigned_tickets, random_applications):
         # assign them
diff --git a/src/events/wagtail_hooks.py b/src/events/wagtail_hooks.py
--- a/src/events/wagtail_hooks.py
+++ b/src/events/wagtail_hooks.py
@@ -178,7 +178,8 @@ class EventApplicationAdmin(ModelAdmin):
                     'event_applicant_email',
                     'event',
                     'ticket']
-    list_export = ('event', 'event_applicant', 'ticket__ticket_number')
+    list_export = ('event', 'event_applicant',
+                   'event_applicant_email', 'event_applicant_ticket_number')
     list_filter = ('event',)
     search_fields = ('event_applicant__person_nr', 'event_applicant__email')
     menu_order = 400
@@ -198,6 +199,12 @@ def event_applicant_email(self, obj):
         else:
             return "No email"
 
+    def event_applicant_ticket_number(self, obj):
+        if obj.ticket:
+            return str(obj.ticket.ticket_number)
+        else:
+            return "-"
+
 
 class EventAdminGroup(ModelAdminGroup):
     menu_label = _('Events')
diff --git a/src/members/models/member.py b/src/members/models/member.py
--- a/src/members/models/member.py
+++ b/src/members/models/member.py
@@ -251,7 +251,12 @@ class Meta:
         verbose_name_plural = _('users')
 
     def __str__(self) -> str:
-        return self.username
+        return "{0} - {1} - {2} - {3}".format(
+            self.username,
+            self.email,
+            self.name,
+            self.person_nr
+        )
 
     @property
     def teams(self):


Test patch:
Repository: UTNkar/moore

Issue:
Events: Can't mark tickets as paid for.
Expose the payment status field in the admin view.


Discussion:

Resolving patch:
diff --git a/src/events/views/admin_assign.py b/src/events/views/admin_assign.py
--- a/src/events/views/admin_assign.py
+++ b/src/events/views/admin_assign.py
@@ -15,7 +15,7 @@ def random_assignment(event, num_to_assign, priority):
     random_applications = random_applications[:num_to_assign]
 
     unassigned_tickets = Ticket.objects.filter(
-        event=event, owner=None).order_by('ticket_number')
+        event=event, owner=None).order_by('ticket_number')[:num_to_assign]
 
     for ticket, application in zip(unassigned_tickets, random_applications):
         # assign them
@@ -67,9 +67,8 @@ def admin_assign(request, pos_id=None):
                 assignments = random_assignment(
                     event, num_to_randomize, priority)
 
-                disabled = False
                 if num_to_randomize > 0 and assignments.count() > 0:
-                    disabled = True
+                    disabled = False
 
                 ticket_formset = formset(queryset=assignments)
             elif 'save' in request.POST:
diff --git a/src/events/wagtail_hooks.py b/src/events/wagtail_hooks.py
--- a/src/events/wagtail_hooks.py
+++ b/src/events/wagtail_hooks.py
@@ -178,7 +178,8 @@ class EventApplicationAdmin(ModelAdmin):
                     'event_applicant_email',
                     'event',
                     'ticket']
-    list_export = ('event', 'event_applicant', 'ticket__ticket_number')
+    list_export = ('event', 'event_applicant',
+                   'event_applicant_email', 'event_applicant_ticket_number')
     list_filter = ('event',)
     search_fields = ('event_applicant__person_nr', 'event_applicant__email')
     menu_order = 400
@@ -198,6 +199,12 @@ def event_applicant_email(self, obj):
         else:
             return "No email"
 
+    def event_applicant_ticket_number(self, obj):
+        if obj.ticket:
+            return str(obj.ticket.ticket_number)
+        else:
+            return "-"
+
 
 class EventAdminGroup(ModelAdminGroup):
     menu_label = _('Events')
diff --git a/src/members/models/member.py b/src/members/models/member.py
--- a/src/members/models/member.py
+++ b/src/members/models/member.py
@@ -251,7 +251,12 @@ class Meta:
         verbose_name_plural = _('users')
 
     def __str__(self) -> str:
-        return self.username
+        return "{0} - {1} - {2} - {3}".format(
+            self.username,
+            self.email,
+            self.name,
+            self.person_nr
+        )
 
     @property
     def teams(self):


Test patch:
Repository: UTNkar/moore

Issue:
No validation is perform when changing a user in the admin pages
When changing the phonenumber of a user in the admin pages, no validation is performed on the phonenumber. Validation is however performed on the registration form. Fix so that phonenumber is validated. 

There might be more fields that aren't validated


Discussion:

Resolving patch:
diff --git a/src/members/forms.py b/src/members/forms.py
--- a/src/members/forms.py
+++ b/src/members/forms.py
@@ -351,10 +351,9 @@ class CustomUserEditForm(UserEditForm):
         help_text=_('Person number using the YYYYMMDD-XXXX format.'),
         required=False
     )
-    phone_number = forms.CharField(
-        required=True,
-        label=_('Phone number'),
-    )
+
+    phone_number = PhoneNumberField()
+
     email = forms.EmailField(
         required=True,
         label=_('Email'),
@@ -419,10 +418,7 @@ class CustomUserCreationForm(UserCreationForm):
         required=True,
         label=_('Email'),
     )
-    phone_number = forms.CharField(
-        required=True,
-        label=_('Phone number'),
-    )
+    phone_number = PhoneNumberField()
     registration_year = forms.CharField(
         required=False,
         label=_('Registration year'),


Test patch:
Repository: UTNkar/moore

Issue:
Translations for footer_en missing in production
I noticed that in the settings the footer option is called footer_en. Seems like a translation has gone missing
![image](https://user-images.githubusercontent.com/19433606/228253442-09290b66-c344-417f-856a-19e97083a23a.png)



Discussion:

Resolving patch:
diff --git a/src/branding/models.py b/src/branding/models.py
--- a/src/branding/models.py
+++ b/src/branding/models.py
@@ -13,7 +13,7 @@
 @register_setting(icon='fa-window-minimize')
 class FooterSettings(BaseSetting):
     class Meta:
-        verbose_name = _('footer_en')   # quickfix
+        verbose_name = _('footer')   # quickfix
 
     footer_en = StreamField(
         [('column', blocks.StructBlock([


Test patch:
Repository: coala/coala

Issue:
`DocstyleDefinition`: Accept a single marker set also
Via the normal constructor or a class method.



Discussion:
Hi, I would like to work on this!

Hi, please accept the invitation to the org so I can assign you.


Resolving patch:
diff --git a/coalib/bearlib/languages/documentation/DocstyleDefinition.py b/coalib/bearlib/languages/documentation/DocstyleDefinition.py
--- a/coalib/bearlib/languages/documentation/DocstyleDefinition.py
+++ b/coalib/bearlib/languages/documentation/DocstyleDefinition.py
@@ -23,12 +23,19 @@ def __init__(self, language: str, docstyle: str, markers):
                          `"PYTHON3"`.
         :param docstyle: The case insensitive documentation style/tool used
                          to document code, e.g. `"default"` or `"doxygen"`.
-        :param markers:  An iterable of marker/delimiter string iterables that
+        :param markers:  An iterable of marker/delimiter string iterables
+                         or a single marker/delimiter string iterable that
                          identify a documentation comment. See `markers`
                          property for more details on markers.
         """
         self._language = language.lower()
         self._docstyle = docstyle.lower()
+
+        # Check and modify tuple if only one marker_set exists.
+        markers = tuple(markers)
+        if len(markers) == 3 and all(isinstance(x, str) for x in markers):
+            markers = (markers,)
+
         self._markers = tuple(tuple(marker_set) for marker_set in markers)
 
         # Check marker set dimensions.


Test patch:
diff --git a/coalib/tests/bearlib/languages/documentation/DocstyleDefinitionTest.py b/coalib/tests/bearlib/languages/documentation/DocstyleDefinitionTest.py
--- a/coalib/tests/bearlib/languages/documentation/DocstyleDefinitionTest.py
+++ b/coalib/tests/bearlib/languages/documentation/DocstyleDefinitionTest.py
@@ -46,6 +46,12 @@ def test_properties(self):
         self.assertEqual(uut.docstyle, "my-custom-tool")
         self.assertEqual(uut.markers, (("~~", "/~", "/~"), (">!", ">>", ">>")))
 
+        uut = DocstyleDefinition("Cpp", "doxygen", ("~~", "/~", "/~"))
+
+        self.assertEqual(uut.language, "cpp")
+        self.assertEqual(uut.docstyle, "doxygen")
+        self.assertEqual(uut.markers, (("~~", "/~", "/~"),))
+
     def test_load(self):
         # Test unregistered docstyle.
         with self.assertRaises(FileNotFoundError):
Repository: coala/coala

Issue:
Spelling error in ContextManager
`coalib/misc/ContextManagers.py` function `prepare_file` has a spelling error - `Can creates a temporary file ...` should be `Can create a temporary file ...`



Discussion:

Resolving patch:
diff --git a/coalib/misc/ContextManagers.py b/coalib/misc/ContextManagers.py
--- a/coalib/misc/ContextManagers.py
+++ b/coalib/misc/ContextManagers.py
@@ -171,7 +171,7 @@ def prepare_file(lines,
                  create_tempfile=True,
                  tempfile_kwargs={}):
     """
-    Can creates a temporary file (if filename is None) with the lines.
+    Can create a temporary file (if filename is None) with the lines.
     Can also add a trailing newline to each line specified if needed.
 
     :param lines:            The lines from the file. (list of strings)


Test patch:
Repository: coala/coala

Issue:
DefaultArgParser: Fix spelling mistake
Change analaysis on line 30 to analysis



Discussion:

Resolving patch:
diff --git a/coalib/parsing/DefaultArgParser.py b/coalib/parsing/DefaultArgParser.py
--- a/coalib/parsing/DefaultArgParser.py
+++ b/coalib/parsing/DefaultArgParser.py
@@ -27,7 +27,7 @@ def default_arg_parser(formatter_class=None):
         prog="coala",
         description="coala is a simple COde AnaLysis Application. Its goal "
                     "is to make static code analysis easy and convenient "
-                    "for all languages. coala uses bears, which are analaysis "
+                    "for all languages. coala uses bears, which are analysis "
                     "routines that can be combined arbitrarily.")
 
     arg_parser.add_argument('TARGETS',


Test patch:
Repository: coala/coala

Issue:
coala_delete_orig: Modify message
Modify message about `Couldn't delete... <filename>`

@sils1297 please suggest a better message.



Discussion:
remove the `...` for a start...

why the current message is bad? It says file `<filename>` couldn't be deleted :O

the ellipsis is there for no reason at all

ah I thought that's where the filename comes :O
Yeah just deleting the `...` suffices

Please, I would like to work on  this issue. I guess this would also include changes to the coalaDeleteOrigTest.py, which also contains the following lines

self.assertIn("Couldn't delete... file1", output)
self.assertIn("Couldn't delete... file2", output)

Hey @yland  I've invited you into our org, accept at github.com/coala-analyzer please so we can assign you.

Yes, test changes should be included in the very same commit.

Cool, seeing forward to a PR, ping us at https://gitter.im/coala-analyzer/coala if you need anyu assistance.


Resolving patch:
diff --git a/coalib/coala_delete_orig.py b/coalib/coala_delete_orig.py
--- a/coalib/coala_delete_orig.py
+++ b/coalib/coala_delete_orig.py
@@ -26,7 +26,7 @@ def main(log_printer=None, section: Section=None):
             os.remove(ofile)
         except OSError as oserror:
             not_deleted += 1
-            log_printer.warn("Couldn't delete... {}. {}".format(
+            log_printer.warn("Couldn't delete {}. {}".format(
                 os.path.relpath(ofile), oserror.strerror))
 
     if not_deleted:


Test patch: