125 lines
2.8 KiB
Python
125 lines
2.8 KiB
Python
from datetime import datetime
|
|
|
|
from peewee import (
|
|
SqliteDatabase,
|
|
Model,
|
|
CharField,
|
|
ForeignKeyField,
|
|
DateTimeField,
|
|
SmallIntegerField,
|
|
BooleanField,
|
|
CompositeKey
|
|
)
|
|
|
|
|
|
db = SqliteDatabase(None)
|
|
|
|
|
|
class HamsterCategory(Model):
|
|
name = CharField()
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "categories"
|
|
|
|
|
|
class HamsterActivity(Model):
|
|
name = CharField()
|
|
category = ForeignKeyField(HamsterCategory, backref="activities")
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "activities"
|
|
|
|
|
|
class HamsterFact(Model):
|
|
activity = ForeignKeyField(HamsterActivity, backref="facts")
|
|
start_time = DateTimeField()
|
|
end_time = DateTimeField(null=True)
|
|
description = CharField()
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "facts"
|
|
|
|
|
|
class HamsterTag(Model):
|
|
name = CharField()
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "tags"
|
|
|
|
|
|
|
|
class HamsterFactTag(Model):
|
|
fact = ForeignKeyField(HamsterFact, backref="tags")
|
|
tag = ForeignKeyField(HamsterTag, backref="facts")
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "fact_tags"
|
|
primary_key = CompositeKey('fact', 'tag')
|
|
|
|
|
|
class KimaiCustomer(Model):
|
|
visible = BooleanField(default=True)
|
|
name = CharField()
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "kimai_customers"
|
|
|
|
|
|
class KimaiProject(Model):
|
|
name = CharField()
|
|
customer = ForeignKeyField(KimaiCustomer, backref="projects")
|
|
visible = BooleanField(default=True)
|
|
allow_global_activities = BooleanField(default=True)
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "kimai_projects"
|
|
|
|
|
|
class KimaiActivity(Model):
|
|
name = CharField()
|
|
project = ForeignKeyField(KimaiProject, backref="activities", null=True)
|
|
visible = BooleanField(default=True)
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "kimai_activities"
|
|
|
|
|
|
class KimaiTag(Model):
|
|
name = CharField()
|
|
visible = BooleanField(default=True)
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "kimai_tags"
|
|
|
|
|
|
class HamsterActivityKimaiMapping(Model):
|
|
hamster_activity = ForeignKeyField(HamsterActivity, backref="mappings")
|
|
kimai_customer = ForeignKeyField(KimaiCustomer, backref="mappings")
|
|
kimai_project = ForeignKeyField(KimaiProject, backref="mappings")
|
|
kimai_activity = ForeignKeyField(KimaiActivity, backref="mappings")
|
|
kimai_description = CharField()
|
|
kimai_tags = CharField()
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "hamster_kimai_mappings"
|
|
|
|
|
|
class HamsterFactKimaiImport(Model):
|
|
hamster_fact = ForeignKeyField(HamsterFact, backref="imports")
|
|
kimai_id = SmallIntegerField()
|
|
imported = DateTimeField(default=datetime.now)
|
|
|
|
class Meta:
|
|
database = db
|
|
table_name = "hamster_fact_kimai_imports"
|