Commit 6edc7a103af55b1a3fc67a97f2a0ded35b00f7a2

Authored by Tomasz Bartosiak
1 parent 9d93a0e1

Generowanie listy haseł do sprawdzenia -- co mogło się poodpinać

dictionary/management/commands/moglo_sie_odpiac.py 0 → 100644
  1 +#-*- coding:utf-8 -*-
  2 +
  3 +from django.core.management.base import BaseCommand
  4 +from dictionary.models import Entry, Lemma, Lemma_Status
  5 +
  6 +class Command(BaseCommand):
  7 +
  8 + def handle(self, **options):
  9 + to_check()
  10 +
  11 +def to_check():
  12 + all = 0
  13 + semantic_statuses = [s.id for s in Lemma_Status.objects.filter(status__startswith='(S)')]
  14 + all_entries = {e.id: len(e.rel_entries.all()) for e in Entry.objects.all()}
  15 + potential_errors = [id for id in all_entries.keys() if all_entries[id] > 1]
  16 + for id in potential_errors:
  17 + in_semantics = []
  18 + e = Entry.objects.get(id=id)
  19 + if e.actual_lemma().status.id in semantic_statuses:
  20 + for re in e.rel_entries.all():
  21 + if len(re.lemmas.all()) > 0:
  22 + if re.actual_lemma().status.id in semantic_statuses:
  23 + in_semantics.append(re.name)
  24 + if len(in_semantics) > 1:
  25 + print ' '.join(in_semantics)
  26 + all += 1
  27 + # print all
... ...
... ... @@ -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',
... ...