Models

Models that inherit from appier_extras.admin.Base are automatically added to the admin interface. You can find more information about Appier models here.

Attributes

The admin input component for each model attribute is automatically chosen according to the attribute's data type:

Certain interface behaviours change according to other attribute modifiers besides the data type:

Operations

Appier operations are picked up by the admin and made accessible through the interface. Here's an example:

class Cat:

    @classmethod
    @appier.operation(name = "Meow")
    def meow(cls):
        cats = cls.find()
        for cat in cats: cat._meow()

To make the same operation be associated with a single instance, just apply to an instance method instead:

    @appier.operation(name = "Meow")
    def meow(self):
        self._meow()

An operation can receive parameters that will be sent to the handler method:

    @appier.operation(
        name = "Meow",
        parameters = (
            ("Number of meows", "number_meows", int, 5),
        )
    )
    def meow(self, number_meows):
        for x in range(number_meows): self._meow()

Appier links are also picked up by the admin interface. Here's an example:

class Cat

    @classmethod
    @appier.link(name = "Export Cats (CSV)")
    def export_csv(cls):
        return appier.get_app().url_for("cat.list_csv")

In the same way, if the link is just for a particular instance, just use an instance method:

    @appier.link(name = "Export Cat (CSV)")
    def export_csv(self):
        return self.get_app().url_for("cat.show_csv")

Links can receive parameters as well:

    @classmethod
    @appier.link(
        name = "Export Cats (CSV)",
        parameters = (
            ("Start record", "start_record", int, 0),
            ("Number of records", "number_records", int, 10)
        )
    )
    def export_csv(cls, start_record, number_records):
        return appier.get_app().url_for(
            "cat.list_csv",
            start_record = start_record,
            number_records = number_records
        )