Commit b23fc478dc2f2c00f27383ebf0d5c19f31c4aa18

Authored by janek37
1 parent d2ada81a

dodawanie wzorow

dictionary/ajax_lexeme_view.py
... ... @@ -352,7 +352,8 @@ def update_lexeme(request, form_data, mask=''):
352 352 if not attr_values or attr_values.get() != av:
353 353 for av1 in attr_values:
354 354 av1.remove_lexeme(l)
355   - av.add_lexeme(l)
  355 + if av:
  356 + av.add_lexeme(l)
356 357 else:
357 358 raise AjaxError(error_messages(attr_form))
358 359 else:
... ... @@ -460,15 +461,10 @@ def create_lexeme(request, vocab_id):
460 461 next_id = Lexeme.all_objects.filter(
461 462 pk__gte=START_ID).aggregate(Max('id'))['id__max']
462 463 next_id = next_id + 1 if next_id else START_ID
463   - l = Lexeme()
464   - l.id = next_id
465   - l.homonym_number = 1 # zanim zostanie faktycznie stworzony
466   - l.part_of_speech = PartOfSpeech.objects.get(symbol='subst')
467   - l.owner_vocabulary = owner
468   - l.status = Lexeme.STATUS_CANDIDATE
469   - l.responsible = request.user
470   - l.deleted = True # proste i genialne!
471   - l.save()
  464 + l = Lexeme.objects.create(
  465 + id=next_id, homonym_number=1, part_of_speech_id='subst',
  466 + owner_vocabulary=owner, status=Lexeme.STATUS_CANDIDATE,
  467 + responsible=request.user, deleted=True)
472 468 owner.add_lexeme(l)
473 469 return {'id': l.id}
474 470  
... ...
dictionary/ajax_pattern_view.py
1 1 #-*- coding:utf-8 -*-
  2 +from common.util import error_messages
  3 +from common.decorators import render, ajax, AjaxError, render_ajax
2 4  
3 5 from dictionary.models import Pattern, Ending, BaseFormLabel, PatternType, \
4 6 editable_qualifiers, readonly_vocabularies
5   -from dictionary.forms import PatternEditForm, PatternTypeForm, QualifierForm
  7 +from dictionary.forms import PatternEditForm, QualifierForm
6 8 from dictionary.ajax_slickgrid import SlickGridQuery
7   -from common.decorators import render, ajax, AjaxError, render_ajax
8 9  
9 10  
10 11 class PatternQuery(SlickGridQuery):
... ... @@ -57,11 +58,10 @@ def pattern_edit_form(request, id):
57 58 if not request.user.has_perm('dictionary.view_pattern'):
58 59 raise AjaxError('access denied')
59 60 to_return = {}
60   - p = Pattern.objects.get(pk=id)
  61 + p = Pattern.all_objects.get(pk=id)
61 62 editable = request.user.has_perm('dictionary.change_pattern')
62 63 to_return['pattern'] = p
63 64 to_return['form'] = PatternEditForm(instance=p, editable=editable)
64   - to_return['type_form'] = PatternTypeForm(instance=p.type, editable=editable)
65 65 to_return['editable'] = editable
66 66 bfls = p.type.base_form_labels()
67 67 ending_groups = dict((bfl, []) for bfl in bfls)
... ... @@ -80,7 +80,7 @@ def pattern_edit_form(request, id):
80 80 @render('ending_row.html')
81 81 @ajax(method='get', encode_result=False)
82 82 def new_ending_row(request, pattern_id):
83   - p = Pattern.objects.get(id=pattern_id)
  83 + p = Pattern.all_objects.get(id=pattern_id)
84 84 ending = {'string': '', 'id': 'add-NUM'}
85 85 form = QualifierForm(user=request.user, prefix='add-NUM')
86 86 return {'ending': ending, 'editable': True, 'form': form, 'pattern': p}
... ... @@ -90,18 +90,11 @@ def update_pattern(request, form_data):
90 90 if not request.user.has_perm('dictionary.change_pattern'):
91 91 raise AjaxError('access denied')
92 92 form_dict = dict((x['name'], x['value']) for x in form_data)
93   - p = Pattern.objects.get(pk=form_dict['id'])
  93 + p = Pattern.all_objects.get(pk=form_dict['id'])
94 94 form = PatternEditForm(data=form_dict, instance=p)
95   - type_form = PatternTypeForm(data=form_dict)
96   - if type_form.is_valid():
97   - type_qs = PatternType.objects.filter(
98   - symbol=type_form.cleaned_data['symbol'],
99   - lexical_class=type_form.cleaned_data['lexical_class'])
100   - else:
101   - raise AjaxError('invalid data')
102   - if form.is_valid() and len(type_qs) == 1:
  95 + if form.is_valid():
103 96 form.save()
104   - p.type = type_qs[0]
  97 + p.deleted = False
105 98 p.save()
106 99 for ending_pk in form_dict['deleted']:
107 100 Ending.objects.get(pk=int(ending_pk)).delete()
... ... @@ -128,10 +121,22 @@ def update_pattern(request, form_data):
128 121 qualifier.set_for(ending, qualifier.pk in quals)
129 122 endings.append(ending)
130 123 else:
131   - raise AjaxError('invalid data')
  124 + raise AjaxError(error_messages(form))
