'Add an app to this collection, as a member of the passed `group`.
If specified, the app will be created with the specified `order`. If
not, it will be added to the end of the collection.'

def add_app_grouped(self, app, group, order=None):

    qs = self.membership_class.objects.filter(obj=self)
    if (order is None):
        aggregate = qs.aggregate(models.Max('order'))['order__max']
        order = ((aggregate + 1) if (aggregate is not None) else 0)
    rval = self.membership_class.objects.create(obj_id=self.id, app_id=app, group=group, order=order)
    index_webapps.delay([app])
    return rval
