From bc821ba243a7d766cb4e0c47129d9c1fba872d49 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Thu, 15 Nov 2018 21:56:25 +0100
Subject: [PATCH] Remove unneeded related fields checkers

---
 scipost/models.py                             | 52 -------------------
 .../templates/scipost/contributor_merge.html  | 24 ---------
 2 files changed, 76 deletions(-)

diff --git a/scipost/models.py b/scipost/models.py
index df4b58c35..d55050e0b 100644
--- a/scipost/models.py
+++ b/scipost/models.py
@@ -128,58 +128,6 @@ class Contributor(models.Model):
             return ', '.join([subject_areas_dict[exp].lower() for exp in self.expertises])
         return ''
 
-    def related_fields_one_to_one(self):
-        related_fields = [ f for f in self._meta.get_fields(include_hidden=True)
-                           if f.one_to_one
-                           #and f.auto_created and not f.concrete
-        ]
-        # print('related fields one_to_one for %s' % str(self))
-        # for related_field in related_fields:
-        #     # try:
-        #     related_object = getattr(self, related_field.name)
-        #     print ('\t%s, %s, %s' % (related_field.name, 'one_to_one', '1'))
-        #     print('\t\t%s, %s' % (related_object.id, str(related_object)))
-        #     # except:
-        #     #     print('%s, %s, %s' % (related_field.name, 'one_to_one', 'ERROR'))
-        return related_fields
-
-    def related_fields_one_to_many(self):
-        related_fields = [ f for f in self._meta.get_fields(include_hidden=True)
-                           if f.one_to_many
-                           #and f.auto_created and not f.concrete
-        ]
-        # print('related fields one_to_many for %s' % str(self))
-        # for related_field in related_fields:
-        #     # try:
-        #     related_objects = getattr(self, '%s_set' % (related_field.attname if hasattr(related_field, 'attname') else related_field.name)).all()
-        #     #related_objects = getattr(self, related_field.name).all()
-        #     print ('\t%s, %s, %s' %
-        #            (related_field.name, 'one_to_many', related_objects.count()))
-        #     for obj in related_objects:
-        #         print('\t\t%s, %s' % (obj.id, str(obj)))
-        #     # except:
-        #     #     print('\t\t%s, %s, %s' %
-        #     #           (related_field.name, 'one_to_many', 'ERROR'))
-        return related_fields
-
-    def related_fields_many_to_one(self):
-        related_fields = [ f for f in self._meta.get_fields(include_hidden=True)
-                           if f.many_to_one ]
-        return related_fields
-
-    def related_fields_many_to_many(self):
-        related_fields = [ f for f in self._meta.get_fields(include_hidden=True)
-                           if f.many_to_many and f.auto_created ]
-        # print('related fields many_to_many for %s' % str(self))
-        # for related_field in related_fields:
-        #     related_objects = getattr(self, '%s' % related_field.name).all()
-        #     print ('\t%s, %s' % (related_field.name, related_objects.count()))
-        #     print ('\t%s, %s, %s' %
-        #            (related_field.name, 'many_to_many', related_objects.count()))
-        #     for obj in related_objects:
-        #         print('\t\t%s, %s' % (obj.id, str(obj)))
-        return related_fields
-
 
 class UnavailabilityPeriod(models.Model):
     contributor = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE,
diff --git a/scipost/templates/scipost/contributor_merge.html b/scipost/templates/scipost/contributor_merge.html
index 5bd3cd9ac..73b0700f1 100644
--- a/scipost/templates/scipost/contributor_merge.html
+++ b/scipost/templates/scipost/contributor_merge.html
@@ -22,30 +22,6 @@
   <div class="col-12">
   <h3 class="highlight">Contributor {{ contributor_to_merge.id }}</h3>
   {% include "scipost/_public_info_as_table.html" with contributor=contributor %}
-  <h4>One to One:</h4>
-  <ul>
-    {% for field in contributor_to_merge.related_fields_one_to_one %}
-    <li>{{ field }} -- {{ field.name }} -- {{ field.attname }}</li>
-    {% endfor %}
-  </ul>
-  <h4>One to Many:</h4>
-  <ul>
-    {% for field in contributor_to_merge.related_fields_one_to_many %}
-    <li>{{ field }} -- {{ field.name }} -- {{ field.attname }}</li>
-    {% endfor %}
-  </ul>
-  <h4>Many to One:</h4>
-  <ul>
-    {% for field in contributor_to_merge.related_fields_many_to_one %}
-    <li>{{ field }} -- {{ field.name }} -- {{ field.attname }}</li>
-    {% endfor %}
-  </ul>
-  <h4>Many to Many:</h4>
-  <ul>
-    {% for field in contributor_to_merge.related_fields_many_to_many %}
-    <li>{{ field }} -- {{ field.name }} -- {{ field.attname }}</li>
-    {% endfor %}
-  </ul>
   </div>
 </div>
 <div class="row">
-- 
GitLab