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

Issue:
Remove feedbackskjema dashboard
**Describe the bug**
When clicking "Fjern" in the "Tilbakemeldingsskjema" tab, the site redirects to 404 Error: Page not found

**To Reproduce**
Steps to reproduce the behavior:
1. Go to any event in the dashboard with a registered feeback - form. 
2. Click on "Tilbakemeldingsskjema"
3. Try to remove the form using the "Fjern" button
4. See error

**Expected behavior**
When clicking the "Fjern" button, I expect that the previously selected feedback form is removed, so that I can select a new one. 

**Desktop (please complete the following information):**
 - OS: Linux Kubuntu
 - Browser Firefox 
 - Version 71.0

**Additional context**
Can be solved by using the Adminpanel, but this is much more time-consuming. 



Discussion:

Resolving patch:
diff --git a/apps/events/dashboard/views.py b/apps/events/dashboard/views.py
--- a/apps/events/dashboard/views.py
+++ b/apps/events/dashboard/views.py
@@ -148,7 +148,6 @@ def form_valid(self, form):
 class RemoveCompanyEventView(DashboardObjectPermissionMixin, DeleteView):
     model = CompanyEvent
     permission_required = "events.add_attendanceevent"
-    pk_url_kwarg = "event_id"
 
     def get_success_url(self):
         return reverse(
@@ -177,7 +176,6 @@ def form_valid(self, form):
 class RemoveFeedbackRelationView(DashboardObjectPermissionMixin, DeleteView):
     model = FeedbackRelation
     permission_required = "events.add_attendanceevent"
-    pk_url_kwarg = "event_id"
 
     def get_success_url(self):
         return reverse(


Test patch:
Repository: dotkom/onlineweb4

Issue:
Updated membership "fails" for users with membership > 1 year old
Currrently the new expiration date for memberships is determined like this:

``` python
new_expiration_date = datetime.date(membership.expiration_date.year + 1, 9, 16)
```

Source: https://github.com/dotKom/onlineweb4/blob/develop/apps/approval/views.py#L86

If a user has membership that expired in 2014, they will get 2015 as the new date, which is still an expired date.



Discussion:
Could the new date simply be the current year, or would that fuck something up?

Me updating my thingy August 2016:
New date:
Septembre 2016.
So yes, it would.

Fixed in #1513

Still happens. User had bachelor degree 2012 - 2015, and extended their membership. Membership expiration date was sat to september 2016. Had to send a new request to set the date to 2017.

Me and @oleast took a quick gander at this one, and we _think_ it should just be changing [this](https://github.com/dotkom/onlineweb4/blob/972069a2ec64b6050d721ca619c66904be54eb86/apps/approval/views.py#L89) check to instead go based on 1st of July.

Resolving patch:
diff --git a/apps/approval/views.py b/apps/approval/views.py
--- a/apps/approval/views.py
+++ b/apps/approval/views.py
@@ -11,7 +11,7 @@
 
 from apps.approval.forms import FieldOfStudyApplicationForm
 from apps.approval.models import MembershipApproval
-from apps.authentication.models import Membership, get_length_of_membership
+from apps.authentication.models import get_length_of_membership
 
 
 @login_required
@@ -116,9 +116,14 @@ def create_membership_application(request):
             )
             return redirect("profiles_active", active_tab="membership")
 
-        # Extend length of membership by 1 year
-        membership = Membership.objects.get(username=request.user.ntnu_username)
-        new_expiration_date = datetime.date(membership.expiration_date.year + 1, 9, 16)
+        # Grant membership until 16th of September this year if the request was sent previous to 1st of July,
+        # or until 16th of September next year if the request was sent after 1st of July
+        if timezone.now().date().month < 7:
+            new_expiration_date = datetime.date(timezone.now().year, 9, 16)
+        else:
+            new_expiration_date = datetime.date(
+                timezone.now().year, 9, 16
+            ) + datetime.timedelta(days=365)
 
         application = MembershipApproval(
             applicant=request.user,


Test patch:
Repository: dotkom/onlineweb4

Issue:
Cant delete mails through REST API endpoints
The endpoint to remove mails are fucked :)


Discussion:

Resolving patch:
diff --git a/apps/authentication/api/views.py b/apps/authentication/api/views.py
--- a/apps/authentication/api/views.py
+++ b/apps/authentication/api/views.py
@@ -105,6 +105,7 @@ def destroy(self, request, *args, **kwargs):
                 },
                 status=status.HTTP_400_BAD_REQUEST,
             )
+        super().destroy(request, *args, **kwargs)
 
 
 class PositionViewSet(MultiSerializerMixin, viewsets.ModelViewSet):