132 125 return {}
133 126  
134 127 @ajax(method='post')
135 128 def save_columns(request, columns):
136 129 request.session['pattern-columns'] = columns
137 130 return {}
  131 +
  132 +@ajax(method='post')
  133 +def create_pattern(request):
  134 + new_name = u'nowy wzór %s'
  135 + i = 1
  136 + while Pattern.all_objects.filter(name=new_name % i).exists():
  137 + i += 1
  138 + pt = PatternType.objects.get(lexical_class_id='subst', symbol='m')
  139 + p = Pattern.objects.create(
  140 + name=new_name % i, type=pt, example='...', status = 'nowy',
  141 + deleted=True)
  142 + return {'id': p.id}
138 143 \ No newline at end of file
... ...
dictionary/forms.py
... ... @@ -438,29 +438,17 @@ class VocabularyForm(Form):
438 438 class PatternEditForm(ModelForm):
439 439 def __init__(self, editable=True, **kwargs):
440 440 super(PatternEditForm, self).__init__(**kwargs)
  441 + self.fields['type'].choices = PatternType.options()
441 442 if not editable:
442 443 instance = getattr(self, 'instance', None)
443 444 if instance and instance.id:
444   - for _name, field in self.fields.iteritems():
  445 + for name, field in self.fields.iteritems():
445 446 disable_field(field)
446 447  
447 448 class Meta:
448 449 model = Pattern
449   - fields = ('name', 'example', 'basic_form_ending', 'status', 'comment')
450   -
451   -
452   -class PatternTypeForm(ModelForm):
453   - def __init__(self, editable=True, **kwargs):
454   - super(PatternTypeForm, self).__init__(**kwargs)
455   - if not editable:
456   - instance = getattr(self, 'instance', None)
457   - if instance and instance.id:
458   - for _name, field in self.fields.iteritems():
459   - disable_field(field)
460   -
461   - class Meta:
462   - model = PatternType
463   - fields = ('lexical_class', 'symbol')
  450 + fields = (
  451 + 'type', 'name', 'example', 'basic_form_ending', 'status', 'comment')
464 452  
465 453  
466 454 class QualifierForm(Form):
... ...
dictionary/history.py
... ... @@ -116,7 +116,7 @@ def prepare_value(table, column, value):
116 116 elif column == 'gender_id':
117 117 prepared = Gender.objects.get(id=int(value)).symbol
118 118 elif column == 'w_id':
119   - prepared = Pattern.objects.get(id=int(value)).name
  119 + prepared = Pattern.all_objects.get(id=int(value)).name
120 120 elif column in ('classification_value_id', 'classificationvalue_id'):
121 121 cv = ClassificationValue.all_objects.get(id=int(value))
122 122 prepared = (cv.label, cv.classification.name)
... ... @@ -262,7 +262,7 @@ def transaction_table(transaction_data):
262 262 gender_id = records.get(column_name='gender_id').old_value
263 263 pattern_id = records.get(column_name='w_id').old_value
264 264 gender = Gender.objects.get(id=gender_id)
265   - pattern = Pattern.objects.get(id=pattern_id)
  265 + pattern = Pattern.all_objects.get(id=pattern_id)
