fix conflict issue

This commit is contained in:
bkfox 2016-05-26 01:56:09 +02:00
parent a989e53da4
commit 7402fc49b6
7 changed files with 32 additions and 27 deletions

View File

@ -52,31 +52,31 @@ main .section {
/** comments **/ /** comments **/
.comment-form label { .comment_form label {
display: none; display: none;
} }
.comment-form input:not([type=checkbox]), .comment_form input:not([type=checkbox]),
.comment-form textarea { .comment_form textarea {
display: inline-block; display: inline-block;
width: calc(100% - 5em); width: calc(100% - 5em);
max-height: 6em; max-height: 6em;
margin: 0.2em 0em; margin: 0.2em 0em;
} }
.comment-form input[type=checkbox], .comment_form input[type=checkbox],
.comment-form button[type=submit] { .comment_form button[type=submit] {
max-width: 4em; max-width: 4em;
vertical-align:bottom; vertical-align:bottom;
margin: 0.2em 0em; margin: 0.2em 0em;
text-align: center; text-align: center;
} }
.comment-form .extra { .comment_form .extra {
display: none; display: none;
} }
.comment-form input[type="checkbox"]:checked + .extra { .comment_form input[type="checkbox"]:checked + .extra {
display: block; display: block;
} }

View File

@ -6,7 +6,7 @@
{% endblock %} {% endblock %}
{% block pre_title %} {% block pre_title %}
<div class="pre_title"> <div class="pre_title metadata">
{% if object.thread %} {% if object.thread %}
<div class="threads"> <div class="threads">
{{ object|threads:' > '|safe }} {{ object|threads:' > '|safe }}

View File

@ -5,7 +5,7 @@
{% block section_content %} {% block section_content %}
{{ form.non_field_errors }} {{ form.non_field_errors }}
<form action="" method="POST" class="comment-form"> <form action="" method="POST" class="comment_form">
{% csrf_token %} {% csrf_token %}
{% render_honeypot_field "hp_website" %} {% render_honeypot_field "hp_website" %}
<div> <div>
@ -25,13 +25,16 @@
<button type="submit">{% trans "Post!" %}</button> <button type="submit">{% trans "Post!" %}</button>
</div> </div>
</form> </form>
<ul style="padding:0; margin:0"> <div class="comment_list">
{% for item in object_list %} {% for item in object_list %}
<li id="comment-{{ item.id }}" class="{{item.css}}"> <div id="comment-{{ item.id }}" class="comment_item">
{{ item.content }} {{ item.content }}
<div class="info"> <div class="metadata">
<a href="{% if item.url %}{{ item.url }}{% else %}#{% endif %}">{{ item.author }}</a> <a href="{% if item.url %}{{ item.url }}{% else
%}#{% endif %}" class="author">
{{ item.author }}
</a>
<time datetime="{{ item.date }}"> <time datetime="{{ item.date }}">
{{ item.date|date:'l d F Y' }}, {{ item.date|date:'l d F Y' }},
@ -40,9 +43,9 @@
<a href="#comment-{{ item.id }}">#{{ item.id }}</a> <a href="#comment-{{ item.id }}">#{{ item.id }}</a>
</div> </div>
</li> </div>
{% endfor %} {% endfor %}
</ul> </div>
{% endblock %} {% endblock %}

View File

@ -32,7 +32,6 @@ class PostBaseView:
for k in self.website.menu_layouts for k in self.website.menu_layouts
}.items() if v }.items() if v
} }
context['view'] = self context['view'] = self
return context return context

View File

@ -113,8 +113,8 @@ class DiffusionAdmin (admin.ModelAdmin):
def get_queryset(self, request): def get_queryset(self, request):
qs = super(DiffusionAdmin, self).get_queryset(request) qs = super(DiffusionAdmin, self).get_queryset(request)
if '_changelist_filters' in request.GET or \ if ('_changelist_filters' in request.GET or \
'type__exact' in request.GET and \ 'type__exact' in request.GET) and \
str(Diffusion.Type.unconfirmed) in request.GET['type__exact']: str(Diffusion.Type.unconfirmed) in request.GET['type__exact']:
return qs return qs
return qs.exclude(type = Diffusion.Type.unconfirmed) return qs.exclude(type = Diffusion.Type.unconfirmed)

View File

@ -38,7 +38,7 @@ class Actions:
Return the number of conflicts Return the number of conflicts
""" """
conflicts = item.get_conflicts() conflicts = list(item.get_conflicts())
for i, conflict in enumerate(conflicts): for i, conflict in enumerate(conflicts):
if conflict.program == item.program: if conflict.program == item.program:
item.do_not_save = True item.do_not_save = True
@ -74,6 +74,7 @@ class Actions:
if manual: if manual:
Diffusion.objects.bulk_create(items) Diffusion.objects.bulk_create(items)
else: else:
print('items: ', len(items))
for item in items: for item in items:
count[1] += cl.__check_conflicts(item, saved_items) count[1] += cl.__check_conflicts(item, saved_items)
if hasattr(item, 'do_not_save'): if hasattr(item, 'do_not_save'):

View File

@ -639,8 +639,11 @@ class Diffusion(models.Model):
if station: if station:
filter_args['program__station'] = station filter_args['program__station'] = station
if queryset is None:
queryset = cl.objects
if now: if now:
return cl.objects.filter( return queryset.filter(
models.Q(start__lte = date, models.Q(start__lte = date,
end__gte = date) | end__gte = date) |
models.Q(start__gte = date), models.Q(start__gte = date),
@ -648,18 +651,17 @@ class Diffusion(models.Model):
).order_by('start') ).order_by('start')
if next: if next:
return cl.objects.filter( return queryset.filter(
start__gte = date, start__gte = date,
**filter_args **filter_args
).order_by('start') ).order_by('start')
if prev: if prev:
return cl.objects.filter( return queryset.filter(
end__lte = date, end__lte = date,
**filter_args **filter_args
).order_by('-start') ).order_by('-start')
def is_date_in_my_range(self, date): def is_date_in_my_range(self, date):
""" """
Return true if the given date is in the diffusion's start-end Return true if the given date is in the diffusion's start-end
@ -672,10 +674,10 @@ class Diffusion(models.Model):
Return a list of conflictual diffusions, based on the scheduled duration. Return a list of conflictual diffusions, based on the scheduled duration.
""" """
r = Diffusion.objects.filter( r = Diffusion.objects.filter(
models.Q(start__lte = self.start, models.Q(start__lt = self.start,
end__gte = self.start) | end__gt = self.start) |
models.Q(start__gte = self.start, models.Q(start__gt = self.start,
start__lte = self.end) start__lt = self.end)
) )
return r return r