mirror of
https://github.com/aykhans/series-robot-web.git
synced 2025-04-16 04:53:11 +00:00
Added search bar
This commit is contained in:
parent
8ec01acc4c
commit
b90f87e4ca
@ -11,6 +11,6 @@ app.autodiscover_tasks()
|
||||
app.conf.beat_schedule = {
|
||||
'send-emails': {
|
||||
'task': 'send_emails',
|
||||
'schedule': crontab(hour=7, minute=55),
|
||||
'schedule': crontab(hour=5, minute=55),
|
||||
},
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
from celery import shared_task
|
||||
from account.models import User
|
||||
from requests import get
|
||||
from datetime import datetime
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.mail import EmailMessage
|
||||
from celery.utils.log import get_task_logger
|
||||
# from celery.utils.log import get_task_logger
|
||||
from imdb_api_access import SeriesCounter
|
||||
from imdb_api_access import MaximumUsageError
|
||||
|
||||
|
@ -8,6 +8,11 @@
|
||||
{% include 'components/message.html' %}
|
||||
<link rel="stylesheet" href="{% static 'css/homepage.css' %}">
|
||||
|
||||
<form action="{% url 'homepage' %}" class="form-inline my-2 mb-3 search-form">
|
||||
<input name="search" type="text" class="form-control" placeholder="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0 ml-2" type="submit">Search</button>
|
||||
</form>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -8,14 +8,18 @@ from django.db.models import Q
|
||||
@login_required(login_url='/account/login')
|
||||
def homepage_view(request):
|
||||
user = User.objects.get(id=request.user.id)
|
||||
|
||||
if request.GET.get('new') == 'true':
|
||||
series_true = user.series.filter(~Q(new_episodes_count=0), show=True).order_by('-id')
|
||||
series_false = user.series.filter(~Q(new_episodes_count=0), show=False).order_by('-id')
|
||||
else:
|
||||
series_true = user.series.filter(show=True).order_by('-id')
|
||||
series_false = user.series.filter(show=False).order_by('-id')
|
||||
series = user.series.filter(~Q(new_episodes_count=0)).order_by('-id')
|
||||
|
||||
else: series = user.series.filter().order_by('-id')
|
||||
|
||||
if search := request.GET.get('search'):
|
||||
series = series.filter(
|
||||
Q(title__icontains=search)
|
||||
)
|
||||
|
||||
page = request.GET.get('page')
|
||||
paginator = Paginator(list(series_true) + list(series_false), 5)
|
||||
paginator = Paginator(series, 5)
|
||||
|
||||
return render(request, 'homepage.html', context={'series': paginator.get_page(page)})
|
@ -10,6 +10,15 @@
|
||||
float: right;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
width: 370px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search-form input {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 510px) {
|
||||
table {
|
||||
font-size: 87%;
|
||||
@ -24,4 +33,15 @@
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
width: 330px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search-form input {
|
||||
margin-top: 4px;
|
||||
height: 45px;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user