266 266 header = lip_header(gender, pattern)
267 267 except ObjectDoesNotExist: # stare DELETE...
268 268 header = ''
... ...
dictionary/migrations/0059_auto__add_field_pattern_deleted.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +import datetime
  3 +from south.db import db
  4 +from south.v2 import SchemaMigration
  5 +from django.db import models
  6 +
  7 +
  8 +class Migration(SchemaMigration):
  9 +
  10 + def forwards(self, orm):
  11 + # Adding field 'Pattern.deleted'
  12 + db.add_column('wzory', 'deleted',
  13 + self.gf('django.db.models.fields.BooleanField')(default=False),
  14 + keep_default=False)
  15 +
  16 +
  17 + def backwards(self, orm):
  18 + # Deleting field 'Pattern.deleted'
  19 + db.delete_column('wzory', 'deleted')
  20 +
  21 +
  22 + models = {
  23 + u'auth.group': {
  24 + 'Meta': {'object_name': 'Group'},
  25 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  26 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
  27 + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
  28 + },
  29 + u'auth.permission': {
  30 + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
  31 + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  32 + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
  33 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  34 + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
  35 + },
  36 + u'auth.user': {
  37 + 'Meta': {'object_name': 'User'},
  38 + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  39 + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
  40 + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  41 + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
  42 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  43 + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
  44 + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  45 + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  46 + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  47 + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  48 + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
  49 + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
  50 + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
  51 + },
  52 + u'contenttypes.contenttype': {
  53 + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
  54 + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  55 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  56 + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  57 + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
  58 + },
  59 + u'dictionary.baseformlabel': {
  60 + 'Meta': {'object_name': 'BaseFormLabel', 'db_table': "'efobazy'"},
  61 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  62 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_column': "'efobaz'", 'blank': 'True'})
  63 + },
  64 + u'dictionary.classification': {
  65 + 'Meta': {'object_name': 'Classification', 'db_table': "'klasyfikacje'"},
  66 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  67 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_column': "'nazwa'"}),
  68 + 'parts_of_speech': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PartOfSpeech']", 'symmetrical': 'False'})
  69 + },
  70 + u'dictionary.classificationvalue': {
  71 + 'Meta': {'object_name': 'ClassificationValue', 'db_table': "'wartosci_klasyfikacji'"},
  72 + 'classification': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'values'", 'db_column': "'klas_id'", 'to': u"orm['dictionary.Classification']"}),
  73 + 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_column': "'usunieta'"}),
  74 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  75 + 'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_column': "'nazwa'"}),
  76 + 'lexemes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Lexeme']", 'symmetrical': 'False', 'through': u"orm['dictionary.LexemeCV']", 'blank': 'True'}),
  77 + 'parent_node': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'child_nodes'", 'null': 'True', 'db_column': "'rodzic'", 'to': u"orm['dictionary.ClassificationValue']"})
  78 + },
  79 + u'dictionary.crossreference': {
  80 + 'Meta': {'object_name': 'CrossReference', 'db_table': "'odsylacze'"},
  81 + 'from_lexeme': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'refs_to'", 'db_column': "'l_id_od'", 'to': u"orm['dictionary.Lexeme']"}),
  82 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  83 + 'to_lexeme': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'refs_from'", 'db_column': "'l_id_do'", 'to': u"orm['dictionary.Lexeme']"}),
  84 + 'type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.CrossReferenceType']", 'db_column': "'typods_id'"})
  85 + },
  86 + u'dictionary.crossreferencetype': {
  87 + 'Meta': {'object_name': 'CrossReferenceType', 'db_table': "'typyodsylaczy'"},
  88 + 'desc': ('django.db.models.fields.CharField', [], {'max_length': '40', 'db_column': "'naglowek'"}),
  89 + 'from_pos': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'crtype_to'", 'db_column': "'pos1'", 'to': u"orm['dictionary.PartOfSpeech']"}),
  90 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  91 + 'index': ('django.db.models.fields.IntegerField', [], {'db_column': "'kolejnosc'"}),
  92 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '10', 'db_column': "'typods'"}),
  93 + 'to_pos': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'crtype_from'", 'db_column': "'pos2'", 'to': u"orm['dictionary.PartOfSpeech']"})
  94 + },
  95 + u'dictionary.ending': {
  96 + 'Meta': {'ordering': "['index']", 'unique_together': "(('pattern', 'base_form_label', 'index'),)", 'object_name': 'Ending', 'db_table': "'zakonczenia'"},
  97 + 'base_form_label': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']", 'db_column': "'efobaz'"}),
  98 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  99 + 'index': ('django.db.models.fields.IntegerField', [], {'db_column': "'zind'"}),
  100 + 'pattern': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'endings'", 'db_column': "'w_id'", 'to': u"orm['dictionary.Pattern']"}),
  101 + 'qualifiers': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Qualifier']", 'symmetrical': 'False', 'db_table': "'kwalifikatory_zakonczen'", 'blank': 'True'}),
  102 + 'string': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_column': "'zak'", 'blank': 'True'})
  103 + },
  104 + u'dictionary.exportcell': {
  105 + 'Meta': {'object_name': 'ExportCell'},
  106 + 'attribute_values': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.LexemeAttributeValue']", 'symmetrical': 'False'}),
  107 + 'base_form_label': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']"}),
  108 + 'genders': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Gender']", 'symmetrical': 'False'}),
  109 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  110 + 'pattern_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PatternType']", 'symmetrical': 'False'}),
  111 + 'prefix': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  112 + 'suffix': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  113 + 'table_template': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'export_cells'", 'to': u"orm['dictionary.TableTemplate']"}),
  114 + 'tag_template': ('django.db.models.fields.TextField', [], {})
  115 + },
  116 + u'dictionary.gender': {
  117 + 'Meta': {'object_name': 'Gender'},
  118 + 'basic_form_label': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']"}),
  119 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  120 + 'symbol': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '4'})
  121 + },
  122 + u'dictionary.history': {
  123 + 'Meta': {'object_name': 'History', 'db_table': "'history'"},
  124 + 'column_name': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_column': "'column_name_'", 'blank': 'True'}),
  125 + 'column_ord': ('django.db.models.fields.IntegerField', [], {'db_column': "'ordinal_position_of_column_'"}),
  126 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  127 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']", 'null': 'True', 'db_column': "'lexeme_id_'", 'blank': 'True'}),
  128 + 'new_value': ('django.db.models.fields.TextField', [], {'db_column': "'new_value_'", 'blank': 'True'}),
  129 + 'old_value': ('django.db.models.fields.TextField', [], {'db_column': "'old_value_'", 'blank': 'True'}),
  130 + 'operation': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_column': "'operation_'"}),
  131 + 'pattern': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Pattern']", 'null': 'True', 'db_column': "'pattern_id_'", 'blank': 'True'}),
  132 + 'row_id': ('django.db.models.fields.IntegerField', [], {'db_column': "'id_'"}),
  133 + 'table_name': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_column': "'table_name_'"}),
  134 + 'table_oid': ('django.db.models.fields.IntegerField', [], {'db_column': "'table_oid_'"}),
  135 + 'timestamp': ('django.db.models.fields.DateTimeField', [], {'db_column': "'timestamp_'"}),
  136 + 'transaction_began': ('django.db.models.fields.DateTimeField', [], {'db_column': "'transaction_began_'"}),
  137 + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'db_column': "'user_id_'"})
  138 + },
  139 + u'dictionary.inflectioncharacteristic': {
  140 + 'Meta': {'unique_together': "(('symbol', 'part_of_speech'),)", 'object_name': 'InflectionCharacteristic', 'db_table': "'charfle'"},
  141 + 'basic_form_label': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']", 'db_column': "'efobaz'"}),
  142 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  143 + 'part_of_speech': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.PartOfSpeech']", 'db_column': "'pos'"}),
  144 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_column': "'charfl'", 'blank': 'True'})
  145 + },
  146 + u'dictionary.inputform': {
  147 + 'Meta': {'object_name': 'InputForm'},
  148 + 'form': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}),
  149 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  150 + 'input_lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.InputLexeme']"})
  151 + },
  152 + u'dictionary.inputlexeme': {
  153 + 'Meta': {'object_name': 'InputLexeme'},
  154 + 'entry': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_index': 'True'}),
  155 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
  156 + },
  157 + u'dictionary.lexeme': {
  158 + 'Meta': {'object_name': 'Lexeme', 'db_table': "'leksemy'"},
  159 + 'comment': ('django.db.models.fields.TextField', [], {'db_column': "'komentarz'", 'blank': 'True'}),
  160 + 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_column': "'usuniety'"}),
  161 + 'entry': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '64', 'db_column': "'haslo'", 'blank': 'True'}),
  162 + 'entry_suffix': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_column': "'haslosuf'", 'blank': 'True'}),
  163 + 'gloss': ('django.db.models.fields.TextField', [], {'db_column': "'glosa'", 'blank': 'True'}),
  164 + 'homonym_number': ('django.db.models.fields.IntegerField', [], {'default': '1', 'db_column': "'hom'"}),
  165 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  166 + 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_column': "'data_modyfikacji'", 'blank': 'True'}),
  167 + 'note': ('django.db.models.fields.TextField', [], {'db_column': "'nota'", 'blank': 'True'}),
  168 + 'owner_vocabulary': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'owned_lexemes'", 'db_column': "'slownik'", 'to': u"orm['dictionary.Vocabulary']"}),
  169 + 'part_of_speech': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.PartOfSpeech']", 'db_column': "'pos'"}),
  170 + 'patterns': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Pattern']", 'through': u"orm['dictionary.LexemeInflectionPattern']", 'symmetrical': 'False'}),
  171 + 'pronunciation': ('django.db.models.fields.TextField', [], {'db_column': "'wymowa'", 'blank': 'True'}),
  172 + 'qualifiers': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Qualifier']", 'symmetrical': 'False', 'db_table': "'kwalifikatory_leksemow'", 'blank': 'True'}),
  173 + 'qualifiers_cache': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'all_lexemes'", 'symmetrical': 'False', 'through': u"orm['dictionary.LexemeFormQualifier']", 'to': u"orm['dictionary.Qualifier']"}),
  174 + 'qualifiers_dor': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
  175 + 'qualifiers_scope': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
  176 + 'qualifiers_style': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
  177 + 'responsible': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'db_column': "'odpowiedzialny'", 'blank': 'True'}),
  178 + 'source': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'zrodlo'", 'blank': 'True'}),
  179 + 'source_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
  180 + 'status': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_column': "'status'"}),
  181 + 'valence': ('django.db.models.fields.TextField', [], {'blank': 'True'})
  182 + },
  183 + u'dictionary.lexemeassociation': {
  184 + 'Meta': {'unique_together': "(['lexeme', 'vocabulary'],)", 'object_name': 'LexemeAssociation', 'db_table': "'leksemy_w_slownikach'"},
  185 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  186 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']", 'db_column': "'l_id'"}),
  187 + 'vocabulary': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Vocabulary']", 'db_column': "'slownik'"})
  188 + },
  189 + u'dictionary.lexemeattribute': {
  190 + 'Meta': {'object_name': 'LexemeAttribute'},
  191 + 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  192 + 'genders': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Gender']", 'symmetrical': 'False', 'blank': 'True'}),
  193 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  194 + 'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  195 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}),
  196 + 'parts_of_speech': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PartOfSpeech']", 'symmetrical': 'False'}),
  197 + 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  198 + 'takes_gender': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
  199 + },
  200 + u'dictionary.lexemeattributevalue': {
  201 + 'Meta': {'ordering': "['value']", 'object_name': 'LexemeAttributeValue'},
  202 + 'attribute': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'values'", 'to': u"orm['dictionary.LexemeAttribute']"}),
  203 + 'display_value': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
  204 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  205 + 'lexemes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Lexeme']", 'symmetrical': 'False', 'through': u"orm['dictionary.LexemeAV']", 'blank': 'True'}),
  206 + 'value': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'})
  207 + },
  208 + u'dictionary.lexemeav': {
  209 + 'Meta': {'unique_together': "(['lexeme', 'attribute_value'],)", 'object_name': 'LexemeAV'},
  210 + 'attribute_value': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.LexemeAttributeValue']"}),
  211 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  212 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']"})
  213 + },
  214 + u'dictionary.lexemecv': {
  215 + 'Meta': {'unique_together': "(['lexeme', 'classification_value'],)", 'object_name': 'LexemeCV'},
  216 + 'classification_value': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.ClassificationValue']"}),
  217 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  218 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']"})
  219 + },
  220 + u'dictionary.lexemeform': {
  221 + 'Meta': {'object_name': 'LexemeForm'},
  222 + 'form': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_index': 'True'}),
  223 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  224 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']"})
  225 + },
  226 + u'dictionary.lexemeformqualifier': {
  227 + 'Meta': {'object_name': 'LexemeFormQualifier'},
  228 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  229 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']"}),
  230 + 'qualifier': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Qualifier']"})
  231 + },
  232 + u'dictionary.lexemeinflectionpattern': {
  233 + 'Meta': {'ordering': "['index']", 'unique_together': "(('lexeme', 'index'),)", 'object_name': 'LexemeInflectionPattern', 'db_table': "'odmieniasie'"},
  234 + 'gender': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Gender']", 'null': 'True', 'blank': 'True'}),
  235 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  236 + 'index': ('django.db.models.fields.IntegerField', [], {'db_column': "'oind'"}),
  237 + 'lexeme': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Lexeme']", 'db_column': "'l_id'"}),
  238 + 'pattern': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Pattern']", 'db_column': "'w_id'"}),
  239 + 'qualifiers': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Qualifier']", 'symmetrical': 'False', 'db_table': "'kwalifikatory_odmieniasiow'", 'blank': 'True'}),
  240 + 'root': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'rdzen'"})
  241 + },
  242 + u'dictionary.lexicalclass': {
  243 + 'Meta': {'object_name': 'LexicalClass', 'db_table': "'czescimowy'"},
  244 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '16', 'primary_key': 'True', 'db_column': "'czm'"})
  245 + },
  246 + u'dictionary.paradygmatywsjp': {
  247 + 'Meta': {'object_name': 'ParadygmatyWSJP', 'db_table': "'paradygmatywsjp'"},
  248 + 'charfl': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.InflectionCharacteristic']", 'db_column': "'charfl'"}),
  249 + 'col': ('django.db.models.fields.IntegerField', [], {}),
  250 + 'colspan': ('django.db.models.fields.IntegerField', [], {}),
  251 + 'efobaz': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']", 'db_column': "'efobaz'"}),
  252 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  253 + 'kskl': ('django.db.models.fields.IntegerField', [], {}),
  254 + 'morf': ('django.db.models.fields.TextField', [], {}),
  255 + 'podparad': ('django.db.models.fields.CharField', [], {'max_length': '4', 'blank': 'True'}),
  256 + 'pref': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  257 + 'row': ('django.db.models.fields.IntegerField', [], {}),
  258 + 'rowspan': ('django.db.models.fields.IntegerField', [], {}),
  259 + 'suf': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  260 + 'typr': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.PatternType']", 'db_column': "'typr'"}),
  261 + 'wariant': ('django.db.models.fields.CharField', [], {'max_length': '4'})
  262 + },
  263 + u'dictionary.partofspeech': {
  264 + 'Meta': {'ordering': "['index']", 'object_name': 'PartOfSpeech', 'db_table': "'klasygramatyczne'"},
  265 + 'color_scheme': ('django.db.models.fields.IntegerField', [], {}),
  266 + 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'db_column': "'nazwa'"}),
  267 + 'index': ('django.db.models.fields.IntegerField', [], {}),
  268 + 'lexical_class': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.LexicalClass']", 'db_column': "'czm'"}),
  269 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '16', 'primary_key': 'True', 'db_column': "'pos'"})
  270 + },
  271 + u'dictionary.pattern': {
  272 + 'Meta': {'ordering': "['name']", 'object_name': 'Pattern', 'db_table': "'wzory'"},
  273 + 'basic_form_ending': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_column': "'zakp'", 'blank': 'True'}),
  274 + 'comment': ('django.db.models.fields.TextField', [], {'db_column': "'komentarz'", 'blank': 'True'}),
  275 + 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  276 + 'example': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'przyklad'"}),
  277 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  278 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_column': "'w_id'"}),
  279 + 'status': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
  280 + 'type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.PatternType']", 'db_column': "'typ'"})
  281 + },
  282 + u'dictionary.patterntype': {
  283 + 'Meta': {'object_name': 'PatternType', 'db_table': "'typywzorow'"},
  284 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  285 + 'lexical_class': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.LexicalClass']", 'db_column': "'czm'"}),
  286 + 'symbol': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_column': "'wtyp'", 'blank': 'True'})
  287 + },
  288 + u'dictionary.qualifier': {
  289 + 'Meta': {'ordering': "['label']", 'unique_together': "(('label', 'vocabulary'),)", 'object_name': 'Qualifier', 'db_table': "'kwalifikatory'"},
  290 + 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_column': "'usuniety'"}),
  291 + 'exclusion_class': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.QualifierExclusionClass']", 'null': 'True', 'db_column': "'klasa'", 'blank': 'True'}),
  292 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  293 + 'label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'kwal'"}),
  294 + 'type': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
  295 + 'vocabulary': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'qualifiers'", 'db_column': "'slownik'", 'to': u"orm['dictionary.Vocabulary']"})
  296 + },
  297 + u'dictionary.qualifierexclusionclass': {
  298 + 'Meta': {'object_name': 'QualifierExclusionClass', 'db_table': "'klasy_wykluczania'"},
  299 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  300 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_column': "'nazwa'"}),
  301 + 'vocabulary': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Vocabulary']", 'db_column': "'slownik'"})
  302 + },
  303 + u'dictionary.savedexportdata': {
  304 + 'Meta': {'object_name': 'SavedExportData'},
  305 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  306 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
  307 + 'serialized_data': ('django.db.models.fields.TextField', [], {})
  308 + },
  309 + u'dictionary.savedfilter': {
  310 + 'Meta': {'unique_together': "(('name', 'user'),)", 'object_name': 'SavedFilter'},
  311 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  312 + 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
  313 + 'serialized_filter': ('django.db.models.fields.TextField', [], {}),
  314 + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
  315 + },
  316 + u'dictionary.tablecell': {
  317 + 'Meta': {'object_name': 'TableCell'},
  318 + 'attribute_values': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.LexemeAttributeValue']", 'symmetrical': 'False'}),
  319 + 'base_form_label': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.BaseFormLabel']"}),
  320 + 'col': ('django.db.models.fields.IntegerField', [], {}),
  321 + 'colspan': ('django.db.models.fields.IntegerField', [], {}),
  322 + 'genders': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Gender']", 'symmetrical': 'False'}),
  323 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  324 + 'index': ('django.db.models.fields.IntegerField', [], {}),
  325 + 'pattern_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PatternType']", 'symmetrical': 'False'}),
  326 + 'prefix': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  327 + 'row': ('django.db.models.fields.IntegerField', [], {}),
  328 + 'rowspan': ('django.db.models.fields.IntegerField', [], {}),
  329 + 'suffix': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
  330 + 'table_template': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'table_cells'", 'to': u"orm['dictionary.TableTemplate']"})
  331 + },
  332 + u'dictionary.tableheader': {
  333 + 'Meta': {'object_name': 'TableHeader'},
  334 + 'attribute_values': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.LexemeAttributeValue']", 'symmetrical': 'False'}),
  335 + 'col': ('django.db.models.fields.IntegerField', [], {}),
  336 + 'colspan': ('django.db.models.fields.IntegerField', [], {}),
  337 + 'css_class': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_column': "'styl'"}),
  338 + 'genders': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.Gender']", 'symmetrical': 'False'}),
  339 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  340 + 'label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'nagl'", 'blank': 'True'}),
  341 + 'pattern_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PatternType']", 'symmetrical': 'False'}),
  342 + 'row': ('django.db.models.fields.IntegerField', [], {}),
  343 + 'rowspan': ('django.db.models.fields.IntegerField', [], {}),
  344 + 'table_template': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'headers'", 'to': u"orm['dictionary.TableTemplate']"})
  345 + },
  346 + u'dictionary.tabletemplate': {
  347 + 'Meta': {'object_name': 'TableTemplate'},
  348 + 'attribute_values': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.LexemeAttributeValue']", 'symmetrical': 'False'}),
  349 + 'attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.LexemeAttribute']", 'symmetrical': 'False'}),
  350 + 'cell_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'templates'", 'symmetrical': 'False', 'to': u"orm['dictionary.LexemeAttribute']"}),
  351 + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  352 + 'name': ('django.db.models.fields.TextField', [], {}),
  353 + 'parts_of_speech': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PartOfSpeech']", 'symmetrical': 'False'}),
  354 + 'pattern_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['dictionary.PatternType']", 'symmetrical': 'False'}),
  355 + 'takes_gender': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  356 + 'variant': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['dictionary.Variant']"})
  357 + },
  358 + u'dictionary.variant': {
  359 + 'Meta': {'object_name': 'Variant', 'db_table': "'warianty'"},
  360 + 'id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'primary_key': 'True', 'db_column': "'wariant'"}),
  361 + 'type': ('django.db.models.fields.CharField', [], {'max_length': '10'})
  362 + },
  363 + u'dictionary.vocabulary': {
  364 + 'Meta': {'ordering': "['id']", 'object_name': 'Vocabulary', 'db_table': "'slowniki'"},
  365 + 'classifications': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'vocabularies'", 'blank': 'True', 'to': u"orm['dictionary.Classification']"}),
  366 + 'editors': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'editable_vocabularies'", 'blank': 'True', 'to': u"orm['auth.User']"}),
  367 + 'id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'primary_key': 'True', 'db_column': "'slownik'"}),
  368 + 'lexemes': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'vocabularies'", 'blank': 'True', 'through': u"orm['dictionary.LexemeAssociation']", 'to': u"orm['dictionary.Lexeme']"}),
  369 + 'managers': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'managed_vocabularies'", 'blank': 'True', 'to': u"orm['auth.User']"}),
  370 + 'viewers': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'visible_vocabularies'", 'blank': 'True', 'to': u"orm['auth.User']"})
  371 + }
  372 + }
  373 +
  374 + complete_apps = ['dictionary']
