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