Commit df14cb1ea03e77d0d5fa05a8ce8595221b04e161

Authored by janek37
1 parent 71a6fc6f

poprawka do wyświetlania odsyłaczy

dictionary/ajax_lexeme_view.py
... ... @@ -35,7 +35,7 @@ def inflection_tables(request, variant, lexeme_id):
35 35 'tables': tables,
36 36 'lexeme': lexeme,
37 37 'part_of_speech': pos_name,
38   - 'cross_references': lexeme.refs_to.order_by('type__index'),
  38 + 'cross_references': lexeme.cross_references(request.user),
39 39 'info': lexeme.sgjp_info(),
40 40 }
41 41  
... ... @@ -163,9 +163,7 @@ def lexeme_edit_form(request, id):
163 163 prefix='lip' + str(lip.pk), user=request.user, editable=editable),
164 164 lip.qualifiers.filter(vocabulary=owner) if ro_owner else [])
165 165 for lip in lips]
166   - crs = l.refs_to.order_by('type__index').filter(
167   - to_lexeme__vocabularies__in=visible_vocabularies(request.user))
168   - to_return['cross_references'] = crs
  166 + to_return['cross_references'] = l.cross_references(request.user)
169 167 return to_return
170 168  
171 169  
... ...
dictionary/models.py
... ... @@ -649,6 +649,10 @@ class Lexeme(Model):
649 649 def status_desc(self):
650 650 return dict(self.STATUS_CHOICES)[self.status]
651 651  
  652 + def cross_references(self, user):
  653 + return self.refs_to.order_by('type__index').distinct().filter(
  654 + to_lexeme__vocabularies__in=visible_vocabularies(user))
  655 +
652 656 def __unicode__(self):
653 657 return '%s (%s)' % (self.entry, self.part_of_speech.symbol)
654 658  
... ...