backend.models

SQLAlchemy ORM models for libreStage.

Defines all database tables as Python classes. Every model that maps to a table inherits from Base.

Helper:

time_to_str() – converts datetime.time / datetime.date objects to ISO strings for serialisation.

backend.models.time_to_str(t)[Quellcode]
class backend.models.User(**kwargs)[Quellcode]

Bases: Base

Registered application user.

id

Primary key.

Type:

int

user_name

Unique login name.

Type:

str

user_pw

bcrypt password hash.

Type:

str

user_group

Role – admin, editor or user.

Type:

str

email

E-mail address.

Type:

str

clear_name

Display name.

Type:

str

musician

Whether the user is a band member.

Type:

bool

is_singer

Whether the user is a singer.

Type:

bool

mm_username

Optional Mattermost username.

Type:

str

id
user_name
user_pw
user_group
email
clear_name
musician
is_singer
mm_username
status
class backend.models.UsedPasswordResetToken(**kwargs)[Quellcode]

Bases: Base

Record of password-reset tokens that have already been consumed.

id

Primary key.

Type:

int

token_hash

SHA-256 hash of the used token.

Type:

str

used_at

Timestamp when the token was used.

Type:

datetime

id
token_hash
used_at
class backend.models.RefreshToken(**kwargs)[Quellcode]

Bases: Base

Persistent refresh token linked to a user.

id

Primary key.

Type:

int

token_hash

SHA-256 hash of the raw token.

Type:

str

user_id

Foreign key to User.

Type:

int

expires_at

Expiry timestamp (UTC).

Type:

datetime

created_at

Creation timestamp (UTC).

Type:

datetime

revoked

True if the token has been invalidated.

Type:

bool

user

Relationship to the owning user.

Type:

User

id
token_hash
user_id
expires_at
created_at
revoked
user
class backend.models.TokenBlacklist(**kwargs)[Quellcode]

Bases: Base

Blacklisted access tokens (e.g. after explicit logout).

id

Primary key.

Type:

int

token_hash

SHA-256 hash of the blacklisted JWT.

Type:

str

blacklisted_at

Timestamp of blacklisting (UTC).

Type:

datetime

expires_at

Original token expiry – used for cleanup.

Type:

datetime

id
token_hash
blacklisted_at
expires_at
class backend.models.RehTodo(**kwargs)[Quellcode]

Bases: Base

A to-do item assigned to a specific user for a song in a rehearsal.

id

Primary key.

Type:

int

id_song

Foreign key to Song.

Type:

int

id_reh

Foreign key to RehSong (rehearsal).

Type:

int

id_user

Foreign key to User.

Type:

int

todo

Description of the task.

Type:

str

dt

Optional due date/time.

Type:

datetime | None

done

Whether the task has been completed.

Type:

bool

id
id_song
id_reh
id_user
todo
dt
done
class backend.models.RehSong(**kwargs)[Quellcode]

Bases: Base

Association between a Rehearsal and a Song.

Stores per-song rehearsal metadata (comment, to-do text, done flag) and exposes several hybrid properties that proxy attributes of the related Song.

id

Primary key.

Type:

int

id_rehearsal

Foreign key to Rehearsal.

Type:

int

id_song

Foreign key to Song.

Type:

int

comment

Free-text comment for this rehearsal slot.

Type:

str | None

todo

Short to-do description.

Type:

str | None

done

Whether the rehearsal slot is marked as done.

Type:

bool | None

rehearsal

Owning rehearsal.

Type:

Rehearsal

song

The rehearsed song.

Type:

Song

todos

Individual to-do items for this slot.

Type:

list[RehTodo]

id
id_rehearsal
id_song
comment
todo
done
title
interpret
status
setlist_comment
song_todos
rehearsal
song
todos
class backend.models.Rehearsal(**kwargs)[Quellcode]

Bases: Base

A single band rehearsal session.

id

Primary key.

Type:

int

comment

Free-text notes about the rehearsal.

Type:

str

begin

Start time.

Type:

datetime

end

End time.

Type:

datetime

ical

iCal UID or event string.

Type:

str

songs

Songs scheduled for this rehearsal.

