Skip to content

Commit

Permalink
Merge pull request #168 from alexmattoni/master
Browse files Browse the repository at this point in the history
Lock game attendance
  • Loading branch information
ddbruce authored Feb 7, 2024
2 parents ba858d8 + 81c5294 commit af6cf3e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .add_game.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
$date = $input['datestamp'];
$type = $input['type'];
$ees = 0;
$locked = $input['locked'];
$mode = $input['mode'];

if($mode == 'edit') {
Expand Down Expand Up @@ -55,7 +56,7 @@

$logid = $statement->fetchAll(PDO::FETCH_ASSOC)[0]['max'] + 1;

$statement = $connection->prepare("INSERT INTO games(id, `date`, start, `end`, description, location, ees, hide) VALUES (:logid, :date, :start_time, :end_time, :event_name, :event_location, :ees, 0)");
$statement = $connection->prepare("INSERT INTO games(id, `date`, start, `end`, description, location, locked, ees, hide) VALUES (:logid, :date, :start_time, :end_time, :event_name, :event_location, 0, :ees, 0)");

$statement->bindParam(":logid", $logid);
$statement->bindParam(":date", $date);
Expand All @@ -73,6 +74,7 @@
`end`=:end_time,
`description`=:event_name,
`location`=:event_location,
`locked`=:locked,
`hide`=0
WHERE id=:id");

Expand All @@ -82,6 +84,7 @@
$statement->bindParam(":end_time", $end_time);
$statement->bindParam(":event_name", $event_name);
$statement->bindParam(":event_location", $event_location);
$statement->bindParam(":locked", $locked);

$result = $statement->execute();
}
Expand Down
1 change: 1 addition & 0 deletions .docker/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ CREATE TABLE `games` (
`end` time NOT NULL DEFAULT '00:00:00',
`description` text NOT NULL,
`location` text NOT NULL,
`locked` tinyint(1) NOT NULL DEFAULT '0',
`ees` tinyint(1) NOT NULL DEFAULT '0',
`hide` tinyint(1) NOT NULL,
`gcalEventId` VARCHAR(255) DEFAULT NULL
Expand Down
5 changes: 4 additions & 1 deletion js/controllers/AddEventCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ angular.module(ctrl_name, []).controller(ctrl_name, ['$scope', '$http', '$locati
end_time: "",
date: "",
type: "",
limit: ""
limit: "",
locked: ""
};

function parseDateString(string) {
Expand Down Expand Up @@ -81,6 +82,7 @@ angular.module(ctrl_name, []).controller(ctrl_name, ['$scope', '$http', '$locati
$scope.formData.date = parseDateString(response.data.event.date);
$scope.formData.type = "1";
$scope.formData.limit = parseInt(response.data.event.limit);
$scope.formData.locked = "-1";
}
});

Expand All @@ -106,6 +108,7 @@ angular.module(ctrl_name, []).controller(ctrl_name, ['$scope', '$http', '$locati
} else {
$scope.formData.type = "2";
}
$scope.formData.locked = response.data.game.locked;
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion js/controllers/GameCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ angular.module(ctrl_name, []).controller(ctrl_name, ['$scope', '$http', '$httpPa
console.log(response.data);
$scope.attendees = response.data.attendees;
$scope.game = response.data.game;
$scope.locked = response.data.game.locked;
$scope.alreadySignedUp = response.data.alreadySignedUp;
$scope.eligiblePositions = response.data.eligiblePositions;
$scope.currentPosition = response.data.currentPosition;
Expand Down Expand Up @@ -73,7 +74,7 @@ angular.module(ctrl_name, []).controller(ctrl_name, ['$scope', '$http', '$httpPa
$scope.load();

$scope.signup = function (position) {
if ($scope.alreadySignedUp && $scope.currentPosition === position) {
if (($scope.alreadySignedUp && $scope.currentPosition === position) || $scope.locked === '1') {
return;
}

Expand Down
7 changes: 6 additions & 1 deletion views/add-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ <h2 ng-if-start="!editMode">Add Event</h2>
<option value="3">Game (NO EES)</option>
</select>
</div>
<div class="form-group col-xs-6 fixed-height-form-element" ng-if="editMode && formData.type != 1"></div>

<div class="form-group col-xs-6 fixed-height-form-element" ng-if="editMode && formData.type != 1">
<label for="locked">Lock Game</label>
<input type="checkbox" name="locked" id="locked" class="form-control" ng-model="formData.locked" ng-true-value="'1'" ng-false-value="'0'" ng-checed="formData.locked" style="margin: 0px; height: 32px"/>
</div>

<div class="form-group col-xs-6 fixed-height-form-element" ng-if="!formData.type || formData.type == 1">
<label for="lim">Attendance Limit</label>
<input type="number" name="lim" id="lim" class="form-control" ng-model="formData.limit" min="-1"
placeholder="0 for no limit, -1 for no signups" required/>
<p class="help-block text-small">Note: Games do not have a specifiable limit.</p>
</div>

<div class="form-group col-xs-6 fixed-height-form-element" ng-if="!editMode && (!formData.type || formData.type == 1)"></div>

<div class="form-actions" ng-if="!editMode">
Expand Down
2 changes: 1 addition & 1 deletion views/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h3 class="btn-toolbar">
<button class="btn btn-primary btn-lg" ng-if="alreadySignedUp" ng-click="drop()">
<span class="fa fa-minus"></span> Drop Game
</button>
<button class="btn btn-primary btn-lg" ng-repeat="p in positions" ng-if="p.value !== currentPosition && eligiblePositions.indexOf(p.value) !== -1" ng-click="signup(p.value)">
<button class="btn btn-primary btn-lg" ng-repeat="p in positions" ng-if="p.value !== currentPosition && eligiblePositions.indexOf(p.value) !== -1 && locked == '0'" ng-click="signup(p.value)">
<span class="fa fa-plus"></span>
<span ng-if="!alreadySignedUp">Sign up as</span>
<span ng-if="alreadySignedUp">Switch to</span>
Expand Down

0 comments on commit af6cf3e

Please sign in to comment.