Merge branch 'infoZettel' of http://gitea.cwsvjudo.dedyn.io/marko/cwsvJudo into infoZettel
This commit is contained in:
14
homepage/participo/.vscode/launch.json
vendored
14
homepage/participo/.vscode/launch.json
vendored
@@ -15,6 +15,16 @@
|
||||
"POST",
|
||||
"--input", "testShiai.json"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "getTrainees",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "testApi.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"args": [
|
||||
"GET",
|
||||
"--endpoint", "trainees" ]
|
||||
} ]
|
||||
}
|
||||
@@ -1,179 +1,402 @@
|
||||
<?php
|
||||
<?php
|
||||
setlocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge");
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
|
||||
|
||||
// Configs
|
||||
require_once("config/participo.php");
|
||||
require_once $config['basePath'] . "/config/cwsvJudo.config.php";
|
||||
require_once "config/participo.php";
|
||||
require_once $config["basePath"] . "/config/cwsvJudo.config.php";
|
||||
|
||||
// Libs
|
||||
require_once("participoLib/user.php");
|
||||
require_once "participoLib/user.php";
|
||||
|
||||
participo::init($cwsvJudoConfig);
|
||||
|
||||
$pmelo = new PmElo();
|
||||
|
||||
class PmElo{
|
||||
class PmElo
|
||||
{
|
||||
/** initialize the pmelo session */
|
||||
function __construct()
|
||||
{
|
||||
// $this->var_log($_SESSION, "session");
|
||||
// starting/continuing a session
|
||||
session_start();
|
||||
|
||||
// create 'pmelo' section in the sessions data
|
||||
if(!array_key_exists('pmelo', $_SESSION)){
|
||||
$_SESSION['pmelo'] = [];
|
||||
}
|
||||
// - data storage for id-s of chosen fighters
|
||||
if(!array_key_exists('fighterIds', $_SESSION['pmelo'])){
|
||||
$_SESSION['pmelo']['fighterIds'] = [];
|
||||
if (!array_key_exists("pmelo", $_SESSION)) {
|
||||
$_SESSION["pmelo"] = [];
|
||||
}
|
||||
|
||||
// check for action in post data
|
||||
if(array_key_exists('pmelo', $_POST)){
|
||||
if(array_key_exists('fighterIds', $_POST['pmelo'])){
|
||||
$_SESSION['pmelo']['fighterIds']=$_POST['pmelo']['fighterIds'];
|
||||
}
|
||||
// $this->var_log($_SESSION, "session");
|
||||
// - data storage for id-s of chosen fighters
|
||||
if (!array_key_exists("fighterIds", $_SESSION["pmelo"])) {
|
||||
$_SESSION["pmelo"]["fighterIds"] = [];
|
||||
}
|
||||
|
||||
// load/recreate ranking data
|
||||
if(!is_file(self::$pmeloJson)){
|
||||
$this->log['info'][] = "Couldn't find `".self::$pmeloJson."`. Create a new one!";
|
||||
if (!is_file(self::$pmeloJson)) {
|
||||
$this->log["info"][] =
|
||||
"Couldn't find `" . self::$pmeloJson . "`. Create a new one!";
|
||||
file_put_contents(self::$pmeloJson, json_encode([]));
|
||||
}
|
||||
|
||||
// init members
|
||||
$this->trainees = self::getTrainees();
|
||||
$this->var_log(array_map(function($user){return $user->getFirstName();},$this->trainees), "trainees from db");
|
||||
$this->rankings = $this->createRankings();
|
||||
$this->var_log(array_map(function($id){return $this->trainees[$id]->getFirstName();},$this->rankings), "current ranking");
|
||||
$this->fighters = [];
|
||||
foreach($_SESSION['pmelo']['fighterIds'] as $id){
|
||||
foreach ($_SESSION["pmelo"]["fighterIds"] as $id) {
|
||||
$this->fighters[$id] = $this->trainees[$id];
|
||||
};
|
||||
$this->var_log(array_map(function($user){return $user->getFirstName();},$this->fighters), "fighters");
|
||||
|
||||
}
|
||||
|
||||
// @todo Can be split. Some actions need the members to be already filled, some could be done earlier.
|
||||
// check for action in post data
|
||||
if (array_key_exists("pmelo", $_POST)) {
|
||||
// setting the current fighters
|
||||
// - meaning: fighter list is automatically updated by posted fighters
|
||||
if (array_key_exists("fighterIds", $_POST["pmelo"])) {
|
||||
$_SESSION["pmelo"]["fighterIds"] =
|
||||
$_POST["pmelo"]["fighterIds"];
|
||||
|
||||
header("Location: pmelo");
|
||||
}
|
||||
|
||||
if (array_key_exists("promote", $_POST["pmelo"])) {
|
||||
$promote = $_POST["pmelo"]["promote"];
|
||||
$this->promote(
|
||||
$promote["promoteeId"],
|
||||
$promote["promoteeRank"],
|
||||
$promote["degradeeId"],
|
||||
$promote["degradeeRank"]
|
||||
);
|
||||
|
||||
header("Location: pmelo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// save the updated ranking
|
||||
// @todo should be in destructor
|
||||
self::saveRankings($this->rankings);
|
||||
}
|
||||
|
||||
function __destruct(){
|
||||
// sad, the destructor is not allowed to use file_put_contents
|
||||
////
|
||||
// html code injection
|
||||
///
|
||||
|
||||
/** Echo the fighterInputForm */
|
||||
public function htmlFighterInputForm(){
|
||||
echo($this->getFighterInputForm($this->trainees));
|
||||
}
|
||||
|
||||
// load all active trainees into a id=>User assoc array
|
||||
public static function getTrainees(){
|
||||
$traineeList = array_map('User::fromDbArray', User::dbSelectWithAttribute(4));
|
||||
|
||||
/** Echo the fighterTable */
|
||||
public function htmlFighterTable(){
|
||||
echo($this->getFighterTable($this->fighters, $this->rankings));
|
||||
}
|
||||
|
||||
/** Echo logOutput */
|
||||
public function htmlLogOutput(){
|
||||
echo($this->getLogOutput($this->log));
|
||||
}
|
||||
|
||||
////
|
||||
// saving and loading
|
||||
////
|
||||
|
||||
/** load all active trainees into a id=>User assoc array */
|
||||
static private function getTrainees()
|
||||
{
|
||||
$traineeList = array_map(
|
||||
"User::fromDbArray",
|
||||
User::dbSelectWithAttribute(4)
|
||||
);
|
||||
$traineeAssocArray = [];
|
||||
foreach($traineeList as $trainee){
|
||||
foreach ($traineeList as $trainee) {
|
||||
$traineeAssocArray[$trainee->getId()] = $trainee;
|
||||
}
|
||||
return $traineeAssocArray;
|
||||
}
|
||||
|
||||
// load ranking from json file
|
||||
public static function loadRankings(){
|
||||
/** load ranking from json file */
|
||||
static private function loadRankings()
|
||||
{
|
||||
return json_decode(file_get_contents(self::$pmeloJson));
|
||||
}
|
||||
|
||||
// save a ranking to json file
|
||||
public static function saveRankings(array $rankings){
|
||||
|
||||
/** save a ranking to json file */
|
||||
static private function saveRankings(array $rankings)
|
||||
{
|
||||
file_put_contents(self::$pmeloJson, json_encode($rankings));
|
||||
}
|
||||
|
||||
// simple logger to a logging buffer
|
||||
function var_log($variable, string $prefix=null, string $logChannel='info'){
|
||||
if(!in_array($logChannel, ['info', 'warning', 'error'])){
|
||||
$logChannel='info';
|
||||
}
|
||||
$prefix = (!empty($prefix) ? $prefix.": " : "");
|
||||
$this->log[$logChannel][]=$prefix.var_export($variable, true);
|
||||
}
|
||||
////
|
||||
// member functions
|
||||
////
|
||||
|
||||
// create the ranking for the current session (load saved ranking from file, remove old trainees, add new trainees)
|
||||
public function createRankings(){
|
||||
/** create the ranking for the current session
|
||||
*
|
||||
* - load saved ranking from file
|
||||
* - remove old trainees
|
||||
* - add new trainees
|
||||
*/
|
||||
private function createRankings()
|
||||
{
|
||||
// load the last state of the ranking
|
||||
$loadedRanking = self::loadRankings();
|
||||
$this->var_log(array_map(function($id){$user=$this->trainees[$id]; return $user->getFirstName();}, $loadedRanking), "loaded ranking");
|
||||
|
||||
// check if the ranked trainees still are in training
|
||||
// - the ranking with
|
||||
$cleanRanking = [];
|
||||
// - trainees that aren't currently in the ranking for later inserting
|
||||
$toBeInsertedTrainees = $this->trainees;
|
||||
foreach($loadedRanking as $id){
|
||||
if(array_key_exists($id, $this->trainees)){
|
||||
foreach ($loadedRanking as $id) {
|
||||
if (array_key_exists($id, $this->trainees)) {
|
||||
// userId is still in training, so append it to the cleaned up ranking
|
||||
$cleanRanking[] = $id;
|
||||
// trainees already in the ranking we won't have to insert manual
|
||||
unset($toBeInsertedTrainees[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
// get the ids of the to be inserted trainees sorted by the birthday
|
||||
$newTraineesIds = array_map(function($u){return $u->getId();},$toBeInsertedTrainees);
|
||||
usort(
|
||||
$newTraineesIds
|
||||
, function($lhs, $rhs){
|
||||
return $this->trainees[$lhs]->getStrBirthday() < $this->trainees[$rhs]->getStrBirthday() ? -1 : ($this->trainees[$lhs]->getStrBirthday() > $this->trainees[$rhs]->getStrBirthday() ? 1 : 0);
|
||||
}
|
||||
);
|
||||
// $this->var_log(
|
||||
// array_map(
|
||||
// function($id){return $this->trainees[$id]->getStrBirthday()." ".$this->trainees[$id]->getFirstName();}
|
||||
// , $newTraineesIds
|
||||
// )
|
||||
// , "newTraineesBy B-Day"
|
||||
// );
|
||||
|
||||
// now we do a mergesort (step)
|
||||
// get the ids of the to be inserted trainees sorted by the birthday
|
||||
$newTraineesIds = array_map(function ($u) {
|
||||
return $u->getId();
|
||||
}, $toBeInsertedTrainees);
|
||||
usort($newTraineesIds, function ($lhs, $rhs) {
|
||||
return $this->trainees[$lhs]->getStrBirthday() <
|
||||
$this->trainees[$rhs]->getStrBirthday()
|
||||
? -1
|
||||
: ($this->trainees[$lhs]->getStrBirthday() >
|
||||
$this->trainees[$rhs]->getStrBirthday()
|
||||
? 1
|
||||
: 0);
|
||||
});
|
||||
|
||||
// now we do a mergesort (step)
|
||||
$updatedRanking = [];
|
||||
$idxNewTrainees = count($newTraineesIds)-1;
|
||||
$idxRanking = count($cleanRanking)-1;
|
||||
$idxNewTrainees = count($newTraineesIds) - 1;
|
||||
$idxRanking = count($cleanRanking) - 1;
|
||||
// - while we can merge, we merge
|
||||
while( ($idxRanking >= 0) && ($idxNewTrainees >= 0) ){
|
||||
// $this->var_log( [$idxRanking.", ".$idxNewTrainees=>$updatedRanking] );
|
||||
// $this->var_log(
|
||||
// [$this->trainees[$cleanRanking[$idxRanking]]->getStrBirthday(), $this->trainees[$newTraineesIds[$idxRanking]]->getStrBirthday()]
|
||||
// );
|
||||
if(
|
||||
$this->trainees[$cleanRanking[$idxRanking]]->getDateOfBirth()
|
||||
> $this->trainees[$newTraineesIds[$idxNewTrainees]]->getDateOfBirth()
|
||||
){
|
||||
// $this->var_log( $this->trainees[$cleanRanking[$idxRanking]]->getFirstName(), "merge ranking insert" );
|
||||
while ($idxRanking >= 0 && $idxNewTrainees >= 0) {
|
||||
if (
|
||||
$this->trainees[$cleanRanking[$idxRanking]]->getDateOfBirth() >
|
||||
$this->trainees[
|
||||
$newTraineesIds[$idxNewTrainees]
|
||||
]->getDateOfBirth()
|
||||
) {
|
||||
array_unshift($updatedRanking, $cleanRanking[$idxRanking]);
|
||||
$idxRanking-=1;
|
||||
}else{
|
||||
// $this->var_log( $this->trainees[$newTraineesIds[$idxNewTrainees]]->getFirstName(), "merge trainees insert" );
|
||||
array_unshift($updatedRanking, $newTraineesIds[$idxNewTrainees]);
|
||||
$idxNewTrainees-=1;
|
||||
$idxRanking -= 1;
|
||||
} else {
|
||||
array_unshift(
|
||||
$updatedRanking,
|
||||
$newTraineesIds[$idxNewTrainees]
|
||||
);
|
||||
$idxNewTrainees -= 1;
|
||||
}
|
||||
}
|
||||
// $this->var_log(
|
||||
// ["idxR ".$idxRanking." idxNT ".$idxNewTrainees=>[$cleanRanking, $newTraineesIds]]
|
||||
// , "after merge"
|
||||
// );
|
||||
while( $idxRanking >= 0 ){
|
||||
// $this->var_log( $this->trainees[$cleanRanking[$idxRanking]]->getFirstName(), "rest ranking insert" );
|
||||
while ($idxRanking >= 0) {
|
||||
array_unshift($updatedRanking, $cleanRanking[$idxRanking]);
|
||||
$idxRanking-=1;
|
||||
$idxRanking -= 1;
|
||||
}
|
||||
while( $idxNewTrainees >= 0 ){
|
||||
// $this->var_log( $this->trainees[$newTraineesIds[$idxNewTrainees]]->getFirstName(), "rest newTrainees insert" );
|
||||
while ($idxNewTrainees >= 0) {
|
||||
array_unshift($updatedRanking, $newTraineesIds[$idxNewTrainees]);
|
||||
$idxNewTrainees-=1;
|
||||
$idxNewTrainees -= 1;
|
||||
}
|
||||
return $updatedRanking;
|
||||
}
|
||||
|
||||
public $log = ['error'=>[], 'warning'=>[], 'info'=>[]];
|
||||
public $fighters = null;
|
||||
public $trainees = null;
|
||||
// list of id-s in the order of the current ranking
|
||||
public $rankings = null;
|
||||
/** promote a fighter
|
||||
*
|
||||
* Promotion means two fighter switch places
|
||||
*
|
||||
* $promoteeId (int>0) id to promote
|
||||
* $promopteeRank (int>0) current rank of the one to be promoted
|
||||
* $degradeeId (int>0) id to demote
|
||||
* $degradeeRank (int>0) new rank of the promotee
|
||||
*/
|
||||
private function promote(
|
||||
int $promoteeId,
|
||||
int $promoteeRank,
|
||||
int $degradeeId,
|
||||
int $degradeeRank
|
||||
) {
|
||||
// input sanitation
|
||||
filterId($promoteeId);
|
||||
filterId($promoteeRank);
|
||||
filterId($degradeeId);
|
||||
filterId($degradeeRank);
|
||||
// check if both id are in the current fighter list
|
||||
if (
|
||||
array_key_exists($promoteeId, $this->fighters) &&
|
||||
array_key_exists($degradeeId, $this->fighters)
|
||||
) {
|
||||
// check their current rank
|
||||
if (
|
||||
$this->rankings[$promoteeRank] == $promoteeId &&
|
||||
$this->rankings[$degradeeRank] == $degradeeId
|
||||
) {
|
||||
// @todo check if they are rank neighbors in the fighter list
|
||||
if (true) {
|
||||
// do the actual switch
|
||||
$this->rankings[$promoteeRank] = $degradeeId;
|
||||
$this->rankings[$degradeeRank] = $promoteeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
// save the updated ranking
|
||||
$this->saveRankings($this->rankings);
|
||||
}
|
||||
|
||||
static $pmeloJson="./pmeloRanking.json";
|
||||
}
|
||||
////
|
||||
// helper for output generation
|
||||
////
|
||||
|
||||
/** Assemble the Input form for the fighter selection
|
||||
*
|
||||
* $trainees (array(participo::user)) list of trainees that can be selected for fighting
|
||||
*
|
||||
* return fighterInputForm as html code
|
||||
*/
|
||||
static private function getFighterInputForm(array $trainees){
|
||||
$style = [
|
||||
'classes'=>[
|
||||
'input-field' => "input-field col s12"
|
||||
]
|
||||
];
|
||||
|
||||
$retHtml =
|
||||
'<form id="pmelo-form-fighters" action="pmelo" method="post">'
|
||||
// selects have to be wrapped into an .input-field, limitation of materializeCss
|
||||
.'<div class='.$style['classes']['input-field'].'>'
|
||||
.'<select name="pmelo[fighterIds][]" id="pmelo-form-fighters-select" multiple>'
|
||||
.'<option value="" disabled selected>Kämpfer auswählen</option>';
|
||||
foreach ($trainees as $trainee) {
|
||||
$retHtml .=
|
||||
'<option value="'.$trainee->getId().'">'.
|
||||
$trainee->getFirstname().' '.$trainee->getName().
|
||||
'</option>';
|
||||
}
|
||||
$retHtml .=
|
||||
'</select>'.
|
||||
'<label for="pmelo-form-fighters-select">'.
|
||||
'Kämpfer auswählen'.
|
||||
'</label>'.
|
||||
'<input type="submit" value="Liste erstellen">'.
|
||||
'</div>'.
|
||||
'</form>';
|
||||
return $retHtml;
|
||||
}
|
||||
|
||||
/** Assemble the ranking table of the fighters
|
||||
*
|
||||
* $fighters (array(id=>participo::User)) list of fighters in the active round
|
||||
* $ranking (array(rank=>id)) ranking of the current selected fighters
|
||||
*
|
||||
* return fighter ranking table as html code
|
||||
*/
|
||||
static private function getFighterTable(array $fighters, array $rankings){
|
||||
$retHtml =
|
||||
'<table>'.
|
||||
'<thead><tr><th>Platz</th><th>Name</th><th>Aufstieg</th></tr></thead>'.
|
||||
'<tbody>';
|
||||
if (!empty($fighters)) {
|
||||
// cache the predecessor in the ranking for the promoting form
|
||||
$lastOne = null;
|
||||
foreach ($rankings as $rank => $id) {
|
||||
if (array_key_exists($id, $fighters)) {
|
||||
$fighter = $fighters[$id];
|
||||
$retHtml .= '<tr>'.
|
||||
'<td>'.$rank.'</td>'.
|
||||
'<td>'.join(' ', [$fighter->getFirstName(), $fighter->getName()]).'</td>';
|
||||
if (!is_null($lastOne)){
|
||||
$retHtml .= '<td>'.self::getPromoteButton(
|
||||
$fighter->getId(),$rank,
|
||||
$lastOne["id"],$lastOne["rank"]
|
||||
).'</td>';
|
||||
}
|
||||
$retHtml .= '</tr>';
|
||||
$lastOne = ["id" => $fighter->getId(), "rank" => $rank];
|
||||
}
|
||||
}
|
||||
}
|
||||
$retHtml .=
|
||||
'</tbody>'.
|
||||
'</table>';
|
||||
|
||||
return $retHtml;
|
||||
}
|
||||
|
||||
/** Assemble a Promote button
|
||||
*
|
||||
* $promoteeId (int>0) id to promote
|
||||
* $promoteeRank (int>0) current rank of the promotee
|
||||
* $degradeeId (int>0) id to demote
|
||||
* $degradeeRank (int>0) rank of the to be demoted
|
||||
*/
|
||||
static private function getPromoteButton(
|
||||
int $promoteeId,
|
||||
int $promoteeRank,
|
||||
int $degradeeId,
|
||||
int $degradeeRank
|
||||
) {
|
||||
return "<form action=\"pmelo\" method=\"post\">" .
|
||||
"<input type= \"hidden\" name=\"pmelo[promote][promoteeId]\" value=\"" . $promoteeId . "\" />" .
|
||||
"<input type= \"hidden\" name=\"pmelo[promote][promoteeRank]\" value=\"" . $promoteeRank . "\" />" .
|
||||
"<input type= \"hidden\" name=\"pmelo[promote][degradeeId]\" value=\"" . $degradeeId . "\" />" .
|
||||
"<input type= \"hidden\" name=\"pmelo[promote][degradeeRank]\" value=\"" . $degradeeRank . "\">" .
|
||||
"<input class=\"btn\" type=\"submit\" value=\"^\">".
|
||||
"</form>";
|
||||
}
|
||||
|
||||
/** Assemble the log Output
|
||||
*
|
||||
* $log (array logLevel=>array(messages)) lists of log messages per logLevel
|
||||
*
|
||||
* return logOutput as html code
|
||||
*/
|
||||
private static function getLogOutput(array $log){
|
||||
$retHtml =
|
||||
'<ul class="collection with-header">'.
|
||||
'<li class="collection-header"><h3>Logs</h3></li>';
|
||||
foreach ($log as $logLevel => $messages) {
|
||||
if (!empty($messages)) {
|
||||
$retHtml .=
|
||||
'<li class="collection-item">'.
|
||||
'<ul class="collection with-header">'.
|
||||
'<li class="collection-header">'.$logLevel.'</li>';
|
||||
foreach ($messages as $message) {
|
||||
$retHtml .=
|
||||
'<li>'.$message.'</li>';
|
||||
}
|
||||
$retHtml .=
|
||||
'</ul>'.
|
||||
'</li>';
|
||||
}
|
||||
}
|
||||
|
||||
return $retHtml;
|
||||
}
|
||||
|
||||
/** simple logger to a logging buffer */
|
||||
private function var_log(
|
||||
$variable,
|
||||
string $prefix = null,
|
||||
string $logChannel = "info"
|
||||
) {
|
||||
if (!in_array($logChannel, ["info", "warning", "error"])) {
|
||||
$logChannel = "info";
|
||||
}
|
||||
$prefix = !empty($prefix) ? $prefix . ": " : "";
|
||||
$this->log[$logChannel][] = $prefix . var_export($variable, true);
|
||||
}
|
||||
|
||||
////
|
||||
// member variables
|
||||
////
|
||||
|
||||
/** current chosen trainees for fighting [id=>participo::User] */
|
||||
public $fighters = null;
|
||||
/** current trainees available for fighting as [id=>participo::User] */
|
||||
public $trainees = null;
|
||||
/** the current ranking as [rank=>id] */
|
||||
public $rankings = null;
|
||||
/** a place to save log messages for later output */
|
||||
public $log = ["error" => [], "warning" => [], "info" => []];
|
||||
|
||||
static $pmeloJson = "./pmeloRanking.json";
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php require_once("pmelo.inc.php");?>
|
||||
<?php require_once "pmelo.inc.php"; ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- shared imports (common css, MaterializeCss) -->
|
||||
<?php readfile('shared/imports.php'); ?>
|
||||
<?php readfile("shared/imports.php"); ?>
|
||||
|
||||
<!-- inits for the materializeCss -->
|
||||
<script src="index.js"></script>
|
||||
@@ -32,74 +32,16 @@
|
||||
<img alt="cwsvJudoApps" style="max-width:100%;height:12vh;" class="responsive-img" src="http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png" />
|
||||
</a>
|
||||
</li>
|
||||
<?php require_once 'sidenav/loginStatus.php'; ?><!-- brings its own li -->
|
||||
<?php require_once "sidenav/loginStatus.php"; ?><!-- brings its own li -->
|
||||
</ul>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h2><a href="pmelo">pmElo</a></h2>
|
||||
|
||||
<form id="pmelo-form-fighters" action="pmelo.php" method="post">
|
||||
<div class="input-field col s12">
|
||||
<select name ="pmelo[fighterIds][]" id="pmelo-form-fighters-select" multiple>
|
||||
<option value="" disabled selected>Kämpfer auswählen</option>
|
||||
<?php
|
||||
foreach($pmelo->trainees as $trainee){
|
||||
echo("<option value=\"".$trainee->getId()."\">".$trainee->getFirstname()." ".$trainee->getName()."</option>".PHP_EOL);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<label for="form-select-2">Kämpfer auswählen</label>
|
||||
<input type="submit" value="Liste erstellen">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Platz</th><th>Name</th><th>Aufstieg</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if(!empty($pmelo->fighters)){
|
||||
foreach($pmelo->rankings as $rank=>$id){
|
||||
if(array_key_exists($id, $pmelo->fighters)){
|
||||
$fighter = $pmelo->fighters[$id];
|
||||
// echo("<tr><td>".$rank."</td><td>".$fighter->getFirstName()."</td></tr>".PHP_EOL);
|
||||
echo("<tr><td>".$rank."</td><td>".$fighter->getFirstName()." ".$fighter->getName()."</td><td>^</td></tr>".PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul class="collection with-header">
|
||||
<li class="collection-header"><h3>Logs</h3></li>
|
||||
<?php
|
||||
foreach($pmelo->log as $logLevel=>$messages){
|
||||
if(!empty($messages)){
|
||||
?>
|
||||
<li class="collection-item">
|
||||
<ul class="collection with-header">
|
||||
<li class="collection-header"><?php echo($logLevel);?></li>
|
||||
<?php
|
||||
foreach($messages as $message){
|
||||
?>
|
||||
<li>
|
||||
<?php echo($message); ?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php $pmelo->htmlFighterInputForm();?>
|
||||
<?php $pmelo->htmlFighterTable();?>
|
||||
<?php $pmelo->htmlLogOutput();?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,49 +5,32 @@ import json
|
||||
|
||||
|
||||
class TestApi:
|
||||
|
||||
@staticmethod
|
||||
def __parse_arguments():
|
||||
import argparse
|
||||
|
||||
argParser = argparse.ArgumentParser(
|
||||
"testApi"
|
||||
)
|
||||
argParser.add_argument(
|
||||
"method",
|
||||
choices=['GET', 'POST']
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--endpoint",
|
||||
default="shiai"
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--host",
|
||||
default="cwsvjudo.bplaced.net"
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--path",
|
||||
default="participo/api"
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--key",
|
||||
default=None
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--configFile",
|
||||
type=argparse.FileType('r'),
|
||||
default="testApi.config.yaml"
|
||||
)
|
||||
argParser = argparse.ArgumentParser("testApi")
|
||||
argParser.add_argument("method", choices=['GET', 'POST'])
|
||||
argParser.add_argument("--endpoint", default="shiai")
|
||||
argParser.add_argument("--host", default="cwsvjudo.bplaced.net")
|
||||
argParser.add_argument("--path", default="participo/api")
|
||||
argParser.add_argument("--key", default=None)
|
||||
argParser.add_argument("--configFile",
|
||||
type=argparse.FileType('r'),
|
||||
default="testApi.config.yaml")
|
||||
_LOG_LEVEL = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
|
||||
argParser.add_argument(
|
||||
"--logLevel",
|
||||
choices=_LOG_LEVEL,
|
||||
default="WARNING"
|
||||
)
|
||||
argParser.add_argument(
|
||||
"--input", "-i",
|
||||
type=argparse.FileType("r"),
|
||||
default="-"
|
||||
)
|
||||
argParser.add_argument("--logLevel",
|
||||
choices=_LOG_LEVEL,
|
||||
default="WARNING")
|
||||
argParser.add_argument("--input",
|
||||
"-i",
|
||||
type=argparse.FileType("r"),
|
||||
default="-")
|
||||
argParser.add_argument("--output",
|
||||
"-o",
|
||||
type=argparse.FileType("w"),
|
||||
default="-")
|
||||
|
||||
return argParser.parse_args()
|
||||
|
||||
@@ -70,11 +53,8 @@ class TestApi:
|
||||
method=self.config.method,
|
||||
host=self.config.host,
|
||||
url="/".join([self.config.path, self.config.endpoint]),
|
||||
headers={
|
||||
"Authorization": f"Basic {self.config.key}"
|
||||
},
|
||||
input=load_json(self.config.input)
|
||||
)
|
||||
headers={"Authorization": f"Basic {self.config.key}"},
|
||||
input=load_json(self.config.input))
|
||||
|
||||
|
||||
def load_json(jsonFile):
|
||||
@@ -82,7 +62,9 @@ def load_json(jsonFile):
|
||||
with jsonFile as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
class apiCall:
|
||||
|
||||
@staticmethod
|
||||
def call(
|
||||
method: str,
|
||||
@@ -93,19 +75,15 @@ class apiCall:
|
||||
) -> dict:
|
||||
import requests
|
||||
|
||||
if(method=="GET"):
|
||||
r = requests.get(
|
||||
url=f"http://{host}/{url}",
|
||||
timeout=10,
|
||||
headers=headers
|
||||
)
|
||||
elif(method=="POST"):
|
||||
r = requests.post(
|
||||
json=input,
|
||||
url=f"http://{host}/{url}",
|
||||
timeout=10,
|
||||
headers=headers
|
||||
)
|
||||
if (method == "GET"):
|
||||
r = requests.get(url=f"http://{host}/{url}",
|
||||
timeout=10,
|
||||
headers=headers)
|
||||
elif (method == "POST"):
|
||||
r = requests.post(json=input,
|
||||
url=f"http://{host}/{url}",
|
||||
timeout=10,
|
||||
headers=headers)
|
||||
else:
|
||||
logging.error("This line should never been reached!")
|
||||
|
||||
@@ -122,11 +100,6 @@ if __name__ == "__main__":
|
||||
response = testApi.apiCall()
|
||||
|
||||
try:
|
||||
print(
|
||||
json.dumps(
|
||||
response,
|
||||
indent=2
|
||||
)
|
||||
)
|
||||
print(json.dumps(response, indent=2))
|
||||
except Exception as e:
|
||||
logging.error(f"Exception {repr(e)} ({e}) while parsing json:")
|
||||
|
||||
55
infoZettelOrg/2024-02-24-Trainingsverlegung.md
Normal file
55
infoZettelOrg/2024-02-24-Trainingsverlegung.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
title: Trainingsverlegung am 1.3.
|
||||
---
|
||||
|
||||
- [Verlegung des Trainingsortes am Freitag (01.03.2024)](#verlegung-des-trainingsortes-am-freitag-01032024)
|
||||
- [Werbung in eigener Sache](#werbung-in-eigener-sache)
|
||||
- [Sommerlager 20.6.- 25.6.2024](#sommerlager-206--2562024)
|
||||
- [Schwimmen](#schwimmen)
|
||||
- [Aktualisierung eMail](#aktualisierung-email)
|
||||
|
||||
## Verlegung des Trainingsortes am Freitag (01.03.2024)
|
||||
|
||||
- Datum: 01.03.2024
|
||||
- Zeit: 16:00-18:00 Uhr alle
|
||||
- Ort: [Gymnastikraum der Sachsenhalle][mapSachsenhalle]
|
||||
|
||||
Am Freitag, dem 01.03.2024, werden wir unser Dojo den Karateka überlassen. Stattdessen weichen wir wieder mal in den [Gymnastikraum der Sachsenhalle][mapSachsenhalle] (Str. Usti nad Labem 275, 09119 Chemnitz) aus.
|
||||
|
||||
Das Training der Großen wird diesmal nicht in der gewohnten Form stattfinden, stattdessen wird es einen Spieleabend geben: Jeder bringt ein kleines Spiel (vorzugsweise für die mehrere Teilnehmer und schnell zu erklären) und wir machen uns einen schönen, geselligen im Beratungsraum.
|
||||
|
||||
Wer von den Großen nicht auf ganz auf das Judo verzichten möchte, kann gerne bei denKleinen schon mitmachen: Viele Leute (und vor allem viele verschiedene Gürtelfarben) und die große Halle wären die perfekte Gelegenheit für Seeungeheuer.
|
||||
|
||||
## Werbung in eigener Sache
|
||||
|
||||
### Sommerlager 20.6.- 25.6.2024
|
||||
|
||||
Auch im nächstes Jahr wollen wir wieder gemeinsam mit den Karateka ins Sommerlager fahren. Dieses Mal geht es vom 20.6.- 25.6.2024 ins Schullandheim Bautzen-Burk.
|
||||
|
||||
Adresse:
|
||||
|
||||
- Nimschützer Str. 10
|
||||
- 02625 Bautzen
|
||||
- [Homepage des Schullandheimes Bautzen][schullandheimBautzen]
|
||||
|
||||
Die Kosten belaufen sich diesmal auf 250,00 €.
|
||||
|
||||
Die Plätze für die Judoka sind auf 10 begrenzt und 5 sind schon vergeben. Wer Interesse hat, kann sich bei mir melden.
|
||||
|
||||
### Schwimmen
|
||||
|
||||
Erinnerung an unseren sonntäglichen Schwimmtreff: Jeden Sonntag 10:00 Uhr treffen wir uns am [Stadtbad Chemnitz (Mühlenstraße 27, 09111 Chemnitz)][mapStadtbad].
|
||||
|
||||
Es hat mich in letzter Zeit sehr gefreut nicht alleine schwimmen zu müssen und vielleicht hat der eine oder andere ja noch Lust darauf.
|
||||
|
||||
## Aktualisierung eMail
|
||||
|
||||
Damit der NewsLetter ordentlich ankommt, hier mal die Bitte um Aktualisierung der eMail Adressen: Wer den NewsLetter an eine andere oder zusätzliche eMail haben möchte, soll mir das bitte mitteilen. Wenn jemand gar keinen NewsLetter bekommt, dann wahrscheinlich, weil ich die eMail Adresse nicht habe. Auch da die Bitte: Wer gerne den NewsLetter erhalten möchte, soll mir die Ziel Adresse mitteilen.
|
||||
|
||||
Wenn das von den Eltern gewünscht ist, können auch die Kinder selber den NewsLetter mit erhalten.
|
||||
|
||||
MsG marko
|
||||
|
||||
[mapStadtbad]: https://osm.org/go/0MIY_~XdV-
|
||||
[mapSachsenhalle]: https://osm.org/go/0MIYhooV9--
|
||||
[schullandheimBautzen]: https://www.schullandheime.de/bautzen
|
||||
Reference in New Issue
Block a user