feat(kaisertisch): implement Kaisertisch tournament functionality with model, routes, and controller
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 57s

This commit is contained in:
Torsten Schulz (local)
2026-08-19 14:02:12 +02:00
parent d251d40868
commit 18ba120927
7 changed files with 191 additions and 27 deletions

View File

@@ -0,0 +1,18 @@
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Club from './Club.js';
import DiaryDate from './DiaryDates.js';
const KaisertischTournament = sequelize.define('KaisertischTournament', {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
clubId: { type: DataTypes.INTEGER, allowNull: false, field: 'club_id', references: { model: Club, key: 'id' }, onDelete: 'CASCADE' },
diaryDateId: { type: DataTypes.INTEGER, allowNull: false, field: 'diary_date_id', references: { model: DiaryDate, key: 'id' }, onDelete: 'CASCADE' },
state: { type: DataTypes.JSON, allowNull: false },
}, {
tableName: 'kaisertisch_tournaments',
underscored: true,
timestamps: true,
indexes: [{ unique: true, fields: ['club_id', 'diary_date_id'] }],
});
export default KaisertischTournament;

View File

@@ -98,6 +98,7 @@ import MemberProfileChangeRequest from './MemberProfileChangeRequest.js';
import MemberEventResponse from './MemberEventResponse.js';
import NotificationEvent from './NotificationEvent.js';
import NotificationRecipient from './NotificationRecipient.js';
import KaisertischTournament from './KaisertischTournament.js';
import TournamentSuggestion from './TournamentSuggestion.js';
// Official tournaments relations
OfficialTournament.hasMany(OfficialCompetition, { foreignKey: 'tournamentId', as: 'competitions' });
@@ -131,6 +132,10 @@ TournamentSuggestion.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
DiaryDate.belongsTo(Club, { foreignKey: 'clubId' });
Club.hasMany(DiaryDate, { foreignKey: 'clubId' });
DiaryDate.hasOne(KaisertischTournament, { foreignKey: 'diaryDateId', as: 'kaisertischTournament' });
KaisertischTournament.belongsTo(DiaryDate, { foreignKey: 'diaryDateId', as: 'diaryDate' });
Club.hasMany(KaisertischTournament, { foreignKey: 'clubId', as: 'kaisertischTournaments' });
KaisertischTournament.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
DiaryDate.belongsToMany(Member, { through: Participant, as: 'participants', foreignKey: 'diaryDateId' });
Member.belongsToMany(DiaryDate, { through: Participant, as: 'diaryDates', foreignKey: 'memberId' });
@@ -726,6 +731,7 @@ export {
MemberEventResponse,
NotificationEvent,
NotificationRecipient,
KaisertischTournament,
TournamentSuggestion,
ClubDistributionGroupMember,
};