mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Location Editing Part 2
Bulk uploading has been added and some inconsistencies in the templates have been addressed. Still needs work but it's starting to feel like a cohesive experience. With the base data entry funcationality in place, now really polishing can begin as well as establishing what roles can do what. Smoothing out entry editing will be addressed as well.
This commit is contained in:
@ -12,6 +12,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use App\Service\HandleLocations;
|
||||
use Doctrine\DBAL\Connection;
|
||||
//use App\Utils\PageRender;
|
||||
//use App\Utils\StringTools;
|
||||
use App\Service\Auth;
|
||||
@ -36,6 +37,8 @@ class Locations extends AbstractController
|
||||
RequestStack $requestStack,
|
||||
Auth $auth,
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
Connection $connection,
|
||||
string $pageNum
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
@ -43,6 +46,11 @@ class Locations extends AbstractController
|
||||
$session = $requestStack->getSession();
|
||||
$member = $session->get("member");
|
||||
$list = $locations->getLocationsPage($pageNum);
|
||||
|
||||
//$search = $connection->fetchAllAssociative("SELECT * FROM searchlocations('agenda')");
|
||||
|
||||
//var_dump($search[0]["name"]);
|
||||
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations",
|
||||
"handle" => $member->getHandle(),
|
||||
@ -140,6 +148,86 @@ class Locations extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/den/locations/bulk-add", name="location-bulk-add")
|
||||
*/
|
||||
public function bulkAddLocation(
|
||||
Request $request,
|
||||
Auth $auth,
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
FileUploader $uploader
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
if ($request->getMethod() == "GET") {
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Bulk Add",
|
||||
"mode" => "bulk-add"
|
||||
]);
|
||||
} else {
|
||||
// do posting stuff
|
||||
$token = $request->get("token");
|
||||
$entityManager = $doctrine->getManager();
|
||||
$notice = '';
|
||||
|
||||
if (!$this->isCsrfTokenValid("upload", $token)) {
|
||||
$logger->info("CSRF failure");
|
||||
return new Response(
|
||||
"Operation not allowed",
|
||||
Response::HTTP_BAD_REQUEST,
|
||||
[
|
||||
"content-type" => "text/plain",
|
||||
]
|
||||
);
|
||||
}
|
||||
//get file from post
|
||||
$file = $request->files->get("myfile");
|
||||
//grab extension
|
||||
if (!empty($file)) {
|
||||
$extention = substr(strrchr($file->getClientOriginalName(), "."), 1);
|
||||
}
|
||||
|
||||
//check it out to make sure it's cool
|
||||
if (
|
||||
empty($file) ||
|
||||
$extention != "csv"
|
||||
) {
|
||||
if (empty($file)) {
|
||||
$notice = 'You didn\'t select a file, boss';
|
||||
} elseif ($extention != "csv") {
|
||||
$notice = "Only files of type .csv are accepted, slick. " . $extention;
|
||||
}
|
||||
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"notice" => $notice,
|
||||
"mode" => "bulk-add"
|
||||
]);
|
||||
}
|
||||
//if it's cool, send it to be processed
|
||||
$response = $locations->addMultipleLocations($file, $result["id"]);
|
||||
if ($response["status"]) {
|
||||
$notice = "New locations added! Take a break.";
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"notice" => $response["message"],
|
||||
"mode" => "bulk-add"
|
||||
]);
|
||||
} else {
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"notice" => $response["message"],
|
||||
"mode" => "bulk-add"
|
||||
]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location:/den");
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/den/locations/edit/{uuid}", name="location-edit")
|
||||
*/
|
||||
|
Reference in New Issue
Block a user