mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 12:44:25 +00:00
implement torrent sensitive edit features #11
This commit is contained in:
parent
cbda078c38
commit
b81d973331
@ -133,7 +133,7 @@ class PageController extends AbstractController
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('sensitive'),
|
||||
'placeholder' => $translator->trans('Apply sensitive filters for this publication'),
|
||||
'placeholder' => $translator->trans('Apply sensitive filters to publication'),
|
||||
]
|
||||
]
|
||||
];
|
||||
|
@ -14,6 +14,7 @@ use App\Service\TorrentService;
|
||||
|
||||
class TorrentController extends AbstractController
|
||||
{
|
||||
// Torrent
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}',
|
||||
name: 'torrent_info',
|
||||
@ -57,7 +58,7 @@ class TorrentController extends AbstractController
|
||||
'id' => $torrent->getId(),
|
||||
'added' => $torrent->getAdded(),
|
||||
'locales' => $torrentService->findLastTorrentLocales($torrent->getId()),
|
||||
'sensitive' => $torrentService->findLastTorrentSensitive($torrent->getId()),
|
||||
'sensitive' => $torrentService->findLastTorrentSensitive($torrent->getId())->isValue(),
|
||||
'pages' => []
|
||||
],
|
||||
'file' =>
|
||||
@ -86,9 +87,148 @@ class TorrentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/submit/torrent',
|
||||
name: 'torrent_submit',
|
||||
methods:
|
||||
[
|
||||
'GET',
|
||||
'POST'
|
||||
]
|
||||
)]
|
||||
public function submit(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $userService->init(
|
||||
$request->getClientIp()
|
||||
);
|
||||
|
||||
if (!$user->isStatus())
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Init form
|
||||
$form =
|
||||
[
|
||||
'locales' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('locales') ? $request->get('locales') : [$request->get('_locale')],
|
||||
'placeholder' => $translator->trans('Content language')
|
||||
]
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => null, // is local file, there is no values passed
|
||||
'placeholder' => $translator->trans('Select torrent file')
|
||||
]
|
||||
],
|
||||
'sensitive' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('sensitive'),
|
||||
'placeholder' => $translator->trans('Apply sensitive filters to publication'),
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Process request
|
||||
if ($request->isMethod('post'))
|
||||
{
|
||||
/// Locales
|
||||
$locales = [];
|
||||
if ($request->get('locales'))
|
||||
{
|
||||
foreach ((array) $request->get('locales') as $locale)
|
||||
{
|
||||
if (in_array($locale, explode('|', $this->getParameter('app.locales'))))
|
||||
{
|
||||
$locales[] = $locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// At least one valid locale required
|
||||
if (!$locales)
|
||||
{
|
||||
$form['locales']['error'][] = $translator->trans('At least one locale required');
|
||||
}
|
||||
|
||||
/// Torrent
|
||||
if ($file = $request->files->get('torrent'))
|
||||
{
|
||||
//// Validate torrent file
|
||||
if (filesize($file->getPathName()) > $this->getParameter('app.torrent.size.max'))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Torrent file out of size limit');
|
||||
}
|
||||
|
||||
//// Validate torrent format
|
||||
if (!$torrentService->readTorrentFileByFilepath($file->getPathName()))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Torrent file required');
|
||||
}
|
||||
|
||||
// Request is valid
|
||||
if (empty($form['torrent']['error']) && empty($form['locales']['error']))
|
||||
{
|
||||
// Save data
|
||||
$torrent = $torrentService->add(
|
||||
$file->getPathName(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
(array) $locales,
|
||||
(bool) $request->get('sensitive'),
|
||||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Render form template
|
||||
return $this->render(
|
||||
'default/torrent/submit.html.twig',
|
||||
[
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'form' => $form,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Torrent locales
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/edit/locales/{torrentLocalesId}',
|
||||
name: 'torrent_edit_locales',
|
||||
name: 'torrent_locales_edit',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
@ -270,7 +410,7 @@ class TorrentController extends AbstractController
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/approve/locales/{torrentLocalesId}',
|
||||
name: 'torrent_approve_locales',
|
||||
name: 'torrent_locales_approve',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
@ -321,7 +461,7 @@ class TorrentController extends AbstractController
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_edit_locales',
|
||||
'torrent_locales_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
@ -332,7 +472,7 @@ class TorrentController extends AbstractController
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/delete/locales/{torrentLocalesId}',
|
||||
name: 'torrent_delete_locales',
|
||||
name: 'torrent_locales_delete',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
@ -383,7 +523,7 @@ class TorrentController extends AbstractController
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_edit_locales',
|
||||
'torrent_locales_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
@ -392,16 +532,26 @@ class TorrentController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Torrent sensitive
|
||||
#[Route(
|
||||
'/{_locale}/submit/torrent',
|
||||
name: 'torrent_submit',
|
||||
'/{_locale}/torrent/{torrentId}/edit/sensitive/{torrentSensitiveId}',
|
||||
name: 'torrent_sensitive_edit',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
'torrentSensitiveId' => '\d+',
|
||||
],
|
||||
defaults:
|
||||
[
|
||||
'torrentSensitiveId' => null,
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET',
|
||||
'POST'
|
||||
]
|
||||
)]
|
||||
public function submit(
|
||||
public function editSensitive(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
@ -421,34 +571,81 @@ class TorrentController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init sensitive value
|
||||
if ($request->get('torrentSensitiveId'))
|
||||
{
|
||||
if ($torrentSensitive = $torrentService->getTorrentSensitive($request->get('torrentSensitiveId')))
|
||||
{
|
||||
$sensitive =
|
||||
[
|
||||
'id' => $torrentSensitive->getId(),
|
||||
'value' => $torrentSensitive->isValue(),
|
||||
];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($torrentSensitive = $torrentService->findLastTorrentSensitive($request->get('torrentId')))
|
||||
{
|
||||
$sensitive =
|
||||
[
|
||||
'id' => $torrentSensitive->getId(),
|
||||
'value' => $torrentSensitive->isValue(),
|
||||
]; }
|
||||
|
||||
else
|
||||
{
|
||||
$sensitive =
|
||||
[
|
||||
'id' => null,
|
||||
'value' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Init edition history
|
||||
$editions = [];
|
||||
foreach ($torrentService->findTorrentSensitive($torrent->getId()) as $torrentSensitive)
|
||||
{
|
||||
$editions[] =
|
||||
[
|
||||
'id' => $torrentSensitive->getId(),
|
||||
'added' => $torrentSensitive->getAdded(),
|
||||
'approved' => $torrentSensitive->isApproved(),
|
||||
'active' => $torrentSensitive->getId() == $sensitive['id'],
|
||||
'user' =>
|
||||
[
|
||||
'id' => $torrentSensitive->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->get(
|
||||
$torrentSensitive->getUserId()
|
||||
)->getAddress()
|
||||
),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// Init form
|
||||
$form =
|
||||
[
|
||||
'locales' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('locales') ? $request->get('locales') : [$request->get('_locale')],
|
||||
'placeholder' => $translator->trans('Content language')
|
||||
]
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => null, // is local file, there is no values passed
|
||||
'placeholder' => $translator->trans('Select torrent file')
|
||||
]
|
||||
],
|
||||
'sensitive' =>
|
||||
[
|
||||
'error' => [],
|
||||
'attribute' =>
|
||||
[
|
||||
'value' => $request->get('sensitive'),
|
||||
'placeholder' => $translator->trans('Apply sensitive filters for this publication'),
|
||||
'value' => $sensitive['value'],
|
||||
'placeholder' => $translator->trans('Apply sensitive filters to publication')
|
||||
]
|
||||
]
|
||||
];
|
||||
@ -456,76 +653,161 @@ class TorrentController extends AbstractController
|
||||
// Process request
|
||||
if ($request->isMethod('post'))
|
||||
{
|
||||
/// Locales
|
||||
$locales = [];
|
||||
if ($request->get('locales'))
|
||||
{
|
||||
foreach ((array) $request->get('locales') as $locale)
|
||||
{
|
||||
if (in_array($locale, explode('|', $this->getParameter('app.locales'))))
|
||||
{
|
||||
$locales[] = $locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Save data
|
||||
$torrentService->addTorrentSensitive(
|
||||
$torrent->getId(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
$request->get('sensitive') === 'true',
|
||||
$user->isApproved()
|
||||
);
|
||||
|
||||
//// At least one valid locale required
|
||||
if (!$locales)
|
||||
{
|
||||
$form['locales']['error'][] = $translator->trans('At least one locale required');
|
||||
}
|
||||
|
||||
/// Torrent
|
||||
if ($file = $request->files->get('torrent'))
|
||||
{
|
||||
//// Validate torrent file
|
||||
if (filesize($file->getPathName()) > $this->getParameter('app.torrent.size.max'))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Torrent file out of size limit');
|
||||
}
|
||||
|
||||
//// Validate torrent format
|
||||
if (!$torrentService->readTorrentFileByFilepath($file->getPathName()))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Torrent file required');
|
||||
}
|
||||
|
||||
// Request is valid
|
||||
if (empty($form['torrent']['error']) && empty($form['locales']['error']))
|
||||
{
|
||||
// Save data
|
||||
$torrent = $torrentService->add(
|
||||
$file->getPathName(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
(array) $locales,
|
||||
(bool) $request->get('sensitive'),
|
||||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Render form template
|
||||
return $this->render(
|
||||
'default/torrent/submit.html.twig',
|
||||
'default/torrent/edit/sensitive.html.twig',
|
||||
[
|
||||
'locales' => explode('|', $this->getParameter('app.locales')),
|
||||
'form' => $form,
|
||||
'torrentId' => $torrent->getId(),
|
||||
'editions' => $editions,
|
||||
'form' => $form,
|
||||
'session' =>
|
||||
[
|
||||
'moderator' => $user->isModerator(),
|
||||
'owner' => $user->getId() === $torrentSensitive->getUserId(),
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/approve/sensitive/{torrentSensitiveId}',
|
||||
name: 'torrent_sensitive_approve',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
'torrentSensitiveId' => '\d+',
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET'
|
||||
]
|
||||
)]
|
||||
public function approveSensitive(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $userService->init(
|
||||
$request->getClientIp()
|
||||
);
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init torrent sensitive
|
||||
if (!$torrentSensitive = $torrentService->getTorrentSensitive($request->get('torrentSensitiveId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!$user->isModerator())
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentSensitiveApproved(
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_sensitive_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
'torrentSensitiveId' => $torrentSensitive->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}/delete/sensitive/{torrentSensitiveId}',
|
||||
name: 'torrent_sensitive_delete',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+',
|
||||
'torrentSensitiveId' => '\d+',
|
||||
],
|
||||
methods:
|
||||
[
|
||||
'GET'
|
||||
]
|
||||
)]
|
||||
public function deleteSensitive(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
$user = $userService->init(
|
||||
$request->getClientIp()
|
||||
);
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init torrent sensitive
|
||||
if (!$torrentSensitive = $torrentService->getTorrentSensitive($request->get('torrentSensitiveId')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (!($user->isModerator() || $user->getId() === $torrentSensitive->getUserId()))
|
||||
{
|
||||
// @TODO
|
||||
throw new \Exception(
|
||||
$translator->trans('Access denied')
|
||||
);
|
||||
}
|
||||
|
||||
// Update approved
|
||||
$torrentService->deleteTorrentSensitive(
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Redirect to info page created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_sensitive_edit',
|
||||
[
|
||||
'_locale' => $request->get('_locale'),
|
||||
'torrentId' => $torrent->getId(),
|
||||
'torrentSensitiveId' => $torrentSensitive->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class TorrentService
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(TorrentSensitive::class)
|
||||
->getTorrentLocales($id);
|
||||
->getTorrentSensitive($id);
|
||||
}
|
||||
|
||||
public function findLastTorrentSensitive(int $torrentId): ?TorrentSensitive
|
||||
@ -175,6 +175,22 @@ class TorrentService
|
||||
return $torrentLocales;
|
||||
}
|
||||
|
||||
public function toggleTorrentSensitiveApproved(
|
||||
int $id
|
||||
): ?TorrentSensitive
|
||||
{
|
||||
$torrentSensitive = $this->getTorrentSensitive($id);
|
||||
|
||||
$torrentSensitive->setApproved(
|
||||
!$torrentSensitive->isApproved() // toggle current value
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrentSensitive);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $torrentSensitive;
|
||||
}
|
||||
|
||||
// Delete
|
||||
public function deleteTorrentLocales(
|
||||
int $id
|
||||
@ -188,6 +204,18 @@ class TorrentService
|
||||
return $torrentLocales;
|
||||
}
|
||||
|
||||
public function deleteTorrentSensitive(
|
||||
int $id
|
||||
): ?TorrentSensitive
|
||||
{
|
||||
$torrentSensitive = $this->getTorrentSensitive($id);
|
||||
|
||||
$this->entityManagerInterface->remove($torrentSensitive);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $torrentSensitive;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public function add(
|
||||
string $filepath,
|
||||
|
@ -8,7 +8,7 @@
|
||||
<a href="{{ path('torrent_info', { torrentId : torrentId }) }}">#{{ torrentId }}</a>
|
||||
</h1>
|
||||
</div>
|
||||
<form name="locales" method="post" action="{{ path('torrent_edit_locales', { torrentId : torrentId }) }}">
|
||||
<form name="locales" method="post" action="{{ path('torrent_locales_edit', { torrentId : torrentId }) }}">
|
||||
<div class="margin-y-16-px">
|
||||
<label for="locales">
|
||||
{{'Content language'|trans }}
|
||||
@ -57,7 +57,7 @@
|
||||
{% if edition.active %}
|
||||
{{ edition.added | format_ago }}
|
||||
{% else %}
|
||||
<a href="{{ path('torrent_edit_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}">
|
||||
<a href="{{ path('torrent_locales_edit', { torrentId : torrentId, torrentLocalesId : edition.id }) }}">
|
||||
{{ edition.added | format_ago }}
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -67,7 +67,7 @@
|
||||
</a>
|
||||
<div class="float-right">
|
||||
{% if session.moderator or session.owner %}
|
||||
<a class="margin-r-8-px text-color-red" href="{{ path('torrent_delete_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<a class="margin-r-8-px text-color-red" href="{{ path('torrent_locales_delete', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
||||
@ -76,7 +76,7 @@
|
||||
{% endif %}
|
||||
{% if edition.approved %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_approve_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<a href="{{ path('torrent_locales_approve', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</svg>
|
||||
@ -90,7 +90,7 @@
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_approve_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<a href="{{ path('torrent_locales_approve', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
</svg>
|
||||
|
85
templates/default/torrent/edit/sensitive.html.twig
Normal file
85
templates/default/torrent/edit/sensitive.html.twig
Normal file
@ -0,0 +1,85 @@
|
||||
{% extends 'default/layout.html.twig' %}
|
||||
{% block title %}{{'Torrent'|trans }} #{{ torrentId }} - {{'Edit sensitive status'|trans }} - {{ name }}{% endblock %}
|
||||
{% block main_content %}
|
||||
<div class="padding-24-px margin-y-8-px border-radius-3-px background-color-night">
|
||||
<div class="margin-b-24-px padding-b-16-px border-bottom-default">
|
||||
<h1>
|
||||
{{'Edit sensitive status for torrent'|trans }}
|
||||
<a href="{{ path('torrent_info', { torrentId : torrentId }) }}">#{{ torrentId }}</a>
|
||||
</h1>
|
||||
</div>
|
||||
<form name="sensitive" method="post" action="{{ path('torrent_sensitive_edit', { torrentId : torrentId }) }}">
|
||||
<div class="margin-y-16-px">
|
||||
<input type="checkbox" name="sensitive" id="sensitive" value="true" {% if form.sensitive.attribute.value %}checked="checked"{% endif %} />
|
||||
<label for="sensitive">
|
||||
{{'Sensitive'|trans }}
|
||||
</label>
|
||||
<sub class="opacity-0 parent-hover-opacity-09" title="{{ form.sensitive.attribute.placeholder }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||
</svg>
|
||||
</sub>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="margin-r-8-px" href="{{ path('torrent_info', { torrentId : torrentId }) }}">
|
||||
{{'cancel'|trans }}
|
||||
</a>
|
||||
<input class="button-green" type="submit" value="{{'Submit'|trans }}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% for edition in editions %}
|
||||
<div class="padding-x-24-px padding-y-16-px margin-y-8-px border-radius-3-px {% if edition.active %}background-color-night-light{% else %}background-color-night{% endif %} ">
|
||||
{% if edition.active %}
|
||||
{{ edition.added | format_ago }}
|
||||
{% else %}
|
||||
<a href="{{ path('torrent_sensitive_edit', { torrentId : torrentId, torrentSensitiveId : edition.id }) }}">
|
||||
{{ edition.added | format_ago }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{{ 'by'|trans }}
|
||||
<a href="{{ path('user_info', { id : edition.user.id }) }}">
|
||||
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ edition.user.identicon }}" alt="{{'identicon'|trans }}" />
|
||||
</a>
|
||||
<div class="float-right">
|
||||
{% if session.moderator or session.owner %}
|
||||
<a class="margin-r-8-px text-color-red" href="{{ path('torrent_sensitive_delete', { torrentId : torrentId, torrentSensitiveId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if edition.approved %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_sensitive_approve', { torrentId : torrentId, torrentSensitiveId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</svg>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_sensitive_approve', { torrentId : torrentId, torrentSensitiveId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="{{ 'Waiting for approve' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
</svg>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
@ -178,7 +178,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="padding-y-8-px text-right">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_edit_locales', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_locales_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
@ -194,7 +194,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="padding-y-8-px text-right">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_edit_locales', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
@ -210,7 +210,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="padding-y-8-px text-right">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_edit_locales', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_locales_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
|
||||
</svg>
|
||||
|
@ -58,11 +58,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="margin-y-16-px">
|
||||
<input type="checkbox"
|
||||
name="sensitive"
|
||||
id="sensitive"
|
||||
value="true"
|
||||
{% if form.sensitive.attribute.value %}checked="checked"{% endif %} />
|
||||
<input type="checkbox" name="sensitive" id="sensitive" value="true" {% if form.sensitive.attribute.value %}checked="checked"{% endif %} />
|
||||
<label for="sensitive">
|
||||
{{'Sensitive'|trans }}
|
||||
</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user