buttom filter
This commit is contained in:
parent
5c207b4771
commit
09a6a5a1a4
49608
logs/app.log
49608
logs/app.log
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8,6 +8,9 @@ from sqlalchemy.future import select
|
|||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from sqlalchemy import or_, and_, select
|
||||
|
||||
from sqlalchemy import null
|
||||
|
||||
from routers.auth import get_current_user
|
||||
from model.database import get_async_session, Job, Client, AppliedJob, User
|
||||
|
@ -47,6 +50,140 @@ async def product(request: Request,
|
|||
"username": username['username'], "users": users,
|
||||
"current_path": request.url.path })#
|
||||
|
||||
|
||||
|
||||
@router.get("/productuj")
|
||||
async def productuj(request: Request,
|
||||
username: str = Depends(get_current_user),
|
||||
session: AsyncSession = Depends(get_async_session)):
|
||||
size = "Work"
|
||||
username = username
|
||||
|
||||
result = await session.execute(
|
||||
select(AppliedJob)
|
||||
.where(
|
||||
and_(
|
||||
or_(
|
||||
AppliedJob.status.is_(None),
|
||||
AppliedJob.status.in_(["Scheduled", "Requested"])
|
||||
),
|
||||
AppliedJob.assignee.is_(None)
|
||||
)
|
||||
)
|
||||
.options(
|
||||
joinedload(AppliedJob.client),
|
||||
joinedload(AppliedJob.job),
|
||||
joinedload(AppliedJob.users)
|
||||
)
|
||||
)
|
||||
|
||||
applied_jobs = result.scalars().all()
|
||||
|
||||
|
||||
result1 = await session.execute(select(User))
|
||||
users = result1.scalars().all()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return templates.TemplateResponse("productuj.html", {"request": request, "size": size,
|
||||
"jobs": applied_jobs, "role": username["role"],
|
||||
"username": username['username'], "users": users,
|
||||
"current_path": request.url.path })#
|
||||
|
||||
|
||||
|
||||
|
||||
@router.get("/productmj")
|
||||
async def productmj(request: Request,
|
||||
username: str = Depends(get_current_user),
|
||||
session: AsyncSession = Depends(get_async_session)):
|
||||
size = "Work"
|
||||
username = username
|
||||
user_result = await session.execute(
|
||||
select(User.id).where(User.username == username['username'])
|
||||
)
|
||||
user_id = user_result.scalar() # Достаём ID
|
||||
|
||||
if user_id is None:
|
||||
raise ValueError(f"Пользователь с username '{username['username']}' не найден")
|
||||
|
||||
# Теперь используем user_id для фильтрации AppliedJob
|
||||
result = await session.execute(
|
||||
select(AppliedJob)
|
||||
.where(
|
||||
and_(
|
||||
AppliedJob.status.in_(["In-Progress"]),
|
||||
AppliedJob.assignee == user_id # Теперь сравниваем с id, а не username
|
||||
)
|
||||
)
|
||||
.options(
|
||||
joinedload(AppliedJob.client),
|
||||
joinedload(AppliedJob.job),
|
||||
joinedload(AppliedJob.users)
|
||||
)
|
||||
)
|
||||
|
||||
applied_jobs = result.scalars().all()
|
||||
|
||||
|
||||
result1 = await session.execute(select(User))
|
||||
users = result1.scalars().all()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return templates.TemplateResponse("productmj.html", {"request": request, "size": size,
|
||||
"jobs": applied_jobs, "role": username["role"],
|
||||
"username": username['username'], "users": users,
|
||||
"current_path": request.url.path })#
|
||||
|
||||
|
||||
@router.get("/productoj")
|
||||
async def productoj(request: Request,
|
||||
username: str = Depends(get_current_user),
|
||||
session: AsyncSession = Depends(get_async_session)):
|
||||
size = "Work"
|
||||
username = username
|
||||
|
||||
result = await session.execute(
|
||||
select(AppliedJob)
|
||||
.where(
|
||||
and_(
|
||||
or_(
|
||||
|
||||
AppliedJob.status.in_(["Scheduled", "Requested", "In-Progress"])
|
||||
),
|
||||
# AppliedJob.assignee.is_(None)
|
||||
)
|
||||
)
|
||||
.options(
|
||||
joinedload(AppliedJob.client),
|
||||
joinedload(AppliedJob.job),
|
||||
joinedload(AppliedJob.users)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
applied_jobs = result.scalars().all()
|
||||
|
||||
|
||||
result1 = await session.execute(select(User))
|
||||
users = result1.scalars().all()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return templates.TemplateResponse("productoj.html", {"request": request, "size": size,
|
||||
"jobs": applied_jobs, "role": username["role"],
|
||||
"username": username['username'], "users": users,
|
||||
"current_path": request.url.path })#
|
||||
|
||||
# Pydantic модель запроса
|
||||
class StatusUpdate(BaseModel):
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="author" content="">
|
||||
<title>Dashboard - LINK</title>
|
||||
<title>Dashboard - TurboАpply</title>
|
||||
<!-- BEGIN: CSS Assets-->
|
||||
<link rel="stylesheet" href="/static/dist/css/app.css" />
|
||||
<!-- END: CSS Assets-->
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
<h2 class="text-lg font-medium mr-auto">
|
||||
Tasks
|
||||
</h2>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productprom'">Unasigned Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productnoprom'">My Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productuj'">Unasigned Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productmj'">My Jobs</button>
|
||||
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productrozetka'">All Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productnorozetka'">Outstanding Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/product'">All Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productoj'">Outstanding Jobs</button>
|
||||
</div>
|
||||
<!-- BEGIN: Datatable -->
|
||||
<div class="intro-y datatable-wrapper box p-5 mt-5">
|
||||
|
@ -49,6 +49,7 @@
|
|||
<td class="text-center border-b">{{job.job.date_posted}}</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateStatus(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.status is none %}selected{% endif %}>— Not selected —</option>
|
||||
<option value="Scheduled" {% if job.status == "Scheduled" %}selected{% endif %}>Scheduled</option>
|
||||
<option value="Requested" {% if job.status == "Requested" %}selected{% endif %}>Requested</option>
|
||||
<option value="In-Progress" {% if job.status == "In-Progress" %}selected{% endif %}>In-Progress</option>
|
||||
|
@ -60,11 +61,11 @@
|
|||
</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateAssignee(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.assignee is none %}selected{% endif %}>— Not selected —</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if job.assignee == user.id %}selected{% endif %}>
|
||||
|
||||
{{ user.username }}
|
||||
</option>
|
||||
<option value="{{ user.id }}" {% if job.assignee == user.id %}selected{% endif %}>
|
||||
{{ user.username }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Главная{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="intro-y flex flex-col sm:flex-row items-center mt-8">
|
||||
<h2 class="text-lg font-medium mr-auto">
|
||||
Tasks
|
||||
</h2>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productuj'">Unasigned Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productmj'">My Jobs</button>
|
||||
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/product'">All Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productoj'">Outstanding Jobs</button>
|
||||
</div>
|
||||
<!-- BEGIN: Datatable -->
|
||||
<div class="intro-y datatable-wrapper box p-5 mt-5">
|
||||
<table class="table table-report table-report--bordered display datatable w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border-b-2 whitespace-no-wrap">TITLE ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">COMPANY ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">CLIENT ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Requested on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Posted on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">STATUS ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Assignee ⨈</th>
|
||||
|
||||
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Applied on</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for job in jobs %}
|
||||
<tr>
|
||||
<td class="border-b">
|
||||
<a href="{{ job.job.link }}" target="_blank" class="font-medium whitespace-no-wrap">{{ job.job.job_title [:50] }}</a>
|
||||
<div class="text-gray-600 text-xs whitespace-no-wrap">{{ job.job.job_id }}</div>
|
||||
</td>
|
||||
<td class="text-center border-b">{{job.job.job_company}}</td>
|
||||
<td class="text-center border-b">
|
||||
|
||||
<a href="#" class="client-link text-blue-500" data-client-id="{{ job.client.id }}">{{ job.client.user_nicename }}</a>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="text-center border-b">Requested on</td>
|
||||
<td class="text-center border-b">{{job.job.date_posted}}</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateStatus(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.status is none %}selected{% endif %}>— Not selected —</option>
|
||||
<option value="Scheduled" {% if job.status == "Scheduled" %}selected{% endif %}>Scheduled</option>
|
||||
<option value="Requested" {% if job.status == "Requested" %}selected{% endif %}>Requested</option>
|
||||
<option value="In-Progress" {% if job.status == "In-Progress" %}selected{% endif %}>In-Progress</option>
|
||||
<option value="Applied" {% if job.status == "Applied" %}selected{% endif %}>Applied</option>
|
||||
<option value="Issues Applying" {% if job.status == "Issues Applying" %}selected{% endif %}>Issues Applying</option>
|
||||
<option value="Cancelled" {% if job.status == "Cancelled" %}selected{% endif %}>Cancelled</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateAssignee(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.assignee is none %}selected{% endif %}>— Not selected —</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if job.assignee == user.id %}selected{% endif %}>
|
||||
{{ user.username }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center border-b">-</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END: Datatable -->
|
||||
<!-- Включаем модалку -->
|
||||
<!-- Модальное окно -->
|
||||
{% include "modal.html" %}
|
||||
<script src="/static/dist/js/prod.js"></script>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,84 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Главная{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="intro-y flex flex-col sm:flex-row items-center mt-8">
|
||||
<h2 class="text-lg font-medium mr-auto">
|
||||
Tasks
|
||||
</h2>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productuj'">Unasigned Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productmj'">My Jobs</button>
|
||||
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/product'">All Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productoj'">Outstanding Jobs</button>
|
||||
</div>
|
||||
<!-- BEGIN: Datatable -->
|
||||
<div class="intro-y datatable-wrapper box p-5 mt-5">
|
||||
<table class="table table-report table-report--bordered display datatable w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border-b-2 whitespace-no-wrap">TITLE ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">COMPANY ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">CLIENT ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Requested on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Posted on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">STATUS ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Assignee ⨈</th>
|
||||
|
||||
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Applied on</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for job in jobs %}
|
||||
<tr>
|
||||
<td class="border-b">
|
||||
<a href="{{ job.job.link }}" target="_blank" class="font-medium whitespace-no-wrap">{{ job.job.job_title [:50] }}</a>
|
||||
<div class="text-gray-600 text-xs whitespace-no-wrap">{{ job.job.job_id }}</div>
|
||||
</td>
|
||||
<td class="text-center border-b">{{job.job.job_company}}</td>
|
||||
<td class="text-center border-b">
|
||||
|
||||
<a href="#" class="client-link text-blue-500" data-client-id="{{ job.client.id }}">{{ job.client.user_nicename }}</a>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="text-center border-b">Requested on</td>
|
||||
<td class="text-center border-b">{{job.job.date_posted}}</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateStatus(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.status is none %}selected{% endif %}>— Not selected —</option>
|
||||
<option value="Scheduled" {% if job.status == "Scheduled" %}selected{% endif %}>Scheduled</option>
|
||||
<option value="Requested" {% if job.status == "Requested" %}selected{% endif %}>Requested</option>
|
||||
<option value="In-Progress" {% if job.status == "In-Progress" %}selected{% endif %}>In-Progress</option>
|
||||
<option value="Applied" {% if job.status == "Applied" %}selected{% endif %}>Applied</option>
|
||||
<option value="Issues Applying" {% if job.status == "Issues Applying" %}selected{% endif %}>Issues Applying</option>
|
||||
<option value="Cancelled" {% if job.status == "Cancelled" %}selected{% endif %}>Cancelled</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateAssignee(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.assignee is none %}selected{% endif %}>— Not selected —</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if job.assignee == user.id %}selected{% endif %}>
|
||||
{{ user.username }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center border-b">-</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END: Datatable -->
|
||||
<!-- Включаем модалку -->
|
||||
<!-- Модальное окно -->
|
||||
{% include "modal.html" %}
|
||||
<script src="/static/dist/js/prod.js"></script>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,84 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Главная{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="intro-y flex flex-col sm:flex-row items-center mt-8">
|
||||
<h2 class="text-lg font-medium mr-auto">
|
||||
Tasks
|
||||
</h2>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productuj'">Unasigned Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productmj'">My Jobs</button>
|
||||
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/product'">All Jobs</button>
|
||||
<button class="button text-white bg-theme-1 shadow-md mr-2" onclick="window.location.href='/productoj'">Outstanding Jobs</button>
|
||||
</div>
|
||||
<!-- BEGIN: Datatable -->
|
||||
<div class="intro-y datatable-wrapper box p-5 mt-5">
|
||||
<table class="table table-report table-report--bordered display datatable w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border-b-2 whitespace-no-wrap">TITLE ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">COMPANY ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">CLIENT ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Requested on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Posted on ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">STATUS ⨈</th>
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Assignee ⨈</th>
|
||||
|
||||
|
||||
<th class="border-b-2 text-center whitespace-no-wrap">Applied on</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for job in jobs %}
|
||||
<tr>
|
||||
<td class="border-b">
|
||||
<a href="{{ job.job.link }}" target="_blank" class="font-medium whitespace-no-wrap">{{ job.job.job_title [:50] }}</a>
|
||||
<div class="text-gray-600 text-xs whitespace-no-wrap">{{ job.job.job_id }}</div>
|
||||
</td>
|
||||
<td class="text-center border-b">{{job.job.job_company}}</td>
|
||||
<td class="text-center border-b">
|
||||
|
||||
<a href="#" class="client-link text-blue-500" data-client-id="{{ job.client.id }}">{{ job.client.user_nicename }}</a>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="text-center border-b">Requested on</td>
|
||||
<td class="text-center border-b">{{job.job.date_posted}}</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateStatus(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.status is none %}selected{% endif %}>— Not selected —</option>
|
||||
<option value="Scheduled" {% if job.status == "Scheduled" %}selected{% endif %}>Scheduled</option>
|
||||
<option value="Requested" {% if job.status == "Requested" %}selected{% endif %}>Requested</option>
|
||||
<option value="In-Progress" {% if job.status == "In-Progress" %}selected{% endif %}>In-Progress</option>
|
||||
<option value="Applied" {% if job.status == "Applied" %}selected{% endif %}>Applied</option>
|
||||
<option value="Issues Applying" {% if job.status == "Issues Applying" %}selected{% endif %}>Issues Applying</option>
|
||||
<option value="Cancelled" {% if job.status == "Cancelled" %}selected{% endif %}>Cancelled</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td class="text-center border-b">
|
||||
<select class="select2" onchange="updateAssignee(this, '{{ job.id }}')">
|
||||
<option value="" {% if job.assignee is none %}selected{% endif %}>— Not selected —</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if job.assignee == user.id %}selected{% endif %}>
|
||||
{{ user.username }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center border-b">-</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END: Datatable -->
|
||||
<!-- Включаем модалку -->
|
||||
<!-- Модальное окно -->
|
||||
{% include "modal.html" %}
|
||||
<script src="/static/dist/js/prod.js"></script>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue