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

Issue:
Domyślny tytuł wiadomości określić
https://fedrowanie.siecobywatelska.pl//listy/70

Należy napisać ```get_*_display```.


Discussion:
Obawiam się, że get_*_display może nie zadziałać. Trzeba będzie ``__str__`` nadpisać, albo zbudować właściwość (getter) z tym.

Resolving patch:
diff --git a/feder/letters/models.py b/feder/letters/models.py
--- a/feder/letters/models.py
+++ b/feder/letters/models.py
@@ -24,7 +24,6 @@
 from django_mailbox.signals import message_received
 from model_utils import Choices
 from model_utils.models import TimeStampedModel
-
 from feder.cases.models import Case
 from feder.institutions.models import Institution
 from .utils import email_wrapper, normalize_msg_id
@@ -114,8 +113,16 @@ def is_incoming(self):
     def is_outgoing(self):
         return bool(self.author_user_id)
 
+    def get_title(self):
+        if self.title and self.title.strip():
+            return self.title
+        return _("(no subject)")
+
     def __str__(self):
-        return self.title
+        return unicode(self.get_title())
+
+    def __unicode__(self):
+        return unicode(self.get_title())
 
     def get_absolute_url(self):
         return reverse('letters:details', kwargs={'pk': self.pk})


Test patch:
diff --git a/feder/letters/tests/test_model.py b/feder/letters/tests/test_model.py
--- a/feder/letters/tests/test_model.py
+++ b/feder/letters/tests/test_model.py
@@ -26,6 +26,11 @@ def test_is_outgoing(self):
         self.assertTrue(OutgoingLetterFactory().is_outgoing)
         self.assertFalse(IncomingLetterFactory().is_outgoing)
 
+    def test_default_subject(self):
+        incoming = IncomingLetterFactory()
+        incoming.title = ''
+        self.assertGreater(len(str(incoming)), 0)
+
     def test_author_for_user(self):
         obj = OutgoingLetterFactory()
         self.assertEqual(obj.author, obj.author_user)
Repository: watchdogpolska/feder

