get rid of generic views, fix some controlbar bugs, make it work in chromium as well
This commit is contained in:
parent
9f7e051a9f
commit
6240586d25
@ -34,7 +34,7 @@ $(document).ready(function() {
|
|||||||
let option = $('div.username option[value=' + name + ']');
|
let option = $('div.username option[value=' + name + ']');
|
||||||
if (option.length == 0) {
|
if (option.length == 0) {
|
||||||
$('div.username select').append($('<option>', {
|
$('div.username select').append($('<option>', {
|
||||||
value: name, label: color, html: name
|
value: name, color: color, html: name
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +55,10 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// select username on change
|
||||||
$('div.username select').on('change', function() {
|
$('div.username select').on('change', function() {
|
||||||
|
let color = $('div.username option[value=' + this.value + ']').attr('color');
|
||||||
color = $('div.username option[value=' + this.value + ']').attr('label');
|
$('div.username option[selected=selected]').removeAttr('selected');
|
||||||
render_login(this.value, color);
|
render_login(this.value, color);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,5 +118,16 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
if (name != '') {
|
if (name != '') {
|
||||||
render_login(name, color);
|
render_login(name, color);
|
||||||
|
} else {
|
||||||
|
//#TODO log in as default if any
|
||||||
|
// let option = $('div.username option[value=' + name + ']');
|
||||||
|
// if (option.length == 0) {
|
||||||
|
// $('div.username select').append($('<option>', {
|
||||||
|
// value: name, label: color, html: name
|
||||||
|
// }));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $('div.username option[value=' + name + ']').attr('selected', 'selected');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<th colspan="12">
|
<th colspan="12">
|
||||||
<a name="{{ country.name_iso }}"></a>
|
<a name="{{ country.name_iso }}"></a>
|
||||||
<img class="country" src="/static/coinc/images/{{ country.name_iso }}.png" />
|
<img class="country" src="/static/coinc/images/{{ country.name_iso }}.png" />
|
||||||
<a href="{% url 'coinc:country' country.name_iso %}">{{ country.name }}</a>{% if country.comment %} - {{ country.comment }}{% endif %}
|
<a href="{% url 'coinc:country' country.name_iso %}">{{ country.name }}</a>{% if country.comment %}<small> - {{ country.comment }}</small>{% endif %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
{% if not showed_header %}
|
{% include 'header.html' with title='Münzsammlung' %}
|
||||||
{% include "header.html" with title="Münzsammlung" %}
|
{% include 'coinc/username.html' with users=users %}
|
||||||
{% url 'bar.html' as showed_header %}
|
|
||||||
{% endif %}
|
|
||||||
{% if not showed_usernames %}
|
|
||||||
{% include 'coinc/username.html' with users=users %}
|
|
||||||
{% url 'foo.html' as showed_usernames %}
|
|
||||||
{% endif %}
|
|
||||||
{% if countrys %}
|
{% if countrys %}
|
||||||
{% show_navigation countrys %}
|
{% include 'coinc/filter_country.html' with countrys=countrys %}
|
||||||
{% for country in countrys %}
|
{% for country in countrys %}
|
||||||
{% show_country country %}
|
{% show_country country %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
||||||
{% if not showed_footer %}
|
{% include 'footer.html' with title='Münzsammlung' %}
|
||||||
{% include "footer.html" with title="Münzsammlung" %}
|
|
||||||
{% url 'baz.html' as showed_footer %}
|
|
||||||
{% endif %}
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<label for="select_usernames" id="for_select_usernames">Name</label>
|
<label for="select_usernames" id="for_select_usernames">Name</label>
|
||||||
<select id="select_usernames" name="username" form="username_form" class="form-control">
|
<select id="select_usernames" name="username" form="username_form" class="form-control">
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<option value="{{ user.name }}" label="{{ user.color }}">{{ user.name }}</option>
|
<option value="{{ user.name }}" color="{{ user.color }}">{{ user.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<span id="user_message"><button id="show_add_user" class="btn btn-info">+ Namen hinzufügen</button></span>
|
<span id="user_message"><button id="show_add_user" class="btn btn-info">+ Namen hinzufügen</button></span>
|
||||||
|
@ -25,7 +25,7 @@ from . import views
|
|||||||
|
|
||||||
app_name = 'coinc'
|
app_name = 'coinc'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.IndexView.as_view(), name='index'),
|
path('', views.index, name='index'),
|
||||||
path('statistik', views.statistic, name='statistic'),
|
path('statistik', views.statistic, name='statistic'),
|
||||||
path('<str:country>', views.detail_country, name='country'),
|
path('<str:country>', views.detail_country, name='country'),
|
||||||
path('add/user/<str:username>/color/<str:color>', views.add_user, name='add_user')
|
path('add/user/<str:username>/color/<str:color>', views.add_user, name='add_user')
|
||||||
|
@ -17,28 +17,28 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.template.defaultfilters import register
|
from django.template.defaultfilters import register
|
||||||
from django.views import generic
|
|
||||||
from django.shortcuts import redirect
|
|
||||||
|
|
||||||
from .models import Country, Stamp, Coin, User
|
from .models import Country, Stamp, Coin, User
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
''' index view '''
|
||||||
|
|
||||||
class IndexView(generic.ListView):
|
template = loader.get_template('coinc/index.html')
|
||||||
template_name = 'coinc/index.html'
|
countrys = Country.objects.order_by('name_iso')
|
||||||
context_object_name = 'countrys'
|
users = User.objects.order_by('id')
|
||||||
|
context = {
|
||||||
def get_queryset(self):
|
'countrys': countrys,
|
||||||
''' return all countries ordered by name '''
|
'users': users
|
||||||
return Country.objects.order_by('name_iso')
|
}
|
||||||
|
|
||||||
|
return HttpResponse(template.render(context, request))
|
||||||
|
|
||||||
|
|
||||||
def detail_country(request, country):
|
def detail_country(request, country):
|
||||||
@ -47,13 +47,6 @@ def detail_country(request, country):
|
|||||||
return HttpResponse(template.render(show_country(c, single_country=True), request))
|
return HttpResponse(template.render(show_country(c, single_country=True), request))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('coinc/navigation.html')
|
|
||||||
def show_navigation(countrys):
|
|
||||||
return {'countrys': countrys}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('coinc/country.html')
|
@register.inclusion_tag('coinc/country.html')
|
||||||
def show_country(country, single_country=False):
|
def show_country(country, single_country=False):
|
||||||
c = {
|
c = {
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user