diff --git a/dictionary/models.py b/dictionary/models.py index d3cf25e..98c4eb4 100644 --- a/dictionary/models.py +++ b/dictionary/models.py @@ -1406,7 +1406,7 @@ class Entry(Model): ) def all_der_entries(self): - rel_entries = Entry.objects.none() + rel_entries = Entry.objects.filter(pk=self.pk) if self.der_group is not None: rel_entries = self.der_group.entries.all() return rel_entries diff --git a/dictionary/saving.py b/dictionary/saving.py index 1fda88b..fa4dfd2 100644 --- a/dictionary/saving.py +++ b/dictionary/saving.py @@ -69,7 +69,8 @@ def reconnect_operations(lemma, connection, new_target): new_target['phrase_type'], realization.alternation) if new_phrase_type_ref != old_phrase_type_ref: if realization.frame.id not in shared_schemata_ids: - operations.append(create_operation('disconnect', arg_ref, old_phrase_type_ref)) + if not exists_in_connected(lemma, frame, realization.frame): + operations.append(create_operation('disconnect', arg_ref, old_phrase_type_ref)) operations.append(create_operation('connect', arg_ref, new_phrase_type_ref)) return operations @@ -100,10 +101,20 @@ def get_disconnect_operations(lemma, connections): phrase_type_ref = create_phrase_type_ref(real.frame, real.position, real.argument, real.alternation) arg_ref = create_argument_ref(frame, compl) - operations.append(create_operation('disconnect', arg_ref, phrase_type_ref)) + if not exists_in_connected(lemma, frame, real.frame): + operations.append(create_operation('disconnect', arg_ref, phrase_type_ref)) return operations +def exists_in_connected(lemma, frame, schema): + entry = lemma.entry_obj + for e in entry.related_entries(): + if frame.id in [f.id for f in e.actual_frames()]: + if schema.id in [s.id for s in e.actual_schemata()]: + return True + return False + + def get_shared_schemata_ids(lemma): ids = [f.id for f in lemma.frames.all()] for connected in lemma.entry_obj.related_entries(): diff --git a/urls.py b/urls.py index 3f5ef79..d392ee2 100644 --- a/urls.py +++ b/urls.py @@ -9,8 +9,8 @@ from common.util import url from semantics.sem_urls import SEMANTIC_PATTERNS # Uncomment the next two lines to enable the admin: -from django.contrib import admin -admin.autodiscover() +#from django.contrib import admin +#admin.autodiscover() urlpatterns = patterns('', url(r'^accounts/settings/$', 'accounts.views.settings', name='settings'), @@ -31,7 +31,7 @@ urlpatterns = patterns('', # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: - (r'^admin/', include(admin.site.urls)), + #(r'^admin/', include(admin.site.urls)), url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL.lstrip('/'), 'django.views.static.serve',