internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: graspologic-org/graspologic

Issue:
Give screeplot an `ax` argument
function[ here.](https://github.com/microsoft/graspologic/blob/dev/graspologic/plot/plot.py#L1129)

Currently no way to specify an `ax`, most other plotting functions have that unless there's a good reason not to. I don't see a good reason for this one not to have it. Should be pretty easy to add on.
Give screeplot an `ax` argument
function[ here.](https://github.com/microsoft/graspologic/blob/dev/graspologic/plot/plot.py#L1129)

Currently no way to specify an `ax`, most other plotting functions have that unless there's a good reason not to. I don't see a good reason for this one not to have it. Should be pretty easy to add on.


Discussion:
Hi, i would like to work on this issue, shall i take it?!🙂
> Hi, i would like to work on this issue, shall i take it?!🙂

Sure. Just want to be able to specify a matplotlib axis if i'm using the screeplot function.
Is this work still ongoing?I am a beginner and would like to give it a try.

I think you can still PR, as it hasn't been closed. I'm going to try it as well :)
Hi, i would like to work on this issue, shall i take it?!🙂
> Hi, i would like to work on this issue, shall i take it?!🙂

Sure. Just want to be able to specify a matplotlib axis if i'm using the screeplot function.
Is this work still ongoing?I am a beginner and would like to give it a try.

I think you can still PR, as it hasn't been closed. I'm going to try it as well :)

