Skip to content

Commit

Permalink
trying to fix the filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Bernardo Vargas [C] committed Dec 4, 2019
1 parent 2cb3883 commit a8528f9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/core/templates/core/car/car_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h1 class="title">{% trans "Cars" %}</h1>
</div>
</div>

{% include "pagination.html" %}

<form id="form">
{% csrf_token %}
Expand Down
1 change: 0 additions & 1 deletion app/core/templates/core/client/_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
{{obj.last_service|default:""}}
</td>
<td>
<a class="button is-info " href="{% url 'service_add' %}"> {% trans "Add Service" %}</a>
<a href="{% url 'edit_client' obj.id %}" class="button is-small is-light">
{% trans "Edit" %}
</a>
Expand Down
2 changes: 2 additions & 0 deletions app/core/templates/core/client/client_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ <h1 class="title">{% trans "Clients" %}</h1>
<div class="level-right">
<div class="buttons is-right">

<a class="button is-success " href="{% url 'service_add' %}"> {% trans "Add Service" %}</a>

<a class="button is-info" href="{% url 'client_add' %}"> {% trans "Add" %}</a>

<button class="button is-warning"
Expand Down
7 changes: 6 additions & 1 deletion app/core/templates/core/service/_visit.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{% for obj in object_list %}
<tr class="m-m p-m">
<td>
<!--
{{page_obj.number|pprint}}
{{page_obj.has_next|pprint}}
{{page_obj.next_page_number|pprint}}
-->
<input type="checkbox" name="ids" value="{{obj.id}}">
{% if forloop.last and page_obj.has_next %}
<span
Expand All @@ -20,7 +25,7 @@


</td>
<td>{{obj.reception_datetime|timesince}}</td>
<td>{{obj.reception_datetime|timesince}} ago</td>


<td>
Expand Down
6 changes: 3 additions & 3 deletions app/core/templates/core/service/service_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="title">{% trans "Services" %}</h1>

<div class="select">
<select
ic-include="[name='search'],[name='status']"
ic-include="[name='search'],[name='status'],[name='search_time']"
ic-target="#object_list" ic-get-from="{% url 'service_search' %}?{% param_replace%}"
name="search_time">
<option val="">All time</option>
Expand All @@ -42,8 +42,8 @@ <h1 class="title">{% trans "Services" %}</h1>

<div class="select">
<select name="status"
ic-include="[name='search'],[name='status']"

ic-include="[name='search'],[name='status'],[name='search_time']"
ic-target="#object_list" ic-get-from="{% url 'service_search' %}?{% param_replace %}" >
<option value=""> {% trans "Status" %}</option>
{% for k,v in object_list.0.STATUS %}
Expand Down
2 changes: 2 additions & 0 deletions app/core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def param_replace(context, **kwargs):
pre_dict[k] = list(dict.fromkeys(v)).pop()
for k, v in kwargs.items():
pre_dict[k] = v
import pprint
pprint.pprint(pre_dict)
urlparams = urllib.parse.urlencode(pre_dict)
return mark_safe(QueryDict(urlparams).urlencode())

Expand Down
5 changes: 4 additions & 1 deletion app/core/views/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def service_search(request):
if q_time:
ds = filter_by_date(ds, q_time)
p = Paginator(ds, 5)
object_list = p.get_page(request.GET.get("page"))
try:
object_list = p.get_page(request.GET.get("page",1))
except:
object_list = p.get_page(1)
ctx = {'object_list': object_list,'page_obj':object_list }
return render(request, "core/service/_visit.html", ctx)

Expand Down
2 changes: 1 addition & 1 deletion app/core/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def filter_by_date(ds, q_time):
reception_datetime__year=now.year)
if q_time =="mm":
ds = ds.filter(
reception_datetime__month=now.month-2,
reception_datetime__month=now.month-1,
reception_datetime__year=now.year
)
elif q_time == "t":
Expand Down
8 changes: 4 additions & 4 deletions app/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
Diagnostic.objects.all().delete()

fake = Seed.seeder()
fake.add_entity(Client, 30, {
fake.add_entity(Client, 200, {
'user':user,
'name': lambda x: fake.faker.name()
})
fake.add_entity(Car, 10,{
fake.add_entity(Car, 800,{
'user':user,
'brand': lambda x: fake.faker.random_element(cars.split())
})

fake.add_entity(Diagnostic, 40, {
fake.add_entity(Diagnostic, 800, {
'user':user,
'reception_datetime': lambda x: timezone.make_aware(
fake.faker.date_time_between(
start_date="-120d", end_date="now")),
start_date="-1y", end_date="now")),
'status': lambda x: fake.faker.random_element(Diagnostic.STATUS)[0],

})
Expand Down

0 comments on commit a8528f9

Please sign in to comment.