Issue:
Dopisać tooltip z metadanymi na LetterDetailView
![zaznaczenie_418](https://cloud.githubusercontent.com/assets/3618479/9562630/74158af4-4e71-11e5-8c87-566c046f1840.png)
http://giodo.gov.pl/1520221/id_art/8813/j/pl/



Discussion:

Resolving patch:
diff --git a/feder/letters/logs/models.py b/feder/letters/logs/models.py
--- a/feder/letters/logs/models.py
+++ b/feder/letters/logs/models.py
@@ -33,7 +33,7 @@ def with_logrecord_count(self):
 class EmailLog(TimeStampedModel):
     status = models.CharField(choices=STATUS, default=STATUS.unknown, max_length=20)
     case = models.ForeignKey(Case, max_length=_("Case"))
-    letter = models.ForeignKey(Letter, max_length=_("Letter"), null=True, blank=True)
+    letter = models.OneToOneField(Letter, max_length=_("Letter"), null=True, blank=True)
     email_id = models.CharField(verbose_name=_("Message-ID"), max_length=255)
     to = models.CharField(verbose_name=_("To"), max_length=255)
     objects = EmailQuerySet.as_manager()


Test patch:
Repository: watchdogpolska/feder

Issue:
brak zapytań w zakładce SQL w Django debug toolbar 
![image](https://user-images.githubusercontent.com/1237985/30499623-9559ddcc-9a5b-11e7-8225-0d7f6786960b.png)



Discussion:

Resolving patch:
diff --git a/config/settings/local.py b/config/settings/local.py
--- a/config/settings/local.py
+++ b/config/settings/local.py
@@ -40,7 +40,7 @@
 
 # django-debug-toolbar
 # ------------------------------------------------------------------------------
-MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+# MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
 INSTALLED_APPS += ('debug_toolbar', )
 
 INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',)


Test patch:
Repository: watchdogpolska/feder

Issue:
Autocomplete dla JST w MonitoringFilter



Discussion:
```django-teryt-tree``` ma odpowiednie widgety już chyba.

Resolving patch:
diff --git a/feder/monitorings/filters.py b/feder/monitorings/filters.py
--- a/feder/monitorings/filters.py
+++ b/feder/monitorings/filters.py
@@ -6,10 +6,22 @@
 from django.utils.translation import ugettext_lazy as _
 
 from .models import Monitoring
+from teryt_tree.dal_ext.filters import VoivodeshipFilter, CountyFilter, CommunityFilter
 
 
 class MonitoringFilter(django_filters.FilterSet):
     created = django_filters.DateRangeFilter(label=_("Creation date"))
+    voivodeship = VoivodeshipFilter(
+        widget=autocomplete.ModelSelect2(url='teryt:voivodeship-autocomplete')
+    )
+    county = CountyFilter(
+        widget=autocomplete.ModelSelect2(url='teryt:county-autocomplete',
+                                         forward=['voivodeship'])
+    )
+    community = CommunityFilter(
+        widget=autocomplete.ModelSelect2(url='teryt:community-autocomplete',
+                                         forward=['county'])
+    )
 
     def __init__(self, *args, **kwargs):
         super(MonitoringFilter, self).__init__(*args, **kwargs)
diff --git a/feder/monitorings/models.py b/feder/monitorings/models.py
--- a/feder/monitorings/models.py
+++ b/feder/monitorings/models.py
@@ -24,6 +24,9 @@ class MonitoringQuerySet(models.QuerySet):
     def with_case_count(self):
         return self.annotate(case_count=models.Count('case'))
 
+    def area(self, jst):
+        return self.filter(case__institution__jst__tree_id=jst.tree_id,
+                           case__institution__jst__lft__range=(jst.lft, jst.rght))
 
 @reversion.register()
 class Monitoring(TimeStampedModel):


Test patch:
diff --git a/feder/monitorings/tests.py b/feder/monitorings/tests.py
--- a/feder/monitorings/tests.py
+++ b/feder/monitorings/tests.py
@@ -3,6 +3,7 @@
 from django.test import TestCase
 from guardian.shortcuts import assign_perm
 
+from feder.cases.factories import CaseFactory
 from feder.cases.models import Case
 from feder.institutions.factories import InstitutionFactory
 from feder.letters.factories import IncomingLetterFactory
@@ -81,6 +82,14 @@ def test_list_display(self):
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, self.monitoring)
 
+    def test_filter_by_voivodship(self):
+        self.case = CaseFactory()  # creates a new monitoring (and institution, JST, too)
+
+        response = self.client.get(reverse('monitorings:list') +
+                                   '?voivodeship={0}'.format(self.case.institution.jst.id))
+        self.assertContains(response, self.case.monitoring)
+        self.assertNotContains(response, self.monitoring)
+
 
 class MonitoringDetailViewTestCase(ObjectMixin, PermissionStatusMixin, TestCase):
     status_anonymous = 200
Repository: watchdogpolska/feder

Issue:
Przyjazny komunikat o aktualizacji wiarygodności
![zaznaczenie_1027](https://user-images.githubusercontent.com/3618479/30726463-49ccc99c-9f4b-11e7-8b74-db3108ac4e45.png)



Discussion:

Resolving patch:
diff --git a/feder/tasks/views.py b/feder/tasks/views.py
--- a/feder/tasks/views.py
+++ b/feder/tasks/views.py
@@ -142,7 +142,10 @@ def action(self, *args, **kwargs):
         self.object.save()
 
     def get_success_message(self):
-        return _("Survey {object} selected!").format(object=self.object)
+        if self.direction == 'up':
+            return _("Survey credibility increased!")
+        else:
+            return _("Survey credibility decreased!")
 
     def get_success_url(self):
         return reverse('tasks:survey', kwargs={'pk': self.object.task_id})


Test patch:
Repository: watchdogpolska/feder

Issue:
sposób widzenia załączników do nas wysłanych
Nie wiem czemu jest tak, że ja wchodzę w korespondencję z daną gminą w danym monitoringu, to przy mailach widzę załączniki:

![image](https://user-images.githubusercontent.com/36925935/37775670-d1d18a68-2de3-11e8-9787-af1c19084734.png)

A jak już wejdę z konkretną wiadomość, to ich nie ma:

![image](https://user-images.githubusercontent.com/36925935/37775701-ea66de2a-2de3-11e8-931c-cf61c2e5c964.png)

Czy to się da zmienić, żeby po wejściu z konkretną wiadomość też było widać te załączniki?


Discussion:
Tak.

Resolving patch:
diff --git a/feder/letters/factories.py b/feder/letters/factories.py
--- a/feder/letters/factories.py
+++ b/feder/letters/factories.py
@@ -1,15 +1,12 @@
 from email.mime.text import MIMEText
 
-import factory
 import factory.fuzzy
-from django.core.mail import EmailMessage
 from factory.django import FileField
 
-from feder.cases.factories import CaseFactory
 from feder.institutions.factories import InstitutionFactory
 from feder.records.factories import RecordFactory
 from feder.users.factories import UserFactory
-from .models import Letter
+from .models import Letter, Attachment
 
 
 class MailField(FileField):
@@ -55,3 +52,11 @@ class SendOutgoingLetterFactory(LetterFactory):
     author_user = factory.SubFactory(UserFactory)
 
     is_send_yes = factory.PostGenerationMethodCall('send')
+
+
+class AttachmentFactory(factory.django.DjangoModelFactory):
+    letter = factory.SubFactory(InstitutionFactory)
+    attachment = factory.django.FileField()
+
+    class Meta:
+        model = Attachment


Test patch:
diff --git a/feder/letters/tests/test_views.py b/feder/letters/tests/test_views.py
--- a/feder/letters/tests/test_views.py
+++ b/feder/letters/tests/test_views.py
@@ -15,7 +15,7 @@
 from feder.main.mixins import PermissionStatusMixin
 from feder.monitorings.factories import MonitoringFactory
 from feder.users.factories import UserFactory
-from ..factories import IncomingLetterFactory, OutgoingLetterFactory
+from ..factories import IncomingLetterFactory, OutgoingLetterFactory, AttachmentFactory
 from django.utils.translation import ugettext_lazy as _
 
 
@@ -70,6 +70,11 @@ def test_contains_link_to_report_spam(self):
         self.assertContains(response, _("Report spam"))
         self.assertContains(response, reverse('letters:spam', kwargs={'pk': self.letter.pk}))
 
+    def test_contains_link_to_attachment(self):
+        attachment = AttachmentFactory(letter=self.letter)
+        response = self.client.get(self.get_url())
+        self.assertContains(response, attachment.attachment.url)
+
 
 class LetterCreateViewTestCase(ObjectMixin, PermissionStatusMixin, TestCase):
     permission = ['monitorings.add_letter', ]
Repository: watchdogpolska/feder

Issue:
zmiana sposobu przewijania spraw z mailami z monitoringu
W tej chwili można przeskakiwać tylko o jedną stronę do przodu i do tyłu, a chodziłoby o to, żeby można było przeskoczyć o kilka lub na sam koniec. Jest tak:

![image](https://user-images.githubusercontent.com/36925935/37586415-8c8a566c-2b5c-11e8-9262-bccfc63bea59.png)

A lepiej jakby było tak:

![image](https://user-images.githubusercontent.com/36925935/37586480-c96e5df8-2b5c-11e8-9090-487ecbd94ed6.png)



Discussion:
To jest paginacja Dziś przygotuje.

Resolving patch:
diff --git a/feder/monitorings/views.py b/feder/monitorings/views.py
--- a/feder/monitorings/views.py
+++ b/feder/monitorings/views.py
@@ -60,6 +60,10 @@ def get_queryset(self):
 
         return qs
 
+    def get_context_data(self, **kwargs):
+        kwargs['url_extra_kwargs'] = {'slug': self.object.slug}
+        return super(MonitoringDetailView, self).get_context_data(**kwargs)
+
     def get_object_list(self, obj):
         return (Case.objects.filter(monitoring=obj).
                 select_related('institution').
@@ -77,6 +81,10 @@ class LetterListMonitoringView(SelectRelatedMixin, PrefetchRelatedMixin, ExtraLi
     prefetch_related = ['questionary_set', ]
     paginate_by = 25
 
+    def get_context_data(self, **kwargs):
+        kwargs['url_extra_kwargs'] = {'slug': self.object.slug}
+        return super(LetterListMonitoringView, self).get_context_data(**kwargs)
+
     def get_object_list(self, obj):
         return (Letter.objects.filter(record__case__monitoring=obj).
                 select_related('record__case').
@@ -93,6 +101,10 @@ class DraftListMonitoringView(SelectRelatedMixin, PrefetchRelatedMixin, ExtraLis
     prefetch_related = ['questionary_set', ]
     paginate_by = 25
 
+    def get_context_data(self, **kwargs):
+        kwargs['url_extra_kwargs'] = {'slug': self.object.slug}
+        return super(DraftListMonitoringView, self).get_context_data(**kwargs)
+
     def get_object_list(self, obj):
         return (Letter.objects.filter(record__case__monitoring=obj).
                 is_draft().


Test patch:
Repository: watchdogpolska/feder

Issue:
błąd przy usuwaniu wiadomości 
@dzejkobi weszłam w monitoring "Samorządy - o liczbę wniosków" i zobaczyłam, że gmina Żarnów wysyła nam z automatu wiadomości o różnych szkoleniach, życzenia świąteczne etc. Najpierw zaczęłam te wiadomości oznaczać, jako spam, ale przestraszyłam się, że potem z automatu odpowiedzi od tej gminy będziemy traktować jako spam i postanowiłam po prostu usunąć te wiadomości za pomocą przycisku "usuń":

![image](https://user-images.githubusercontent.com/36925935/103994006-b47d8000-5196-11eb-8f33-d8d4c0fdf15b.png)

I wyskoczył mi taki błąd:

![image](https://user-images.githubusercontent.com/36925935/103994411-42596b00-5197-11eb-9f1f-3a71b10eff11.png)


Ustawiłam sobie uprawnienia, że mogę kasować list, więc błąd nie wynika z braku uprawnień. Czy możesz spojrzeć, co tu poszło nie tak?


Discussion:
Ok, sprawdzę.

Resolving patch:
diff --git a/feder/letters/views.py b/feder/letters/views.py
--- a/feder/letters/views.py
+++ b/feder/letters/views.py
@@ -238,12 +238,12 @@ class LetterDeleteView(
     permission_required = "monitorings.delete_letter"
 
     def delete(self, request, *args, **kwargs):
-        result = super().delete(request, *args, **kwargs)
-        for x in self.object.attachment_set.all():
-            x.attachment.delete()  # Delete file
-        self.object.attachment_set.all().delete()  # Delete objects
-        self.object.eml.delete()  # Delete file
-        return result
+        obj = self.get_object()
+        # Manually deleting related files
+        for att_obj in obj.attachment_set.all():
+            att_obj.attachment.delete()
+        obj.eml.delete()
+        return super().delete(request, *args, **kwargs)
 
     def get_success_url(self):
         return self.object.case.get_absolute_url()


Test patch:
diff --git a/feder/letters/tests/test_views.py b/feder/letters/tests/test_views.py
--- a/feder/letters/tests/test_views.py
+++ b/feder/letters/tests/test_views.py
@@ -194,6 +194,13 @@ def test_remove_eml_file(self):
         self.client.post(self.get_url())
         self.assertFalse(os.path.isfile(self.from_user.eml.file.name))
 
+    def test_remove_letter_with_attachment(self):
+        self.login_permitted_user()
+        attachment = AttachmentFactory(letter=self.from_user)
+        self.assertTrue(os.path.isfile(attachment.attachment.file.name))
+        self.client.post(self.get_url())
+        self.assertFalse(os.path.isfile(attachment.attachment.file.name))
+
 
 class LetterReplyViewTestCase(ObjectMixin, PermissionStatusMixin, TestCase):
     permission = ["monitorings.reply", "monitorings.add_draft"]
Repository: networkx/networkx

Issue:
Pajek exporter should not write first line "*network NetworkX"
Currently, the first line of a pajek file created by networkx looks like:

```
*network NetworkX
```

Many programs that import pajek files crash, because they expect the first line to be 

```
*vertices 762
```

Given that the `*network NetworkX` serves no purpose, could we modify the pajek writer to not create this first line?



Discussion:
That line is apparently allowed by the "specification"  - see http://vlado.fmf.uni-lj.si/pub/networks/pajek/svganim/1.10.7.1/PajekToSvgAnim.pdf
but clearly not necessary for functionality.  So I think we can remove it without any harm.

Great, I'm glad you agree.

Just to summarize the motivation for this small change: there are many software tools which use a subset of the pajek specification, and this line causes problems for them.  So while it may be technically correct to add that line (according to the full pajek specification), unless it's serving an important purpose, I argue we should leave it out.


Resolving patch:
diff --git a/networkx/readwrite/pajek.py b/networkx/readwrite/pajek.py
--- a/networkx/readwrite/pajek.py
+++ b/networkx/readwrite/pajek.py
@@ -37,10 +37,12 @@ def generate_pajek(G):
     for format information.
     """
     if G.name=='': 
-        name='NetworkX'
+       name='NetworkX'
     else:
-        name=G.name
-    yield '*network %s'%name
+       name=G.name
+    # Apparently many Pajek format readers can't process this line
+    # So we'll leave it out for now.
+    # yield '*network %s'%name
 
     # write nodes with attributes
     yield '*vertices %s'%(G.order())


Test patch:
Repository: networkx/networkx

Issue:
[NX1.7] Crash with read_gexf(g) if there are boolean attributes
Repro steps:

> > > import networkx as nx
> > > g = nx.Graph()
> > > g.add_node(1, attrib=True)
> > > nx.write_gexf(g, 'out.gexf')
> > > nx.read_gexf('out.gexf')

How to fix it:

In networkx/readwrite/gexf.py :

line 208: convert_bool={'true':True,'false':False}
edit into:
line 208: convert_bool={'True':True, 'false':False}



Discussion:
That probably isn't the correct fix.  The file should have lower case "true" and "false" according to the GEXF spec.  So it is the writer not the reader that needs to be fixed.

Oh.

How about:

In networkx/utils/misc.py : 

add the following after line 70:
if type(t) == bool:
....if t: 
....,,,,return 'true'
....else:
....,,,,return 'false'

That will mess with other routines that expect the capitalization.  Looks like make_str should just be defined for the gexf case explicitly in gexf.py instead of importing from utils.  Seems to me that when the format has a specified need for lower case we should handle it specifically in that readwrite module.


Resolving patch:
diff --git a/networkx/readwrite/gexf.py b/networkx/readwrite/gexf.py
--- a/networkx/readwrite/gexf.py
+++ b/networkx/readwrite/gexf.py
@@ -395,7 +395,10 @@ def add_attributes(self, node_or_edge, xml_obj, data, default):
                 # static data
                 e=Element("attvalue")
                 e.attrib['for']=attr_id
-                e.attrib['value']=make_str(v)
+                if type(v) == bool:
+                    e.attrib['value']=make_str(v).lower()
+                else:
+                    e.attrib['value']=make_str(v)
                 attvalues.append(e)
         xml_obj.append(attvalues)
         return data


Test patch:
diff --git a/networkx/readwrite/tests/test_gexf.py b/networkx/readwrite/tests/test_gexf.py
--- a/networkx/readwrite/tests/test_gexf.py
+++ b/networkx/readwrite/tests/test_gexf.py
@@ -303,4 +303,11 @@ def test_write_with_node_attributes(self):
         obtained = '\n'.join(nx.generate_gexf(G))
         assert_equal( expected, obtained )
 
-
+    def test_bool(self):
+        G=nx.Graph()
+        G.add_node(1, testattr=True)
+        fh = io.BytesIO()
+        nx.write_gexf(G,fh)
+        fh.seek(0)
+        H=nx.read_gexf(fh,node_type=int)
+        assert_equal(H.node[1]['testattr'], True)
Repository: networkx/networkx

Issue:
Documentation for draw_networkx_edge_labels is wrong
The documentation for `draw_networkx_edge_labels` says that the pos label is optional, and the spring layout is used by default. However, I can't call the function with only the graph as the first argument. I get an error saying that it takes two arguments.



Discussion:

Resolving patch:
diff --git a/networkx/drawing/nx_pylab.py b/networkx/drawing/nx_pylab.py
--- a/networkx/drawing/nx_pylab.py
+++ b/networkx/drawing/nx_pylab.py
@@ -292,8 +292,7 @@ def draw_networkx_nodes(G, pos,
 
     pos : dictionary
        A dictionary with nodes as keys and positions as values.
-       If not specified a spring layout positioning will be computed.
-       See networkx.layout for functions that compute node positions.
+       Positions should be sequences of length 2.
 
     ax : Matplotlib Axes object, optional
        Draw the graph in the specified Matplotlib axes.
@@ -416,8 +415,7 @@ def draw_networkx_edges(G, pos,
 
     pos : dictionary
        A dictionary with nodes as keys and positions as values.
-       If not specified a spring layout positioning will be computed.
-       See networkx.layout for functions that compute node positions.
+       Positions should be sequences of length 2.
 
     edgelist : collection of edge tuples
        Draw only specified edges(default=G.edges())
@@ -642,10 +640,9 @@ def draw_networkx_labels(G, pos,
     G : graph
        A networkx graph
 
-    pos : dictionary, optional
+    pos : dictionary
        A dictionary with nodes as keys and positions as values.
-       If not specified a spring layout positioning will be computed.
-       See networkx.layout for functions that compute node positions.
+       Positions should be sequences of length 2.
 
     labels : dictionary, optional (default=None)
        Node labels in a dictionary keyed by node of text labels
@@ -749,10 +746,9 @@ def draw_networkx_edge_labels(G, pos,
     G : graph
        A networkx graph
 
-    pos : dictionary, optional
+    pos : dictionary
        A dictionary with nodes as keys and positions as values.
-       If not specified a spring layout positioning will be computed.
-       See networkx.layout for functions that compute node positions.
+       Positions should be sequences of length 2.
 
     ax : Matplotlib Axes object, optional
        Draw the graph in the specified Matplotlib axes.


Test patch:
Repository: networkx/networkx

Issue:
Need JSON format description
The page on JSON serialization lacks information about the actual structure of produced data. This make it hard to see if networkx is a suitable tool for a backend of already existing JavaScript front.

http://networkx.lanl.gov/reference/readwrite.json_graph.html



Discussion:
They are the format that the D3.js package uses.   And you are right there should be some documentation.

Can you clarify? This answer says that D3.js doesn't use any specific format - http://stackoverflow.com/a/11089330

That is true.  There are a few different formats of JSON serialization hat are used in the d3.js examples and you can, as @mbostoc points out, parse CSV data or whatever you want.  

The three formats that you can generate with NetworkX are 
- node-link like in the d3.js example http://bl.ocks.org/mbostock/4062045
- tree like in the d3.js example http://bl.ocks.org/mbostock/4063550
- adjacency like in the d3.js example http://bost.ocks.org/mike/miserables/

Perhaps some mention of the three available types, with outbound links to the blocks listed would suffice in the docs.  I had a real easy time building a force directed d3 graph using XML parsed into networkx for modeling for a free-hack day at work.


Resolving patch:
diff --git a/networkx/readwrite/json_graph/__init__.py b/networkx/readwrite/json_graph/__init__.py
--- a/networkx/readwrite/json_graph/__init__.py
+++ b/networkx/readwrite/json_graph/__init__.py
@@ -1,8 +1,16 @@
 """
 *********
-JSON data 
+JSON data
 *********
 Generate and parse JSON serializable data for NetworkX graphs.
+
+These formats are suitable for use with the d3.js examples http://d3js.org/
+
+The three formats that you can generate with NetworkX are:
+
+ - node-link like in the d3.js example http://bl.ocks.org/mbostock/4062045
+ - tree like in the d3.js example http://bl.ocks.org/mbostock/4063550
+ - adjacency like in the d3.js example http://bost.ocks.org/mike/miserables/
 """
 from networkx.readwrite.json_graph.node_link import *
 from networkx.readwrite.json_graph.adjacency import *


Test patch: