Skip to content

Refactor and abstract out entity classes #57

@Olen

Description

@Olen

Just an idea for now, please give some feedback.

I have been thinking about some refactoring where we create new classes for e.g. SpondEvent, SpondPerson, SpondGroup. SpondMessage etc.

It would allow us to keep a stable API even if Spond should change stuff, and do more things in a more consistent way.

Something along the lines of

event = SpondEvent()
event.begin = "2023-01-30 13:00:00"
event.end = "2023-01-30 17:00:00"
event.name = "Race"
event.location = SpondLocation(address="Foo Street 123")
event.save()

After saving the event, the object is populated with an event.id.

You can change it later:

event = SpondEvent(event_id)
event.begin = "2023-01-27 14:00:00"
event.save()

There should also be some validations done (start < end etc) before saving.

And similar for persons, messages etc.

person = SpondPerson(person_id)
print(person.first_name)

It also allows for creating shortcuts for things like

class SpondPerson():
    ...
    @property
    def name(self):
        return f"{self.first_name} {self.last_name}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions