mirror of
https://github.com/aykhans/series-robot-web.git
synced 2025-04-21 06:13:34 +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 = {
|
app.conf.beat_schedule = {
|
||||||
'send-emails': {
|
'send-emails': {
|
||||||
'task': '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 celery import shared_task
|
||||||
from account.models import User
|
from account.models import User
|
||||||
from requests import get
|
|
||||||
from datetime import datetime
|
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.core.mail import EmailMessage
|
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 SeriesCounter
|
||||||
from imdb_api_access import MaximumUsageError
|
from imdb_api_access import MaximumUsageError
|
||||||
|
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
{% include 'components/message.html' %}
|
{% include 'components/message.html' %}
|
||||||
<link rel="stylesheet" href="{% static 'css/homepage.css' %}">
|
<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">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -8,14 +8,18 @@ from django.db.models import Q
|
|||||||
@login_required(login_url='/account/login')
|
@login_required(login_url='/account/login')
|
||||||
def homepage_view(request):
|
def homepage_view(request):
|
||||||
user = User.objects.get(id=request.user.id)
|
user = User.objects.get(id=request.user.id)
|
||||||
|
|
||||||
if request.GET.get('new') == 'true':
|
if request.GET.get('new') == 'true':
|
||||||
series_true = user.series.filter(~Q(new_episodes_count=0), show=True).order_by('-id')
|
series = user.series.filter(~Q(new_episodes_count=0)).order_by('-id')
|
||||||
series_false = user.series.filter(~Q(new_episodes_count=0), show=False).order_by('-id')
|
|
||||||
else:
|
else: series = user.series.filter().order_by('-id')
|
||||||
series_true = user.series.filter(show=True).order_by('-id')
|
|
||||||
series_false = user.series.filter(show=False).order_by('-id')
|
if search := request.GET.get('search'):
|
||||||
|
series = series.filter(
|
||||||
|
Q(title__icontains=search)
|
||||||
|
)
|
||||||
|
|
||||||
page = request.GET.get('page')
|
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)})
|
return render(request, 'homepage.html', context={'series': paginator.get_page(page)})
|
@ -10,6 +10,15 @@
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-form {
|
||||||
|
width: 370px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form input {
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 510px) {
|
@media only screen and (max-width: 510px) {
|
||||||
table {
|
table {
|
||||||
font-size: 87%;
|
font-size: 87%;
|
||||||
@ -24,4 +33,15 @@
|
|||||||
width: 19px;
|
width: 19px;
|
||||||
height: 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