0 375 \ No newline at end of file
... ...
dictionary/models.py
... ... @@ -21,11 +21,18 @@ class LexemeNotDeletedManager(Manager):
21 21 use_for_related_field = True
22 22  
23 23 def get_query_set(self):
24   - return super(
25   - LexemeNotDeletedManager, self).get_query_set().filter(
  24 + return super(LexemeNotDeletedManager, self).get_query_set().filter(
26 25 lexeme__deleted=False)
27 26  
28 27  
  28 +class PatternNotDeletedManager(Manager):
  29 + use_for_related_field = True
  30 +
  31 + def get_query_set(self):
  32 + return super(PatternNotDeletedManager, self).get_query_set().filter(
  33 + pattern__deleted=False)
  34 +
  35 +
29 36 class LexicalClass(Model):
30 37 symbol = CharField(primary_key=True, max_length=16, db_column='czm')
31 38  
... ... @@ -278,6 +285,13 @@ class PatternType(Model):
278 285 for bfl in bfls)
279 286 return bfl_dict
280 287  
  288 + @classmethod
  289 + def options(cls):
  290 + pattern_types = GroupDict()
  291 + for pt in cls.objects.all():
  292 + pattern_types.add(pt.lexical_class.symbol, (pt.id, unicode(pt)))
  293 + pattern_type_options = pattern_types.items()
  294 + return pattern_type_options
