Compare commits
2 Commits
8654db9125
...
f70a5d69e3
Author | SHA1 | Date |
---|---|---|
|
f70a5d69e3 | |
|
a6ff9a7291 |
|
@ -2,7 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="icon" href="/squidward.webp">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>availabili.tf</title>
|
||||
</head>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
|
@ -250,6 +250,11 @@ input, textarea {
|
|||
sans-serif;
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
width: unset;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import type { PlayerRoleSchema } from './PlayerRoleSchema';
|
||||
export type CreateEventJson = {
|
||||
description: (string | null);
|
||||
includePlayersWithoutRoles?: boolean;
|
||||
name: string;
|
||||
playerRoles: Array<PlayerRoleSchema>;
|
||||
startTime: string;
|
||||
|
|
|
@ -54,10 +54,6 @@ function saveRoster() {
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
//if (!team.value) {
|
||||
// teamsStore.fetchTeam(teamId.value);
|
||||
//}
|
||||
|
||||
if (eventId.value) {
|
||||
eventsStore.fetchEvent(eventId.value)
|
||||
.then((response) => {
|
||||
|
@ -89,6 +85,18 @@ onMounted(() => {
|
|||
<h3>Description (optional)</h3>
|
||||
<input v-model="rosterStore.description" />
|
||||
</div>
|
||||
<div class="form-group margin" v-if="!eventId">
|
||||
<div>
|
||||
<input
|
||||
v-model="rosterStore.includePlayersWithoutRoles"
|
||||
type="checkbox"
|
||||
name="includePlayersWithoutRoles"
|
||||
/>
|
||||
<label for="includePlayersWithoutRoles">
|
||||
Include attendance of players without assigned role
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group margin">
|
||||
<div class="action-buttons">
|
||||
<button class="accent" @click="saveRoster">Save roster</button>
|
||||
|
|
|
@ -8,13 +8,14 @@ export function useEventForm() {
|
|||
const title = ref("");
|
||||
const description = ref<string | null>("");
|
||||
const players = ref<PlayerRoleSchema[]>([]);
|
||||
const includePlayersWithoutRoles = ref(false);
|
||||
const eventId = computed<number | undefined>(() => Number(route.params.eventId));
|
||||
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
players,
|
||||
includePlayersWithoutRoles,
|
||||
eventId,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ export const useRosterStore = defineStore("roster", () => {
|
|||
|
||||
const startTime = ref<number>();
|
||||
|
||||
const { title, description } = useEventForm();
|
||||
const { title, description, includePlayersWithoutRoles } = useEventForm();
|
||||
|
||||
function saveRoster(teamId: number) {
|
||||
if (startTime.value == undefined) {
|
||||
|
@ -187,6 +187,7 @@ export const useRosterStore = defineStore("roster", () => {
|
|||
name: title.value,
|
||||
description: description.value,
|
||||
startTime: startTime.value.toString(),
|
||||
includePlayersWithoutRoles: includePlayersWithoutRoles.value,
|
||||
playerRoles: Object.values(selectedPlayers).map((player) => ({
|
||||
player: {
|
||||
steamId: player.steamId,
|
||||
|
@ -241,5 +242,6 @@ export const useRosterStore = defineStore("roster", () => {
|
|||
updateRoster,
|
||||
title,
|
||||
description,
|
||||
includePlayersWithoutRoles,
|
||||
}
|
||||
});
|
||||
|
|
|
@ -78,6 +78,7 @@ class CreateEventJson(BaseModel):
|
|||
name: str
|
||||
description: Optional[str]
|
||||
start_time: datetime
|
||||
include_players_without_roles: bool = False
|
||||
player_roles: list[PlayerRoleSchema]
|
||||
|
||||
class UpdateEventJson(BaseModel):
|
||||
|
@ -126,7 +127,10 @@ def create_event(player_team: PlayerTeam, team_id: int, json: CreateEventJson, *
|
|||
tuple_(PlayerTeam.player_id, PlayerTeamRole.role).in_(tuples)
|
||||
).all()
|
||||
|
||||
player_team_ids = []
|
||||
for player_team, role_id, availability in map(lambda x: x.tuple(), results):
|
||||
player_team_ids.append(player_team.player_id)
|
||||
|
||||
player_event = PlayerEvent()
|
||||
player_event.player_id = player_team.player_id
|
||||
player_event.event_id = event.id
|
||||
|
@ -137,6 +141,30 @@ def create_event(player_team: PlayerTeam, team_id: int, json: CreateEventJson, *
|
|||
|
||||
db.session.add(player_event)
|
||||
|
||||
if json.include_players_without_roles:
|
||||
# add players without roles, but with availability
|
||||
|
||||
players_without_roles = db.session.query(
|
||||
PlayerTeam, PlayerTeamAvailability.availability
|
||||
).join(
|
||||
PlayerTeamAvailability,
|
||||
(PlayerTeamAvailability.player_team_id == PlayerTeam.id) &
|
||||
(PlayerTeamAvailability.start_time <= event.start_time) &
|
||||
(PlayerTeamAvailability.end_time > event.start_time)
|
||||
).where(
|
||||
# player_team.player_id NOT IN (ids of processed players)
|
||||
PlayerTeam.player_id.notin_(player_team_ids),
|
||||
PlayerTeam.team_id == team_id
|
||||
).all()
|
||||
|
||||
for player_team, availability in map(lambda x: x.tuple(), players_without_roles):
|
||||
player_event = PlayerEvent()
|
||||
player_event.player_id = player_team.player_id
|
||||
player_event.event_id = event.id
|
||||
# autoconfirm if availability = 2
|
||||
player_event.has_confirmed = (availability == 2)
|
||||
db.session.add(player_event)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
event.update_discord_message()
|
||||
|
|
Loading…
Reference in New Issue