Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card search filter adjustments #356

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/management/commands/generate_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def generate_settings(opt={}):
},
'songs_max_stats': models.Song.objects.order_by('-expert_notes')[0].expert_notes,
'idols': ValuesQuerySetToDict(models.Card.objects.values('name', 'idol__japanese_name').annotate(total=Count('name')).order_by('-idol__main', 'idol__main_unit', '-idol__sub_unit', '-idol__school', 'idol__year', 'idol__name')),
'main_units': [card['main_unit'] for card in models.Idol.objects.filter(main_unit__isnull=False).values('main_unit').distinct()],
'sub_units': [card['sub_unit'] for card in models.Idol.objects.filter(sub_unit__isnull=False).values('sub_unit').distinct()],
'years': [idol['year'] for idol in models.Idol.objects.filter(year__isnull=False).values('year').distinct()],
'schools': [idol['school'] for idol in models.Idol.objects.filter(school__isnull=False).values('school').distinct()],
Expand Down
16 changes: 7 additions & 9 deletions web/templates/cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script src="{{ static_url }}static/bower/CuteForm/cuteform.js"></script>
<script>
cuteform($('#id_attribute'), {
'tooltip': 'text',
'images': {
'': '{{ static_url }}static/empty.png',
{% for i, attribute in filters.attribute_choices %}
Expand All @@ -17,6 +18,7 @@
}
});
cuteform($('#id_rarity'), {
'tooltip': 'text',
'images': {
'': '{{ static_url }}static/empty.png',
{% for rarity, _ in filters.rarity_choices %}
Expand All @@ -25,6 +27,7 @@
}
});
cuteform($('#id_sub_unit'), {
'tooltip': 'text',
'images': {
'': '{{ static_url }}static/empty.png',
{% for sub_unit in filters.sub_units %}
Expand All @@ -33,6 +36,7 @@
}
});
cuteform($('#id_main_unit'), {
'tooltip': 'text',
'images': {
'': '{{ static_url }}static/empty.png',
{% for main_unit in filters.main_units %}
Expand All @@ -41,6 +45,7 @@
}
});
cuteform($('#id_name'), {
'tooltip': 'text',
'modal': 'true',
'modal-text': 'true',
'images': {
Expand Down Expand Up @@ -150,13 +155,6 @@ <h4>{% trans 'Filter' %}</h4>
{% endfor %}
</select>
<br>
{% if view != 'albumbuilder' %}
<br>
<div>
<div class="pull-right"><input id="id_is_world" name="is_world" type="checkbox"{% if request_get.is_world %} checked{% endif %}></div>
<label for="id_is_world"><i class="flaticon-world"></i> {% trans 'Worldwide only' %}</label>
</div>
{% endif %}
<br>
<div class="text-right">
<a href="#morefilters" class="btn btn-{% if not interfaceColor or interfaceColor == 'default' %}Smile{% else %}{{ interfaceColor }}{% endif %} btn-sm" data-toggle="collapse"><i class="flaticon-more"></i> <span class="fontx1-2">{% trans 'More options' %}</span></a>
Expand Down Expand Up @@ -300,7 +298,7 @@ <h4>{% trans 'View' %}</h4>
<option value="1"{% if request_get.idolized == '1' %} selected{% endif %}>{% trans 'Idolized' %}</option>
<option value="-1"{% if request_get.idolized == '-1' %} selected{% endif %}>{% trans 'Not Idolized' %}</option>
</select>
<brf>
<br>
<label for="id_max_level"><i class="flaticon-max-level"></i> {% trans 'Max Leveled' %}</label>
<select id="id_max_level" name="max_level">
<option value=""></option>
Expand All @@ -315,8 +313,8 @@ <h4>{% trans 'View' %}</h4>
<option value="-1"{% if request_get.max_bond == '-1' %} selected{% endif %}>{% trans 'Not Max Bonded' %}</option>
</select>
</div>
{% endif %}
</div>
{% endif %}
</div> <!-- collapse -->
<br>
<h4>{% trans 'Order' %}</h4>
Expand Down
14 changes: 1 addition & 13 deletions web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,16 +676,6 @@ def get_cards_queryset(request, context, card=None, extra_request_get={}):
cards = cards.distinct()
request_get['stored'] = request_get_copy['stored']

if not settings.HIGH_TRAFFIC and (('accounts' in context and not hasJP(context['accounts'])
and 'search' not in request_get_copy
or 'is_world' in request_get_copy and request_get_copy['is_world'])):
if 'is_world' in request_get_copy and request_get_copy['is_world'] == 'off':
cards = cards.filter(japan_only=True)
else:
cards = cards.filter(japan_only=False)
context['show_discover_banner'] = True
request_get['is_world'] = True

if not settings.HIGH_TRAFFIC and (('accounts' in context and not hasJP(context['accounts'])
and 'search' not in request_get_copy
or 'is_promo' in request_get_copy and request_get_copy['is_promo'])):
Expand Down Expand Up @@ -717,8 +707,6 @@ def get_cards_queryset(request, context, card=None, extra_request_get={}):
context['total_results'] = 1
cards = models.Card.objects.filter(pk=int(card))
context['single'] = cards[0]
if 'accounts' in context and not hasJP(context['accounts']):
request_get['is_world'] = True

context['request_get'] = request_get
return context, cards
Expand All @@ -730,7 +718,7 @@ def get_cards_form_filters(request, cardsinfo):
'collections': cardsinfo['collections'],
'translated_collections': cardsinfo['translated_collections'],
'sub_units': cardsinfo['sub_units'] if 'sub_units' in cardsinfo else [],
'main_units': ['Aqours', 'μ\'s', 'Nijigasaki High Scho', 'Liella!'],
'main_units': cardsinfo['main_units'],
'skills': cardsinfo['skills'],
'rarity_choices': models.RARITY_CHOICES,
'attribute_choices': models.ATTRIBUTE_CHOICES,
Expand Down