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 **/
.comment-form label {
.comment_form label {
display: none;
}
.comment-form input:not([type=checkbox]),
.comment-form textarea {
.comment_form input:not([type=checkbox]),
.comment_form textarea {
display: inline-block;
width: calc(100% - 5em);
max-height: 6em;
margin: 0.2em 0em;
}
.comment-form input[type=checkbox],
.comment-form button[type=submit] {
.comment_form input[type=checkbox],
.comment_form button[type=submit] {
max-width: 4em;
vertical-align:bottom;
margin: 0.2em 0em;
text-align: center;
}
.comment-form .extra {
.comment_form .extra {
display: none;
}
.comment-form input[type="checkbox"]:checked + .extra {
.comment_form input[type="checkbox"]:checked + .extra {
display: block;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -639,8 +639,11 @@ class Diffusion(models.Model):
if station:
filter_args['program__station'] = station
if queryset is None:
queryset = cl.objects
if now:
return cl.objects.filter(
return queryset.filter(
models.Q(start__lte = date,
end__gte = date) |
models.Q(start__gte = date),
@ -648,18 +651,17 @@ class Diffusion(models.Model):
).order_by('start')
if next:
return cl.objects.filter(
return queryset.filter(
start__gte = date,
**filter_args
).order_by('start')
if prev:
return cl.objects.filter(
return queryset.filter(
end__lte = date,
**filter_args
).order_by('-start')
def is_date_in_my_range(self, date):
"""
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.
"""
r = Diffusion.objects.filter(
models.Q(start__lte = self.start,
end__gte = self.start) |
models.Q(start__gte = self.start,
start__lte = self.end)
models.Q(start__lt = self.start,
end__gt = self.start) |
models.Q(start__gt = self.start,
start__lt = self.end)
)
return r