Type:

list[RehSong]

id: Mapped[int]
comment: Mapped[str]
begin: Mapped[datetime]
end: Mapped[datetime]
ical: Mapped[str]
songs
class backend.models.Gig(**kwargs)[Quellcode]

Bases: Base

A band performance (gig / concert).

id

Primary key.

Type:

int

name

Display name of the gig.

Type:

str

datum

Performance date.

Type:

date

organizer

Name of the organiser.

Type:

str | None

kind_of_gig

Type, e.g. Schützenfest.

Type:

str | None

venue

Location name.

Type:

str | None

doors

Doors-open time.

Type:

time | None

begin

Start time of the performance.

Type:

time | None

end

End time of the performance.

Type:

time | None

status

Workflow status.

Type:

str | None

publish

Whether the gig is published publicly.

Type:

str | None

sets

Ordered set list for this gig.

Type:

list[GigSet]

id
name
datum: Mapped[date]
organizer
kind_of_gig
venue
doors
begin
end
status
publish
sets: Mapped[list[GigSet]]
schedule_items: Mapped[list[GigScheduleItem]]
debug_dump(schedule=None)[Quellcode]

Print a human-readable overview of the gig structure to stdout.

Parameter:

schedule (dict | None) – Optional timing schedule as returned by services.setlist.SetlistService.calc_schedule().

to_dict(include_song_details=True)[Quellcode]

Serialise the gig and its full set list to a plain dictionary.

Parameter:

include_song_details (bool) – Reserved for future use; currently always includes song details.

Rückgabe:

A JSON-serialisable representation of the gig including all sets and songs.

Rückgabetyp:

dict

class backend.models.Song(**kwargs)[Quellcode]

Bases: Base

A song in the band’s repertoire.

id

Primary key.

Type:

int

title

Song title.

Type:

str

interpret

Artist / band name.

Type:

str

genre

Musical genre.

Type:

str | None

singer_background

Background singer(s).

Type:

str | None

singer_lead

Lead singer.

Type:

str | None

composer

Composer name(s).

Type:

str | None

texter

Lyricist name(s).

Type:

str | None

publisher

Publisher.

Type:

str | None

arrangement

Arranger.

Type:

str | None

text

Full lyrics.

Type:

str | None

tone_key

Musical key, e.g. Bb.

Type:

str | None

status

Workflow status (e.g. angenommen).

Type:

str | None

comment

Internal notes.

Type:

str | None

YouTube link.

Type:

str | None

duration

Song duration.

Type:

time | None

brass

Brass instrument flag.

Type:

int | None

Rehearsal associations.

Type:

list[RehSong]

feedbacks

Candidate feedback entries.

Type:

list[SongCandidateFeedback]

id
title
interpret
genre
singer_background
singer_lead
composer
texter
publisher
arrangement
text
tone_key
status
comment
ytlink
duration
brass
rehearsal_links
feedbacks
to_setlist_dict()[Quellcode]

Serialise the song to a dictionary suitable for setlist display.

Rückgabe:

Song fields used in setlist views (title, interpret, genre, singers, duration, brass, tone_key, status, comment).

Rückgabetyp:

dict

to_setlist_element()[Quellcode]

Like to_setlist_dict() but adds song_id and a placeholder setsong_id of -1.

Rückgabe:

Extended setlist dictionary with song_id and setsong_id.

Rückgabetyp:

dict

class backend.models.SongCandidateFeedback(**kwargs)[Quellcode]

Bases: Base

User feedback on a song candidate (proposal).

id

Primary key.

Type:

int

song_id

Foreign key to Song.

Type:

int

user_id

Foreign key to User.

Type:

int

date

Timestamp of the feedback.

Type:

datetime

feedback

Feedback text.

Type:

str

song

The song this feedback belongs to.

Type:

Song

id
song_id
user_id
date
feedback
song
class backend.models.Set(**kwargs)[Quellcode]

Bases: Base

A named set of songs within a gig.

id

Primary key.

Type:

int

name

Internal set name.

Type:

str

pause

Duration of the break after this set (default 10 min).

Type:

time

setlist_name