Test patch:
Repository: dotkom/onlineweb4

Issue:
"Vis påmeldte" shows list of both attending and waiting list
**Describe the bug**
A clear and concise description of what the bug is.

"Vis påmeldte" on arrangements shows both attending people and people on the waiting list. This can lead to misunderstandings because people on the waiting list might think they're attending the arrangement.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to any arrangement
2. Click on 'Vis påmeldte'
3. Scroll down to bottom of list
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

I expect the "vis påmeldte" modal to show only attending people.


Discussion:

Resolving patch:
diff --git a/apps/events/api/views.py b/apps/events/api/views.py
--- a/apps/events/api/views.py
+++ b/apps/events/api/views.py
@@ -142,10 +142,21 @@ def unregister(self, request, pk=None):
     )
     def public_attendees(self, request, pk=None):
         attendance_event: AttendanceEvent = self.get_object()
-        attendees = (
-            attendance_event.attending_attendees_qs | attendance_event.waitlist_qs
-        )
-        attendees = attendees.order_by("-show_as_attending_event", "timestamp")
+        attendees = attendance_event.attending_attendees_qs
+        serializer = self.get_serializer(attendees, many=True)
+
+        return Response(data=serializer.data, status=status.HTTP_200_OK)
+
+    @action(
+        detail=True,
+        methods=["GET"],
+        permission_classes=(permissions.IsAuthenticated,),
+        serializer_class=PublicAttendeeSerializer,
+        url_path="public-on-waitlist",
+    )
+    def public_on_waitlist(self, request, pk=None):
+        attendance_event: AttendanceEvent = self.get_object()
+        attendees = attendance_event.waitlist_qs
         serializer = self.get_serializer(attendees, many=True)
 
         return Response(data=serializer.data, status=status.HTTP_200_OK)


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
timesince vs naturaltime
A few templates are using something like `{{some_datetime|timesince}} ago` to format elapsed times. This can be difficult to translate (and currently isn't marked for translation), since the equivalent expression in other languages may also require a prefix.

`django.contrib.humanize` provides the [`naturaltime` filter](https://docs.djangoproject.com/en/dev/ref/contrib/humanize/#naturaltime), which generates the same (localised) result. However, this introduces a new dependency. Would it be acceptable?

I'm enclosing a proposed patch. Please let me know if I can submit a PR.

timesince vs naturaltime
A few templates are using something like `{{some_datetime|timesince}} ago` to format elapsed times. This can be difficult to translate (and currently isn't marked for translation), since the equivalent expression in other languages may also require a prefix.

`django.contrib.humanize` provides the [`naturaltime` filter](https://docs.djangoproject.com/en/dev/ref/contrib/humanize/#naturaltime), which generates the same (localised) result. However, this introduces a new dependency. Would it be acceptable?

I'm enclosing a proposed patch. Please let me know if I can submit a PR.



Discussion:

Resolving patch:
diff --git a/quicktest.py b/quicktest.py
--- a/quicktest.py
+++ b/quicktest.py
@@ -11,7 +11,7 @@ class QuickDjangoTest(object):
 
         >>> QuickDjangoTest('app1', 'app2')
 
-    Based on a script published by Lukasz Dziedzia at: 
+    Based on a script published by Lukasz Dziedzia at:
     http://stackoverflow.com/questions/3841725/how-to-launch-tests-for-django-reusable-app
     """
     DIRNAME = os.path.dirname(__file__)
@@ -22,6 +22,7 @@ class QuickDjangoTest(object):
         'django.contrib.admin',
         'django.contrib.staticfiles',
         'django.contrib.messages',
+        'django.contrib.humanize',
         'bootstrapform',
     )
 


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
AttributeError using django1.8+
This commit:   https://github.com/rossp/django-helpdesk/commit/eef2a66f23397b69cc0350d0c34595d3a5413b46
causes an error in django 1.8+ (because _meta.module_name alias was removed)

PR with patch to follow...

AttributeError at /helpdesk/system_settings/
'Options' object has no attribute 'module_name'
Error during template rendering
In template /Users/Joseph/Projects/VirtualEnv/ccl_bchydro/lib/python3.4/site-packages/helpdesk/templates/helpdesk/system_settings.html, error at line 17 

```
<li><a href=' {% url 'changelist'|user_admin_url %} '>{% trans "Maintain Users" %}</a></li>
```

/helpdesk/templatetags/user_admin_url.py in user_admin_url:

```
return 'admin:%s_%s_%s' % (
                    user._meta.app_label, user._meta.module_name.lower(),
            action)
```



Discussion:

Resolving patch:
diff --git a/helpdesk/templatetags/user_admin_url.py b/helpdesk/templatetags/user_admin_url.py
--- a/helpdesk/templatetags/user_admin_url.py
+++ b/helpdesk/templatetags/user_admin_url.py
@@ -14,8 +14,13 @@
 
 def user_admin_url(action):
     user = get_user_model()
+    try:
+        model_name = user._meta.module_name.lower()
+    except AttributeError:  # module_name alias removed in django 1.8
+        model_name = user._meta.model_name.lower()
+
     return 'admin:%s_%s_%s' % (
-        user._meta.app_label, user._meta.module_name.lower(),
+        user._meta.app_label, model_name,
         action)
 
 register = template.Library()


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
User setting login_veiw_ticketlist always returns False
Issue in views/public.py.  Call to getattr() doesn't work, since usersettings.settings are stored in a dict.  Use 'usersettings.settings.get('login_view_ticketlist', False)'  instead. #



Discussion:

Resolving patch:
diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py
--- a/helpdesk/views/public.py
+++ b/helpdesk/views/public.py
@@ -25,7 +25,7 @@ def homepage(request):
 
     if (request.user.is_staff or (request.user.is_authenticated() and helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE)):
         try:
-            if getattr(request.user.usersettings.settings, 'login_view_ticketlist', False):
+            if request.user.usersettings.settings.get('login_view_ticketlist', False):
                 return HttpResponseRedirect(reverse('helpdesk_list'))
             else:
                 return HttpResponseRedirect(reverse('helpdesk_dashboard'))


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
The documentation's description of TEMPLATE_CONTEXT_PROCESSORS is out-of-date for Django >= 1.8
In the documentation [settings section](docs/settings.rst), the usage of TEMPLATE_CONTEXT_PROCESSORS is no longer current as of Django 1.8 ([1.7](https://docs.djangoproject.com/en/1.7/ref/settings/#template-context-processors), [1.9](https://docs.djangoproject.com/en/1.9/ref/settings/#template-context-processors), [upgrade guide](https://docs.djangoproject.com/en/1.9/ref/templates/upgrading/)) and the location of the context_processors module has moved. It would be nice to clarify to users the appropriate method for their version.



Discussion:
Hi. Would this PR clarify the situation?
https://github.com/rossp/django-helpdesk/compare/master...mrkiwi-nz:patch-2#diff-f47f8ca652dac550c8bc9d449ca0d253

I'd think so, thanks!

@mrkiwi-nz Your PR shows no differences, however https://github.com/django-helpdesk/django-helpdesk/blob/master/docs/settings.rst still shows the deprecated use of `TEMPLATE_CONTEXT_PROCESSORS`. Could you open a PR with the proper branch please? 


Resolving patch:
diff --git a/quicktest.py b/quicktest.py
--- a/quicktest.py
+++ b/quicktest.py
@@ -38,6 +38,27 @@ class QuickDjangoTest(object):
         'django.middleware.clickjacking.XFrameOptionsMiddleware',
     ]
 
+    TEMPLATES = [
+        {
+            'BACKEND': 'django.template.backends.django.DjangoTemplates',
+            'APP_DIRS': True,
+            'OPTIONS': {
+                'context_processors': (
+                    # Defaults:
+                    "django.contrib.auth.context_processors.auth",
+                    "django.template.context_processors.debug",
+                    "django.template.context_processors.i18n",
+                    "django.template.context_processors.media",
+                    "django.template.context_processors.static",
+                    "django.template.context_processors.tz",
+                    "django.contrib.messages.context_processors.messages",
+                    # Our extra:
+                    "django.template.context_processors.request",
+                ),
+            },
+        },
+    ]
+
     def __init__(self, *args, **kwargs):
         self.apps = args
         # Get the version of the test suite
@@ -91,7 +112,8 @@ def _new_tests(self):
             INSTALLED_APPS = self.INSTALLED_APPS + self.apps,
             MIDDLEWARE_CLASSES = self.MIDDLEWARE_CLASSES,
             ROOT_URLCONF = self.apps[0] + '.urls',
-            STATIC_URL = '/static/'
+            STATIC_URL = '/static/',
+            TEMPLATES = self.TEMPLATES,
         )
 
         # compatibility with django 1.8 downwards


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
Unable to create new Queue because of multiple content_type
`get() returned more than one ContentType -- it returned 4!`

This can be replicated if you deploy django-helpdesk by adding the source to an existing Django Project which possibly has other apps with one or more models named queue.

In my case:
select * from django_content_type where model = 'queue'; returns 4 records.

Trace this to ....../helpdesk/models.py line 323 `content_type=ContentType.objects.get(model="queue"),`

**My Proposed Solution**
Replace line 323 with content_type = ContentType.objects.get_for_model(self.__class__)


Discussion:
Thanks for the bug report and especially for the proposed fix! Although I'm currently traveling and still not yet able to implement immediately, I should be able to examine this within 24hours, and appreciate your patience on this. 

Resolving patch:
diff --git a/helpdesk/models.py b/helpdesk/models.py
--- a/helpdesk/models.py
+++ b/helpdesk/models.py
@@ -320,7 +320,7 @@ def save(self, *args, **kwargs):
 
             Permission.objects.create(
                 name=_("Permission for queue: ") + self.title,
-                content_type=ContentType.objects.get(model="queue"),
+                content_type=ContentType.objects.get_for_model(self.__class__),
                 codename=basename,
             )
 


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
Admin page for follow ups doesn't show enough information
What happens:
The admin page only shows the **str** of the followup ;
![helpdesk](https://cloud.githubusercontent.com/assets/17169553/16551313/407f26ee-420b-11e6-9e35-a8d99f8f37db.png)
This makes it almost impossible to find a particular followup amongst the list

What should happen:
These fields should be shown: 
[ticket.ticket_for_url], [ticket.title?], [title], [date], length-limited abstract of [comment], [new_status]



Discussion:
For most follow-ups, I wouldn't expect the Admin needs to be used much if at all. I would strongly recommend using the `django-helpdesk` staff views. I'm happy to merge a pull request for this, though.

Good point - i'll see if the staff views cover my use-case. D

I've looked at the use-case, and some issues with tickets (actually followups) cannot be fixed via the staff views, for example a helpdesk tech adds a followup to a ticket and attaches a screenshot of the error, however he accidentally picks the wrong image file and rick-rolls the entire helpdesk team.
AFAIK you can't remove an attached file?
You can fix this via the admin interface, but to find the right followup via a list of followups that all have the same string as their clickable link is hard.
This works;
select followup_id, file from helpdesk_attachment where file like '%rickroll%';
... then use the admin to get to that followup and delete the attachment.

If i submitted a PR that expands the columns in the admin, and adds a search field in tickets and followups, would this be accepted? 

As far as I can see, making the admin more usable has the downside of encouraging some users to bypass the non-admin interface, which AFAIK contains some important code paths, and this may lead to more tickets being submitted to make the admin interface as functional as the non-admin interface.
For sites that don't use the admin interface, I can't see this having any drawbacks.
For sites that sometimes use the admin interface, I can see this being very valuable.

Thanks for following up. I think a PR to improve `contrib.admin` support would be welcomed. Personally I see no issue making it more useful as a _system administration_ tool. In most scenarios the UX for ticket management via the admin just isn't that great so users aren't likely to rely on it for day to day use.

I concur with @rossp , improvements to system administration is welcome!


Resolving patch:
diff --git a/helpdesk/admin.py b/helpdesk/admin.py
--- a/helpdesk/admin.py
+++ b/helpdesk/admin.py
@@ -40,6 +40,12 @@ class AttachmentInline(admin.StackedInline):
 @admin.register(FollowUp)
 class FollowUpAdmin(admin.ModelAdmin):
     inlines = [TicketChangeInline, AttachmentInline]
+    list_display = ('ticket_get_ticket_for_url', 'title', 'date', 'ticket', 'user', 'new_status')
+    list_filter = ('user', 'date', 'new_status')
+
+    def ticket_get_ticket_for_url(self, obj):
+        return obj.ticket.ticket_for_url
+    ticket_get_ticket_for_url.short_description = _('Slug')
 
 
 @admin.register(KBItem)


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
missing __init__.py python2
```
make rundemo2
....

demodesk migrate --noinput
Traceback (most recent call last):
  File "/home/JSSC/.virtualenvs/django-helpdesk/bin/demodesk", line 11, in <module>
    load_entry_point('django-helpdesk-demodesk', 'console_scripts', 'demodesk')()
  File "/home/JSSC/.virtualenvs/django-helpdesk/lib/python2.7/site-packages/pkg_resources/__init__.py", line 570, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/JSSC/.virtualenvs/django-helpdesk/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2751, in load_entry_point
    return ep.load()
  File "/home/JSSC/.virtualenvs/django-helpdesk/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2405, in load
    return self.resolve()
  File "/home/JSSC/.virtualenvs/django-helpdesk/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2411, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named demodesk.manage
make: *** [Makefile:101: demo2] Error 1

touch demo/demodesk/__init__.py

Now it works!
```



Discussion:

Resolving patch:
diff --git a/demo/demodesk/__init__.py b/demo/demodesk/__init__.py
new file mode 100644


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
systems_settings url should only be available to staff users
currently, the template starts to render before it fails if the user is not logged in.


Discussion:

Resolving patch:
diff --git a/helpdesk/urls.py b/helpdesk/urls.py
--- a/helpdesk/urls.py
+++ b/helpdesk/urls.py
@@ -222,6 +222,6 @@ def get_context_data(self, **kwargs):
         name='help_context'),
 
     url(r'^system_settings/$',
-        DirectTemplateView.as_view(template_name='helpdesk/system_settings.html'),
+        login_required(DirectTemplateView.as_view(template_name='helpdesk/system_settings.html')),
         name='system_settings'),
 ]


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
develop branch: resolved tickets should not be included in dashboard unassigned tickets list
https://github.com/django-helpdesk/django-helpdesk/blob/4d9a5f2c55022459903f37df03653121fd6eb004/helpdesk/views/staff.py#L159


Discussion:

Resolving patch:
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py
--- a/helpdesk/views/staff.py
+++ b/helpdesk/views/staff.py
@@ -138,11 +138,13 @@ def dashboard(request):
     showing ticket counts by queue/status, and a list of unassigned tickets
     with options for them to 'Take' ownership of said tickets.
     """
+    active_tickets = Ticket.objects.select_related('queue').exclude(
+        status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS],
+    )
+
     # open & reopened tickets, assigned to current user
-    tickets = Ticket.objects.select_related('queue').filter(
+    tickets = active_tickets.filter(
         assigned_to=request.user,
-    ).exclude(
-        status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS],
     )
 
     # closed & resolved tickets, assigned to current user
@@ -152,11 +154,9 @@ def dashboard(request):
 
     user_queues = _get_user_queues(request.user)
 
-    unassigned_tickets = Ticket.objects.select_related('queue').filter(
+    unassigned_tickets = active_tickets.filter(
         assigned_to__isnull=True,
         queue__in=user_queues
-    ).exclude(
-        status=Ticket.CLOSED_STATUS,
     )
 
     # all tickets, reported by current user


Test patch:
Repository: django-helpdesk/django-helpdesk

Issue:
Editing form in public queue
**Describe the bug**

When ticket submitted to public Queue from unregistered user, the ticket is correctly created, but user can not add any comments in later conversation - if not registered.

**To Reproduce**
Go to http://helpdesk.opengeolabs.cz/view/?ticket=open-source-gis-67&email=jachym.cepicky@gmail.com&key=dc5d12e7-c3a5-42eb-8c89-a0adf507dddd 

you have the unique URL -> you should be able to edit ticket details. Yet, you can not.

**Expected behavior**
Editing form pops up



Discussion:

Resolving patch:
diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py
--- a/helpdesk/views/public.py
+++ b/helpdesk/views/public.py
@@ -181,6 +181,8 @@ def view_ticket(request):
         redirect_url = reverse('helpdesk:view', args=[ticket_id])
 
     return render(request, 'helpdesk/public_view_ticket.html', {
+        'key': key,
+        'mail': email,
         'ticket': ticket,
         'helpdesk_settings': helpdesk_settings,
         'next': redirect_url,
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py
--- a/helpdesk/views/staff.py
+++ b/helpdesk/views/staff.py
@@ -451,15 +451,32 @@ def subscribe_staff_member_to_ticket(ticket, user, email=''):
 
 
 def update_ticket(request, ticket_id, public=False):
+
+    ticket = None
+
     if not (public or (
             request.user.is_authenticated and
             request.user.is_active and (
                 is_helpdesk_staff(request.user) or
                 helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))):
-        return HttpResponseRedirect('%s?next=%s' %
-                                    (reverse('helpdesk:login'), request.path))
 
-    ticket = get_object_or_404(Ticket, id=ticket_id)
+        key = request.POST.get('key')
+        email = request.POST.get('mail')
+
+        if key and email:
+            ticket = Ticket.objects.get(
+                id=ticket_id,
+                submitter_email__iexact=email,
+                secret_key__iexact=key
+            )
+
+        if not ticket:
+            return HttpResponseRedirect(
+                '%s?next=%s' % (reverse('helpdesk:login'), request.path)
+            )
+
+    if not ticket:
+        ticket = get_object_or_404(Ticket, id=ticket_id)
 
     date_re = re.compile(
         r'(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<year>\d{4})$'


Test patch: