'Company' object in Indico

Is there a Company object in Indico? If not, what’s the easiest way to extend the Model to include that object? I now know how to ‘extend’ the Indico Model inside a Plugin, but wasn’t sure if there was a ‘cleaner’ way to extend the current Model, without having to create (an empty?) Plugin.


That question is impossible to answer without knowing what that “Company” object would do…

But making a wild guess, it sounds like the “affiliation” field each user has.

Company will contain a ‘Company/Firm’ name, address, email, phone, etc. Almost identical to User, in terms of the type definition, but I want it to be a separate type (Affiliation seems to not be a separate type, but rather a property of User)

So basically extra information attached to a user?

Yes, but one that exist in a separate Table in the DB (separate type that inherits from db.Model in the Model)

So you want to have a list of companies and each user can be associated with a company (without duplicating the data about the company)?

If yes, then a plugin is the way to go. Add a new model, with a relationship to User. You can also add a new user profile page to the user settings menu using a single to have a place where this can be edited (either by the user themselves or only by admins).

All of the above goes inside the Plugin, correct?

Yes, you shouldn’t need to modify the core for this (except maybe adding additional signals / template hooks if necessary, and those could be contributed back upstream via a pull request)

Got it. So to recap - if I only want to create the bare bones model, I just create an “empty” Plugin with only the Model folder (and the rest of the absolute minimum) stuff in it, correct?

Yes, you create the usual plugin package structure, and a models package inside your plugin’s package.

Your model needs to have __table_args__ = {'schema': 'plugin_YOURPLUGINNAME'} and you then generate an alembic revision file with indico db --plugin YOURPLUGINNAME migrate which creates your schema and table.

Got it. Thanks a bunch @ThiefMaster. Have a great weekend!