281 295  
282 296 def __unicode__(self):
283 297 return self.symbol.replace('"', "''") or '[%s]' % self.lexical_class_id
... ... @@ -295,10 +309,10 @@ class Pattern(Model):
295 309 # kiedyś trzeba zrobić porządek w nazwach.
296 310 name = CharField(
297 311 max_length=32, unique=True, db_column='w_id', verbose_name=u'nazwa')
298   - type = ForeignKey(PatternType, db_column='typ')
  312 + type = ForeignKey(PatternType, db_column='typ', verbose_name=u'typ')
299 313 # rdzeń przykładowej formy hasłowej
300 314 example = CharField(max_length=64, db_column='przyklad',
301   - verbose_name=u'przyklad')
  315 + verbose_name=u'przykład')
302 316 # zakończenie formy podstawowej (uwaga: w zasadzie tylko dla prezentacji
303 317 # wzoru, rdzenie w Odmieniasie trzeba tworzyć uważniej, wiedząc, która forma
304 318 # jest hasłowa dla danego rodzaju)
... ... @@ -310,6 +324,10 @@ class Pattern(Model):
310 324 max_length=8, choices=PATTERN_STATUS_CHOICES, verbose_name=u'status')
311 325 comment = TextField(blank=True, db_column='komentarz',
312 326 verbose_name=u'komentarz')
  327 + deleted = BooleanField()
  328 +
  329 + objects = NotDeletedManager()
  330 + all_objects = Manager()