Optional public-facing name shown on printed setlists.

Type:

str | None

Associations to gigs.

Type:

list[GigSet]

songs

Ordered songs in this set.

Type:

list[SetSong]

id: Mapped[int]
name: Mapped[str]
pause: Mapped[time]
setlist_name: Mapped[str | None]
gig_links: Mapped[list[GigSet]]
songs: Mapped[list[SetSong]]
to_setlist_dict()[Quellcode]

Minimal serialisation of the set (currently only id).

Rückgabe:

{"id": self.id}

Rückgabetyp:

dict

class backend.models.SetSong(**kwargs)[Quellcode]

Bases: Base

Association between a Set and a Song, including position and live-mode state.

id

Primary key.

Type:

int

id_set

Foreign key to Set.

Type:

int

id_song

Foreign key to Song.

Type:

int

position

1-based position of the song within the set.

Type:

int

eingeschoben

Marked as inserted ad-hoc during live mode.

Type:

bool | None

uebersprungen

Marked as skipped during live mode.

Type:

bool | None

feedback

Post-performance rating (1–3).

Type:

int | None

song

The associated song.

Type:

Song

set

The owning set.

Type:

Set

id: Mapped[int]
id_set: Mapped[int]
id_song: Mapped[int]
position: Mapped[int]
eingeschoben: Mapped[bool | None]
uebersprungen: Mapped[bool | None]
feedback: Mapped[int | None]
song: Mapped[Song]
set: Mapped[Set]
to_setlist_dict()[Quellcode]

Serialise the set–song association for setlist views.

Returns a fallback entry with a warning title if the linked song has been deleted.

Rückgabe:

Song fields plus song_id, setsong_id, position, eingeschoben, uebersprungen and feedback.

Rückgabetyp:

dict

class backend.models.GigSet(**kwargs)[Quellcode]

Bases: Base

Ordered association between a Gig and a Set.

id

Primary key.

Type:

int

id_gig

Foreign key to Gig.

Type:

int

id_set

Foreign key to Set.

Type:

int

position

1-based display order within the gig.

Type:

int

gig

The owning gig.

Type:

Gig

set

The associated set.

Type:

Set

id: Mapped[int]
id_gig: Mapped[int]
id_set: Mapped[int]
position: Mapped[int]
gig: Mapped[Gig]
set: Mapped[Set]
class backend.models.GigScheduleItem(**kwargs)[Quellcode]

Bases: Base

Additional freely editable timeline items for a gig.

id
gig_id
item_datetime
was
wer
wo
gig: Mapped[Gig]
class backend.models.Surveys(**kwargs)[Quellcode]

Bases: Base

A feedback survey created by an admin or editor.

id

Primary key.

Type:

int

kind_of_survey

Survey category / type label.

Type:

str

rf_survey

Request-for-feedback description.

Type:

str

released

Whether the survey is visible to members.

Type:

bool

closed

Whether the survey is closed for new responses.

Type:

bool

user_created

Foreign key to the creating User.

Type:

int

release_date

Date/time the survey was released.

Type:

datetime

datum

Creation date.

Type:

datetime

fields

Individual questions / fields.

Type:

list[SurveyFields]

id
kind_of_survey
rf_survey
released
closed
user_created
release_date
fields
datum
class backend.models.SurveyFields(**kwargs)[Quellcode]

Bases: Base

A single question or rating field within a Surveys.

id

Primary key.

Type:

int

id_survey

Foreign key to Surveys.

Type:

int

field_text

The question or label text.

Type:

str

feedbacks

Responses to this field.

Type:

list[SurveyFeedback]

id
id_survey
field_text
feedbacks
class backend.models.SurveyFeedback(**kwargs)[Quellcode]

Bases: Base

A user’s response to a single SurveyFields entry.

id

Primary key.

Type:

int

id_sv_field

Foreign key to SurveyFields.

Type:

int

id_user

Foreign key to User.

Type:

int

datum

Timestamp of the response.

Type:

datetime

value

The submitted value (e.g. a rating string).

Type:

str

comment

Optional free-text comment.

Type:

str | None

id
id_sv_field
id_user
datum
value
comment