Resolving patch:
diff --git a/graspologic/plot/plot.py b/graspologic/plot/plot.py
--- a/graspologic/plot/plot.py
+++ b/graspologic/plot/plot.py
@@ -1421,6 +1421,7 @@ def screeplot(
     context: str = "talk",
     font_scale: float = 1,
     figsize: Tuple[int, int] = (10, 5),
+    ax: Optional[matplotlib.axes.Axes] = None,
     cumulative: bool = True,
     show_first: Optional[int] = None,
     show_elbow: Optional[Union[bool, int]] = False,
@@ -1480,8 +1481,11 @@ def screeplot(
         y = np.cumsum(D[:show_first])
     else:
         y = D[:show_first]
+
+    if ax is None:
+        ax = plt.gca()
+
     _ = plt.figure(figsize=figsize)
-    ax = plt.gca()
     xlabel = "Component"
     ylabel = "Variance explained"
     with sns.plotting_context(context=context, font_scale=font_scale):


Test patch:
Repository: GeotrekCE/Geotrek-admin

Issue:
ADMIN - Tronçon bouclant sur lui-même
Impossible de saisir le CIRCUIT DES LACS correctement.
Renvoie souvent une 504 BAD GATEWAY quand on enregistre. L'itinéraire a pourtant été modifié mais différemment de la façon dont il a été saisi. A creuser.



Discussion:
No problem at all to draw this trek with 0.19, using PNE database.
See detail page screenshot  ( _icons are missing, cause did not import PNE medias locally_ ) :

![capture du 2013-08-20 11 48 59](https://f.cloud.github.com/assets/546692/992425/f1d162be-097d-11e3-9e7a-5cfd5882ced2.png)

**However** : BUG at restoring topology when editing : 

![capture du 2013-08-20 11 48 14](https://f.cloud.github.com/assets/546692/992424/eeb076b0-097d-11e3-9b28-b10f8cc13064.png)


Resolving patch:
diff --git a/geotrek/core/forms.py b/geotrek/core/forms.py
--- a/geotrek/core/forms.py
+++ b/geotrek/core/forms.py
@@ -44,7 +44,6 @@ class Meta(CommonForm.Meta):
         fields = CommonForm.Meta.fields + ['topology']
 
     MEDIA_JS = ("core/dijkstra.js",
-                "core/leaflet-geomutils.js",
                 "core/multipath.js",
                 "core/topology_helper.js") + CommonForm.MEDIA_JS
 


Test patch:
diff --git a/geotrek/core/tests/topology.py b/geotrek/core/tests/topology.py
--- a/geotrek/core/tests/topology.py
+++ b/geotrek/core/tests/topology.py
@@ -424,6 +424,8 @@ def test_return_path_serialized(self):
                                                (7, 10, 0), (5, 10, 0), (5, 0, 0),
                                                (7.5, 0, 0)))
 
+
+class TopologyLoopTests(TestCase):
     def test_simple_loop(self):
         """
            ==========
@@ -521,11 +523,14 @@ def test_spoon_loop_2(self):
                                                (17, 5, 0), (20, 5, 0),  # extra point due middle aggregation
                                                (20, 0, 0), (16, 0, 0), (10, 0, 0), (3, 0, 0)))
 
-        # Deserializing should work too
-        topod = Topology.deserialize("""
-           [{"positions":{"0":[0.3,1],"1":[0, 0.4]},"paths":[%(pk1)s,%(pk2)s]},
-            {"positions":{"0":[0.4, 0.8]},"paths":[%(pk2)s]},
-            {"positions":{"0":[0.8,1],"1":[1,0.3]},"paths":[%(pk2)s,%(pk1)s]}]""" % {'pk1': p1.pk, 'pk2': p2.pk})
+        # De/Serializing should work too
+        serialized = """
+           [{"kind": "TOPOLOGY","positions":{"0":[0.3,1],"1":[0, 0.4]},"paths":[%(pk1)s,%(pk2)s],"offset": 0.0},
+            {"kind": "TOPOLOGY","positions":{"0":[0.4, 0.8]},"paths":[%(pk2)s],"offset": 0.0},
+            {"kind": "TOPOLOGY","positions":{"0":[0.8,1],"1":[1,0.3]},"paths":[%(pk2)s,%(pk1)s],"offset": 0.0}]""" % {'pk1': p1.pk, 'pk2': p2.pk}
+
+        self.assertEqual(json.loads(serialized), json.loads(topo.serialize()))
+        topod = Topology.deserialize(serialized)
         self.assertEqual(topo.geom, topod.geom)
         self.assertEqual(len(topod.aggregations.all()), 7)
Repository: GeotrekCE/Geotrek-admin

Issue:
Show path icon if intervention is not on infrastructure
Dans la liste des interventions, dans la colonne SUR est affiché si l'intervention est rattaché à un aménagement ou signalétique.
Au survol de l'icone, dans le title, traduire INFRASTRUCTURE en AMÉNAGEMENT et afficher ensuite le nom de l'aménagement. Idem quand c'est sur de la signalétique.
Pour les autres, afficher le logo des tronçons plutôt que laisser la colonne vide. Car en effet, quand une intervention est ni sur un aménagement, ni sur une signalétique, alors c'est qu'il s'applique directement à un (ou plusieurs) tronçon(s).



Discussion:

Resolving patch:
diff --git a/geotrek/maintenance/models.py b/geotrek/maintenance/models.py
--- a/geotrek/maintenance/models.py
+++ b/geotrek/maintenance/models.py
@@ -129,11 +129,16 @@ def infrastructure_verbose_name(cls):
 
     @property
     def infrastructure_display(self):
+        icon = 'path'
+        title = _('Path')
         if self.on_infrastructure:
-            return '<img src="%simages/%s-16.png" title="%s">' % (settings.STATIC_URL,
-                                                                  self.topology.kind.lower(),
-                                                                  unicode(_(self.topology.kind)))
-        return ''
+            icon = self.topology.kind.lower()
+            title = u'%s: %s' % (_(self.topology.kind.capitalize()),
+                                 self.infrastructure)
+
+        return u'<img src="%simages/%s-16.png" title="%s">' % (settings.STATIC_URL,
+                                                               icon,
+                                                               title)
 
     @property
     def infrastructure_csv_display(self):


Test patch:
Repository: GeotrekCE/Geotrek-admin

Issue:
QUESTION - Language settings
I saw this change in 0.22.1 : 

Application available languages (english, french, italian, spanish) are now distinct from translated content languages (languages value in :file:settings.ini)

In our settings.ini, we have "languages = en,fr" as our Geotrek-rando is just available in French and English actually.

Why show Italian and Spanish translation fields in forms ? 



Discussion:
Looks like a bug then :)

OK so I dont understand what you changed with "Application available languages (english, french, italian, spanish) are now distinct from translated content languages (languages value in :file:settings.ini)" ?


Resolving patch:
diff --git a/geotrek/settings/base.py b/geotrek/settings/base.py
--- a/geotrek/settings/base.py
+++ b/geotrek/settings/base.py
@@ -404,6 +404,8 @@
 LAND_BBOX_DISTRICTS_ENABLED = True
 LAND_BBOX_AREAS_ENABLED = False
 
+TREK_COMPLETENESS_FIELDS = ['departure', 'duration', 'difficulty',
+                            'description_teaser']
 TREK_DAY_DURATION = 10  # Max duration to be done in one day
 
 # Static offsets in projection units
diff --git a/geotrek/settings/default.py b/geotrek/settings/default.py
--- a/geotrek/settings/default.py
+++ b/geotrek/settings/default.py
@@ -85,6 +85,9 @@
                                                      envini.get('host', section='screamshotter', default='127.0.0.1'),
                                                      envini.get('port', section='screamshotter', default='8001'))
 
+# We override the default Adminsite template, add its location for template loader
+TEMPLATE_DIRS += (os.path.join(DEPLOY_ROOT, 'lib', 'src', 'mapentity', 'mapentity', 'templates'),)
+
 
 #
 #  Geotrek settings
diff --git a/geotrek/trekking/models.py b/geotrek/trekking/models.py
--- a/geotrek/trekking/models.py
+++ b/geotrek/trekking/models.py
@@ -359,7 +359,7 @@ def kml(self):
     def is_complete(self):
         """It should also have a description, etc.
         """
-        mandatory = ['departure', 'arrival', 'description_teaser']
+        mandatory = settings.TREK_COMPLETENESS_FIELDS
         for f in mandatory:
             if not getattr(self, f):
                 return False


Test patch:
diff --git a/geotrek/authent/tests/test_admin.py b/geotrek/authent/tests/test_admin.py
--- a/geotrek/authent/tests/test_admin.py
+++ b/geotrek/authent/tests/test_admin.py
@@ -24,7 +24,7 @@ def login(self, user):
     def test_user_cant_access(self):
         self.login(self.user)
         response = self.client.get('/admin/')
-        self.assertContains(response, 'Log in | Django site admin')
+        self.assertContains(response, 'Log in | Geotrek administration')
 
     def test_admin_can_see_everything(self):
         self.login(self.admin)
Repository: GeotrekCE/Geotrek-admin

Issue:
Add requirement about projection units : should be meters
http://gis.stackexchange.com/questions/85955/how-can-i-obtain-the-unit-of-a-projection-srid



Discussion:

Resolving patch:
diff --git a/geotrek/common/__init__.py b/geotrek/common/__init__.py
--- a/geotrek/common/__init__.py
+++ b/geotrek/common/__init__.py
@@ -5,9 +5,11 @@
     This is executed only once at startup.
 
 """
-from south.signals import post_migrate
+from south.signals import pre_migrate, post_migrate
 from django.conf import settings
-from django.db.models.signals import post_syncdb
+from django.db import connection
+from django.db.models.signals import pre_syncdb, post_syncdb
+from django.core.exceptions import ImproperlyConfigured
 
 from mapentity.helpers import api_bbox
 
@@ -31,11 +33,26 @@ def run_initial_sql_post_syncdb(sender, **kwargs):
     load_sql_files(app_label)
 
 
+def check_srid_has_meter_unit(sender, **kwargs):
+    if not hasattr(check_srid_has_meter_unit, '_checked'):
+        cursor = connection.cursor()
+        cursor.execute("""
+            SELECT * FROM spatial_ref_sys
+            WHERE srtext ILIKE '%%meter%%' AND srid=%s;""", [settings.SRID])
+        results = cursor.fetchall()
+        if len(results) == 0:
+            err_msg = 'Unit of SRID EPSG:%s is not meter.' % settings.SRID
+            raise ImproperlyConfigured(err_msg)
+    check_srid_has_meter_unit._checked = True
+
+
 if settings.TEST and not settings.SOUTH_TESTS_MIGRATE:
+    pre_syncdb.connect(check_srid_has_meter_unit, dispatch_uid="geotrek.core.checksrid")
     post_syncdb.connect(run_initial_sql_post_syncdb, dispatch_uid="geotrek.core.sqlautoload")
     # During tests, the signal is received twice unfortunately
     # https://code.djangoproject.com/ticket/17977
 else:
+    pre_migrate.connect(check_srid_has_meter_unit, dispatch_uid="geotrek.core.checksrid")
     post_migrate.connect(run_initial_sql_post_migrate, dispatch_uid="geotrek.core.sqlautoload")
 
 


Test patch:
diff --git a/geotrek/common/tests.py b/geotrek/common/tests.py
--- a/geotrek/common/tests.py
+++ b/geotrek/common/tests.py
@@ -14,6 +14,7 @@
 from .factories import AttachmentFactory
 from .utils import almostequal, sampling, sql_extent, uniquify
 from .utils.postgresql import debug_pg_notices
+from . import check_srid_has_meter_unit
 
 
 class CommonTest(MapEntityTest):
@@ -26,6 +27,13 @@ def test_attachment(self):
         self.assertEqual(len(obj.attachments), 2)
 
 
+class StartupCheckTest(TestCase):
+    def test_error_is_raised_if_srid_is_not_meters(self):
+        delattr(check_srid_has_meter_unit, '_checked')
+        with self.settings(SRID=4326):
+            self.assertRaises(ImproperlyConfigured, check_srid_has_meter_unit, None)
+
+
 class ViewsTest(TestCase):
 
     def setUp(self):
Repository: GeotrekCE/Geotrek-admin

Issue:
Show land module in left menus
As we said it would be interesting to move it to its own menu, we should take opportunity to rename some elements : 

Module name : 
"Gestion foncière" TO "Gestionnaires"
AND ALSO : 
"Zone de compétence" TO "Compétence sentiers"



Discussion:
What would that be in english ? Just _Managers_ ? 

Would that fit with _type physique_ ?

Ideas of symbols / icons ?

![screenshot from 2014-02-09 15 37 58](https://f.cloud.github.com/assets/546692/2119977/d142804e-9197-11e3-93b2-b07d9dd6182d.png)

![screenshot from 2014-02-09 15 39 02](https://f.cloud.github.com/assets/546692/2119981/1e193a2a-9198-11e3-8168-deb7a47efb60.png)
![screenshot from 2014-02-09 15 40 11](https://f.cloud.github.com/assets/546692/2119983/2904aea6-9198-11e3-9179-5e078591e570.png)
![screenshot from 2014-02-09 15 37 01](https://f.cloud.github.com/assets/546692/2119985/2c306e26-9198-11e3-8ebc-0ac94c4f6f57.png)

Managers sounds OK in english.
It is complicated to find a good name that is OK for every items from the module. 

"Gestionnaires" is a bit better than "Gestion fonciere" but it is not perfect and dont work really well for TYPE FONCIER. No better idea yet.

The third icon is the best for me.

Yes, I agree with the 3rd icon, and more if we add colors.

_statuts_, _reglement_, _juridique_, _légal_, _institutions_... just brainstorming...

Indeed, STATUTS could work better than GESTIONNAIRES.


Resolving patch:
diff --git a/geotrek/land/urls.py b/geotrek/land/urls.py
--- a/geotrek/land/urls.py
+++ b/geotrek/land/urls.py
@@ -4,7 +4,7 @@
 
 
 urlpatterns = registry.register(models.PhysicalEdge, menu=False)
-urlpatterns += registry.register(models.LandEdge, menu=False)
+urlpatterns += registry.register(models.LandEdge)
 urlpatterns += registry.register(models.CompetenceEdge, menu=False)
 urlpatterns += registry.register(models.WorkManagementEdge, menu=False)
 urlpatterns += registry.register(models.SignageManagementEdge, menu=False)


Test patch:
Repository: GeotrekCE/Geotrek-admin

Issue:
Send an email on feeback record creation
- rel https://github.com/makinacorpus/Geotrek-rando/issues/132
- Send to managers
- Import test send email from Geotrek-rando



Discussion:

Resolving patch:
diff --git a/geotrek/feedback/models.py b/geotrek/feedback/models.py
--- a/geotrek/feedback/models.py
+++ b/geotrek/feedback/models.py
@@ -66,9 +66,11 @@ def name_display(self):
 
 
 @receiver(post_save, sender=Report, dispatch_uid="on_report_created")
-def on_report_created(sender, instance, created, **kwargs):
+def on_report_saved(sender, instance, created, **kwargs):
     """ Send an email to managers when a report is created.
     """
+    if not created:
+        return
     try:
         send_report_managers(instance)
     except Exception as e:


Test patch:
diff --git a/geotrek/feedback/tests/test_email.py b/geotrek/feedback/tests/test_email.py
--- a/geotrek/feedback/tests/test_email.py
+++ b/geotrek/feedback/tests/test_email.py
@@ -19,6 +19,13 @@ def test_a_mail_is_sent_on_report_creation(self):
         ReportFactory.create()
         self.assertEquals(len(mail.outbox), 1)
 
+    def test_a_mail_is_not_sent_on_report_modification(self):
+        r = ReportFactory.create()
+        self.assertEquals(len(mail.outbox), 1)
+        r.name = 'toto'
+        r.save()
+        self.assertEquals(len(mail.outbox), 1)
+
     @override_settings(EMAIL_BACKEND='geotrek.feedback.tests.FailingEmailBackend')
     def test_email_failure_does_not_prevent_report_creation(self):
         r = ReportFactory.create()
Repository: GeotrekCE/Geotrek-admin

Issue:
Provide a way to easily override Trek PDF template
Can be done by PNE ?



Discussion:
I changed the title of this issue (previous "Rework PDF RANDO export template")


Resolving patch:
diff --git a/geotrek/settings/default.py b/geotrek/settings/default.py
--- a/geotrek/settings/default.py
+++ b/geotrek/settings/default.py
@@ -87,8 +87,9 @@
 MAPENTITY_CONFIG['CAPTURE_SERVER'] = '%s://%s:%s' % (envini.get('protocol', section='screamshotter', default='http'),
                                                      envini.get('host', section='screamshotter', default='127.0.0.1'),
                                                      envini.get('port', section='screamshotter', default='8001'))
-TEMPLATE_DIRS += (os.path.join(DEPLOY_ROOT, 'lib', 'parts', 'omelette',
-                               'mapentity', 'templates'),)
+TEMPLATE_DIRS = (os.path.join(DEPLOY_ROOT, 'lib', 'parts', 'omelette',
+                               'mapentity', 'templates'),
+                  os.path.join(MEDIA_ROOT, 'templates')) + TEMPLATE_DIRS
 
 
 #
diff --git a/geotrek/trekking/views.py b/geotrek/trekking/views.py
--- a/geotrek/trekking/views.py
+++ b/geotrek/trekking/views.py
@@ -202,10 +202,6 @@ class TrekPrint(DocumentConvert):
     def source_url(self):
         return self.get_object().get_document_public_url()
 
-    @method_decorator(login_required)
-    def dispatch(self, *args, **kwargs):
-        return super(TrekPrint, self).dispatch(*args, **kwargs)
-
 
 class TrekRelationshipFormsetMixin(FormsetMixin):
     context_name = 'relationship_formset'


Test patch:
diff --git a/geotrek/trekking/tests/test_views.py b/geotrek/trekking/tests/test_views.py
--- a/geotrek/trekking/tests/test_views.py
+++ b/geotrek/trekking/tests/test_views.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+import os
 import json
 from collections import OrderedDict
 
@@ -11,6 +12,7 @@
 from django.contrib.gis.geos import LineString
 from django.core.urlresolvers import reverse
 from django.db import connection
+from django.template.loader import find_template
 
 from mapentity.tests import MapEntityLiveTest
 from mapentity.factories import SuperUserFactory
@@ -259,6 +261,17 @@ def test_overriden_document(self, get_attributes_html):
         self.assertEqual(response.status_code, 200)
         self.assertTrue(len(response.content) < 1000)
 
+    @mock.patch('django.template.loaders.filesystem.open', create=True)
+    def test_overriden_public_template(self, open_patched):
+        overriden_template = os.path.join(settings.MEDIA_ROOT, 'templates', 'trekking', 'trek_public.odt')
+        def fake_exists(f, *args):
+            if f == overriden_template:
+                return mock.MagicMock(spec=file)
+            raise IOError
+        open_patched.side_effect = fake_exists
+        find_template('trekking/trek_public.odt')
+        open_patched.assert_called_with(overriden_template, 'rb')
+
     def test_profile_json(self):
         trek = TrekFactory.create()
         url = reverse('trekking:trek_profile', kwargs={'pk': trek.pk})
Repository: GeotrekCE/Geotrek-admin

Issue:
Desordres facultatif sur formulaire Intervention
Le champs DESORDRES ne doit pas être obligatoire.



Discussion:

Resolving patch:
diff --git a/geotrek/maintenance/models.py b/geotrek/maintenance/models.py
--- a/geotrek/maintenance/models.py
+++ b/geotrek/maintenance/models.py
@@ -51,7 +51,8 @@ class Intervention(MapEntityMixin, AltimetryMixin, TimeStampedModel, StructureRe
                              verbose_name=_(u"Type"), db_column='type')
 
     disorders = models.ManyToManyField('InterventionDisorder', related_name="interventions",
-                                       db_table="m_r_intervention_desordre", verbose_name=_(u"Disorders"))
+                                       db_table="m_r_intervention_desordre", verbose_name=_(u"Disorders"),
+                                       blank=True)
 
     jobs = models.ManyToManyField('InterventionJob', through='ManDay', verbose_name=_(u"Jobs"))
 


Test patch:
diff --git a/geotrek/maintenance/tests/test_views.py b/geotrek/maintenance/tests/test_views.py
--- a/geotrek/maintenance/tests/test_views.py
+++ b/geotrek/maintenance/tests/test_views.py
@@ -120,6 +120,13 @@ def test_update_form_on_infrastructure(self):
         response = self.client.post(formurl, data)
         self.assertEqual(response.status_code, 302)
 
+    def test_disorders_not_mandatory(self):
+        self.login()
+        data = self.get_good_data()
+        data.pop('disorders')
+        response = self.client.post(Intervention.get_add_url(), data)
+        self.assertEqual(response.status_code, 302)
+
     def test_update_infrastruture(self):
         self.login()
         intervention = InfrastructureInterventionFactory.create()
@@ -137,7 +144,6 @@ def test_update_infrastruture(self):
         self.assertFalse(intervention.deleted)
         self.assertEqual(intervention.infrastructure.name, 'modified')
 
-
     def test_form_default_stake(self):
         self.login()
         good_data = self.get_good_data()
Repository: GeotrekCE/Geotrek-admin

Issue:
Afficher extrémités tronçons
Visualiser les extrémités de chaque tronçon par un petit point.



Discussion:
Related #940 


Resolving patch:
diff --git a/geotrek/common/views.py b/geotrek/common/views.py
--- a/geotrek/common/views.py
+++ b/geotrek/common/views.py
@@ -66,6 +66,7 @@ def get_context_data(self):
         # Add extra stuff (edition, labelling)
         dictsettings['map'].update(
             snap_distance=settings.SNAP_DISTANCE,
+            paths_line_marker=settings.PATHS_LINE_MARKER,
             colorspool=settings.LAND_COLORS_POOL,
         )
         dictsettings['version'] = __version__
diff --git a/geotrek/settings/base.py b/geotrek/settings/base.py
--- a/geotrek/settings/base.py
+++ b/geotrek/settings/base.py
@@ -358,6 +358,7 @@
 
 DEFAULT_STRUCTURE_NAME = gettext_noop('Default')
 
+PATHS_LINE_MARKER = 'dotL'
 SNAP_DISTANCE = 30  # Distance of snapping in pixels
 
 ALTIMETRIC_PROFILE_PRECISION = 25  # Sampling precision in meters
@@ -381,6 +382,7 @@
     'SPATIAL_EXTENT': (1.3, 43.7, 1.5, 43.5),
     'NO_GLOBALS': False,
     'PLUGINS': {
+        'geotrek': {'js': ['core/leaflet.lineextremities.js']},
         'topofields': {'js': ['core/geotrek.forms.snap.js',
                               'core/geotrek.forms.topology.js',
                               'core/dijkstra.js',


Test patch:
Repository: GeotrekCE/Geotrek-admin

Issue:
Show POI name on hover instead of category



Discussion:

Resolving patch:
diff --git a/geotrek/trekking/models.py b/geotrek/trekking/models.py
--- a/geotrek/trekking/models.py
+++ b/geotrek/trekking/models.py
@@ -51,12 +51,18 @@ def serializable_pictures(self):
         serialized = []
         for picture in self.pictures:
             thumbnailer = get_thumbnailer(picture.attachment_file)
-            thdetail = thumbnailer.get_thumbnail(aliases.get('medium'))
+            try:
+                thdetail = thumbnailer.get_thumbnail(aliases.get('medium'))
+                thurl = os.path.join(settings.MEDIA_URL, thdetail.name)
+            except InvalidImageFormatError:
+                thurl = None
+                logger.error(_("Image %s invalid or missing from disk.") % picture.attachment_file)
+                pass
             serialized.append({
                 'author': picture.author,
                 'title': picture.title,
                 'legend': picture.legend,
-                'url': os.path.join(settings.MEDIA_URL, thdetail.name)
+                'url': thurl
             })
         return serialized
 


Test patch: