mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-02-20 07:59:50 -05:00
feat: add manual download option to season-requests-table.svelte and fixing bug that prevents user from approving/unapproving of a request
This commit is contained in:
@@ -220,8 +220,3 @@ def get_seasons_by_torrent_id(db: Session, torrent_id: TorrentId) -> list[Season
|
||||
def get_season_request(db: Session, season_request_id: SeasonRequestId) -> SeasonRequestSchema:
|
||||
return SeasonRequestSchema.model_validate(db.get(SeasonRequest, season_request_id))
|
||||
|
||||
|
||||
def update_season_request(db: Session, season_request: SeasonRequestSchema) -> None:
|
||||
db.delete(db.get(SeasonRequest, season_request.id))
|
||||
db.add(SeasonRequest(**season_request.model_dump()))
|
||||
db.commit()
|
||||
|
||||
@@ -129,6 +129,8 @@ def authorize_request(db: DbSessionDependency, user: Annotated[User, Depends(cur
|
||||
season_request: SeasonRequest = tv.repository.get_season_request(db=db, season_request_id=season_request_id)
|
||||
season_request.authorized_by = UserRead.model_validate(user)
|
||||
season_request.authorized = authorized_status
|
||||
if not authorized_status:
|
||||
season_request.authorized_by = None
|
||||
tv.service.update_season_request(db=db, season_request=season_request)
|
||||
return
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ def get_season_request_by_id(db: Session, season_request_id: SeasonRequestId) ->
|
||||
return tv.repository.get_season_request(db=db, season_request_id=season_request_id)
|
||||
|
||||
def update_season_request(db: Session, season_request: SeasonRequest) -> None:
|
||||
tv.repository.update_season_request(db=db, season_request=season_request)
|
||||
|
||||
tv.repository.delete_season_request(db=db, season_request_id=season_request.id)
|
||||
tv.repository.add_season_request(db=db, season_request=season_request)
|
||||
|
||||
def delete_season_request(db: Session, season_request_id: SeasonRequestId) -> None:
|
||||
tv.repository.delete_season_request(db=db, season_request_id=season_request_id)
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import {Button} from '$lib/components/ui/button/index.js';
|
||||
import {env} from '$env/dynamic/public';
|
||||
import {toast} from 'svelte-sonner';
|
||||
import {goto} from "$app/navigation";
|
||||
import {base} from "$app/paths";
|
||||
|
||||
let {
|
||||
requests,
|
||||
@@ -32,8 +34,9 @@
|
||||
if (response.ok) {
|
||||
const requestIndex = requests.findIndex((r) => r.id === requestId);
|
||||
if (requestIndex !== -1) {
|
||||
requests[requestIndex].authorized = !currentAuthorizedStatus;
|
||||
requests[requestIndex].authorized_by = user();
|
||||
let newAuthorizedStatus = !currentAuthorizedStatus;
|
||||
requests[requestIndex].authorized = newAuthorizedStatus;
|
||||
requests[requestIndex].authorized_by = newAuthorizedStatus ? user() : null;
|
||||
}
|
||||
toast.success(
|
||||
`Request ${!currentAuthorizedStatus ? 'approved' : 'unapproved'} successfully.`
|
||||
@@ -119,15 +122,23 @@
|
||||
<Table.Cell>
|
||||
{request.authorized_by?.email ?? 'N/A'}
|
||||
</Table.Cell>
|
||||
<Table.Cell class="space-x-1">
|
||||
<Table.Cell class="flex flex-col items-center gap-1">
|
||||
{#if user().is_superuser}
|
||||
<Button
|
||||
class="mb-1"
|
||||
class=""
|
||||
size="sm"
|
||||
onclick={() => approveRequest(request.id, request.authorized)}
|
||||
>
|
||||
{request.authorized ? 'Unapprove' : 'Approve'}
|
||||
</Button>
|
||||
<Button
|
||||
class=""
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onclick={() => goto(base+"/dashboard/tv/"+request.show.id + "/" + request.season.number)}
|
||||
>
|
||||
Download manually
|
||||
</Button>
|
||||
{/if}
|
||||
{#if user().is_superuser || user().id === request.requested_by?.id}
|
||||
<Button variant="destructive" size="sm" onclick={() => deleteRequest(request.id)}
|
||||
|
||||
Reference in New Issue
Block a user