From 66c280babae3c3978e9d259bf4c776e8988dc5d7 Mon Sep 17 00:00:00 2001 From: bniton <bartek.niton@gmail.com> Date: Thu, 19 Oct 2017 15:43:15 +0200 Subject: [PATCH] Saving lemma with not defined entry bugfix. --- INSTALL_PL | 4 ++-- dictionary/models.py | 10 +++++++++- dictionary/saving.py | 6 ++---- semantics/management/commands/find_hanging_connections.py | 2 -- semantics/management/commands/find_hanging_examples.py | 2 -- semantics/views.py | 11 ++++++----- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/INSTALL_PL b/INSTALL_PL index 1db79ba..582b6ce 100644 --- a/INSTALL_PL +++ b/INSTALL_PL @@ -10,8 +10,8 @@ Zainstaluj Django w wersji 1.4.8: Zainstaluj Django south: >> sudo apt-get install python-django-south -Zainstaluj Django extensions: ->> sudo apt-get install python-django-extensions +Zainstaluj Django extensions w wersji 1.6.7: +>> sudo pip install django-extensions==1.6.7 Zainstaluj Django registration w wersji 0.8: >> sudo pip install django-registration==0.8 diff --git a/dictionary/models.py b/dictionary/models.py index ec801ae..fc83c48 100644 --- a/dictionary/models.py +++ b/dictionary/models.py @@ -1452,7 +1452,15 @@ class Entry(Model): def actual_lemma(self): return self.lemmas.get(old=False) - + + def defined(self): + entry_defined = True + try: + self.lemmas.get(old=False) + except Lemma.DoesNotExist: + entry_defined = False + return entry_defined + def __unicode__(self): return self.name diff --git a/dictionary/saving.py b/dictionary/saving.py index baae225..f58d5df 100644 --- a/dictionary/saving.py +++ b/dictionary/saving.py @@ -95,12 +95,10 @@ def get_disconnect_operations(lemma, frames, connections): return operations def get_shared_schemata_ids(lemma): - print lemma ids = [f.id for f in lemma.frames.all()] - print ids for connected in lemma.entry_obj.rel_entries.all(): - ids += [f.id for f in connected.actual_lemma().frames.all()] - print ids + if connected.defined(): + ids += [f.id for f in connected.actual_lemma().frames.all()] return ids def update_connections(lemma_id, reconnect_operations, user): diff --git a/semantics/management/commands/find_hanging_connections.py b/semantics/management/commands/find_hanging_connections.py index a645a58..fd59e98 100644 --- a/semantics/management/commands/find_hanging_connections.py +++ b/semantics/management/commands/find_hanging_connections.py @@ -1,6 +1,5 @@ #-*- coding:utf-8 -*- -import datetime from django.core.management.base import BaseCommand @@ -34,4 +33,3 @@ def find_hanging_connections(): print 'lemma: %s\tcomplement: %s\trealization: %s' % (lemma.entry_obj.name, compl_ref, unicode(real)) - \ No newline at end of file diff --git a/semantics/management/commands/find_hanging_examples.py b/semantics/management/commands/find_hanging_examples.py index c6a7ace..f4b0b1b 100644 --- a/semantics/management/commands/find_hanging_examples.py +++ b/semantics/management/commands/find_hanging_examples.py @@ -38,5 +38,3 @@ def print_hanging_examples(lemma): example.id) for ex in same_lu_examples.all(): print 'lu_ex_id: %d' % ex.id - - \ No newline at end of file diff --git a/semantics/views.py b/semantics/views.py index ca22d97..36e0681 100644 --- a/semantics/views.py +++ b/semantics/views.py @@ -283,11 +283,12 @@ def create_connected_context(lemma_id, user): context = {'frames_display': [], 'connections':{'connected_reverse': [], 'connected': []}} for entry in connected: - lemma = entry.actual_lemma() - frame_context = create_frames_context(lemma.id, user) - context['frames_display'] += frame_context['frames_display'] - context['connections']['connected'] += frame_context['connections']['connected'] - context['connections']['connected_reverse'] += frame_context['connections']['connected_reverse'] + if entry.defined(): + lemma = entry.actual_lemma() + frame_context = create_frames_context(lemma.id, user) + context['frames_display'] += frame_context['frames_display'] + context['connections']['connected'] += frame_context['connections']['connected'] + context['connections']['connected_reverse'] += frame_context['connections']['connected_reverse'] return context -- libgit2 0.22.2