Commit 8c5a757cb139fdeb4bc7ce8ef8d1d1c07529e772

Authored by Tomasz Bartosiak
1 parent 9d9ff22d

Sprawdzanie, kiedy można usunąć powiązanie między ramą i schematem + drobne poprawki w modelu

dictionary/models.py
... ... @@ -1406,7 +1406,7 @@ class Entry(Model):
1406 1406 )
1407 1407  
1408 1408 def all_der_entries(self):
1409   - rel_entries = Entry.objects.none()
  1409 + rel_entries = Entry.objects.filter(pk=self.pk)
1410 1410 if self.der_group is not None:
1411 1411 rel_entries = self.der_group.entries.all()
1412 1412 return rel_entries
... ...
dictionary/saving.py
... ... @@ -69,7 +69,8 @@ def reconnect_operations(lemma, connection, new_target):
69 69 new_target['phrase_type'], realization.alternation)
70 70 if new_phrase_type_ref != old_phrase_type_ref:
71 71 if realization.frame.id not in shared_schemata_ids:
72   - operations.append(create_operation('disconnect', arg_ref, old_phrase_type_ref))
  72 + if not exists_in_connected(lemma, frame, realization.frame):
  73 + operations.append(create_operation('disconnect', arg_ref, old_phrase_type_ref))
73 74 operations.append(create_operation('connect', arg_ref, new_phrase_type_ref))
74 75 return operations
75 76  
... ... @@ -100,10 +101,20 @@ def get_disconnect_operations(lemma, connections):
100 101 phrase_type_ref = create_phrase_type_ref(real.frame, real.position,
101 102 real.argument, real.alternation)
102 103 arg_ref = create_argument_ref(frame, compl)
103   - operations.append(create_operation('disconnect', arg_ref, phrase_type_ref))
  104 + if not exists_in_connected(lemma, frame, real.frame):
  105 + operations.append(create_operation('disconnect', arg_ref, phrase_type_ref))
104 106 return operations
105 107  
106 108  
  109 +def exists_in_connected(lemma, frame, schema):
  110 + entry = lemma.entry_obj
  111 + for e in entry.related_entries():
  112 + if frame.id in [f.id for f in e.actual_frames()]:
  113 + if schema.id in [s.id for s in e.actual_schemata()]:
  114 + return True
  115 + return False
  116 +
  117 +
107 118 def get_shared_schemata_ids(lemma):
108 119 ids = [f.id for f in lemma.frames.all()]
109 120 for connected in lemma.entry_obj.related_entries():
... ...
... ... @@ -9,8 +9,8 @@ from common.util import url
9 9 from semantics.sem_urls import SEMANTIC_PATTERNS
10 10  
11 11 # Uncomment the next two lines to enable the admin:
12   -from django.contrib import admin
13   -admin.autodiscover()
  12 +#from django.contrib import admin
  13 +#admin.autodiscover()
14 14  
15 15 urlpatterns = patterns('',
16 16 url(r'^accounts/settings/$', 'accounts.views.settings', name='settings'),
... ... @@ -31,7 +31,7 @@ urlpatterns = patterns('',
31 31 # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
32 32  
33 33 # Uncomment the next line to enable the admin:
34   - (r'^admin/', include(admin.site.urls)),
  34 + #(r'^admin/', include(admin.site.urls)),
35 35  
36 36 url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL.lstrip('/'),
37 37 'django.views.static.serve',
... ...