313 331  
314 332 def ending_set(self, subroot='', tag_prefix=None):
315 333 endings = self.endings
... ... @@ -379,6 +397,9 @@ class Ending(Model):
379 397 qualifiers = ManyToManyField(
380 398 Qualifier, blank=True, db_table='kwalifikatory_zakonczen')
381 399  
  400 + objects = PatternNotDeletedManager()
  401 + all_objects = Manager()
  402 +
382 403 def editable_vocabularies(self, user):
383 404 return editable_vocabularies(user)
384 405  
... ...
dictionary/templates/lexeme_view.html
... ... @@ -61,9 +61,9 @@
61 61 <span class="ui-icon ui-icon-search">szukaj</span>
62 62 </button>
63 63 {% if perms.dictionary.change_lexeme %}
64   - <button id="action-button" title="akcje grupowe">
  64 + <!--button id="action-button" title="akcje grupowe">
65 65 <span class="ui-icon ui-icon-star">akcje grupowe</span>
66   - </button>
  66 + </button-->
67 67 <button id="add-button" title="dodaj leksem">
68 68 <span class="ui-icon ui-icon-plus">dodaj leksem</span>
69 69 </button>
... ...
dictionary/templates/pattern_view.html
... ... @@ -55,6 +55,11 @@
55 55 <button id="search-button" title="szukaj">
56 56 <span class="ui-icon ui-icon-search">szukaj</span>
57 57 </button>
  58 + {% if perms.dictionary.change_pattern %}
  59 + <button id="add-button" title="dodaj wzór">
  60 + <span class="ui-icon ui-icon-plus">dodaj wzór</span>
  61 + </button>
  62 + {% endif %}
58 63 </div>
59 64 <div id="pattern-grid"></div>
60 65 </div>
... ...
dictionary/views.py
... ... @@ -73,10 +73,6 @@ def lexeme_view(request):
73 73 attr['options'] = [(0, u'(puste)')] + [
74 74 (v.id, v.value) for v in la.values.all()]
75 75 extra_attrs.append(attr)
76   - pattern_types = GroupDict()
77   - for pt in PatternType.objects.all():
78   - pattern_types.add(pt.lexical_class.symbol, (pt.id, unicode(pt)))
79   - pattern_type_options = pattern_types.items()
80 76 js_vars = {
81 77 'ajax_get_page': reverse('get_lexemes'),
82 78 'ajax_inflection_tables': reverse('inflection_tables'),
... ... @@ -117,7 +113,7 @@ def lexeme_view(request):
117 113 'status_options': Lexeme.STATUS_CHOICES,
118 114 'cr_type_options': cr_type_options,
119 115 'gender_options': [(g.id, g.symbol) for g in Gender.objects.all()],
120   - 'pattern_type_options': pattern_type_options,
  116 + 'pattern_type_options': PatternType.options(),
121 117 'commonness': Classification.objects.get(name=u'pospolitość').pk,
122 118 'exclusion_classes': exclusion_classes,
123 119 'filtering_mode': request.user.usersettings.filter_search,
... ... @@ -137,9 +133,6 @@ def pattern_view(request):
137 133 lexical_class_options = [
138 134 (lc.symbol, lc.symbol) for lc in LexicalClass.objects.all()]
139 135 pattern_types = GroupDict()
140   - for pt in PatternType.objects.all():
141   - pattern_types.add(pt.lexical_class.symbol, (pt.id, unicode(pt)))
142   - pattern_type_options = pattern_types.items()
143 136 editable_vocabs = editable_vocabularies(request.user)
144 137 vocabs = {}
145 138 for v in editable_vocabs:
... ... @@ -151,11 +144,12 @@ def pattern_view(request):
151 144 'ajax_search_index': reverse('patterns_search_index'),
152 145 'ajax_save_columns': reverse('patterns_save_columns'),
153 146 'ajax_new_ending_row': reverse('new_ending_row'),
  147 + 'ajax_create_pattern': reverse('create_pattern'),
154 148 'exclusion_classes': get_exclusion_classes(),
155 149 'filtering_mode': request.user.usersettings.filter_search,
156 150 'auto_search': request.user.usersettings.incremental_search,
157 151 'lexical_class_options': lexical_class_options,
158   - 'pattern_type_options': pattern_type_options,
  152 + 'pattern_type_options': PatternType.options(),
159 153 'vocabs': vocabs,
160 154 }
161 155 session_variables = (
... ...
media/js/pattern-edit.js
... ... @@ -41,9 +41,10 @@ $.extend(edit, {
41 41 $(this).find('select[multiple]').multiselect2('close');
42 42 $('#id_new_owner').selectmenu('close');
43 43 });
  44 + $('#add-button').click(add_pattern);
44 45 },
45 46  
46   - load_content: function(id, check_callback) {
  47 + load_content: function(id, is_created, check_callback) {
47 48 "use strict";
48 49 $.ajaxJSON({
49 50 method: 'get',
... ... @@ -52,7 +53,7 @@ $.extend(edit, {
52 53 data: {id: id},
53 54 callback: function () {
54 55 edit.form_init();
55   - //created = Boolean(is_created);
  56 + edit.created = Boolean(is_created);
56 57 },
57 58 check_callback: check_callback
58 59 });
... ... @@ -125,4 +126,18 @@ $.extend(edit, {
125 126 });
126 127 return false;
127 128 }
128   -});
129 129 \ No newline at end of file
  130 +});
  131 +
  132 +function add_pattern() {
  133 + "use strict";
  134 + // stworzyć ajaxem nowy wzór i go po prostu otworzyć...
  135 + $.ajaxJSON({
  136 + method: 'post',
  137 + url: $dj.ajax_create_pattern,
  138 + data: {},
  139 + description: "Utworzenie wzoru",
  140 + callback: function (data) {
  141 + edit.load_content(data.id, true);
  142 + }
  143 + });
  144 +}
130 145 \ No newline at end of file
... ...
... ... @@ -76,6 +76,7 @@ urlpatterns += patterns(&#39;dictionary.ajax_pattern_view&#39;,
76 76 url(r'^ajax/patterns/pattern-edit-form/$', 'pattern_edit_form'),
77 77 url(r'^ajax/patterns/new-ending-row/$', 'new_ending_row'),
78 78 url(r'^ajax/update-pattern/$', 'update_pattern'),
  79 + url(r'^ajax/create-pattern/$', 'create_pattern'),
79 80 )
80 81  
81 82 urlpatterns += patterns('dictionary.ajax_export',
... ...