def edit(self, view: InertiaResponse): org = Organization.find(self.request.param('organization')) # TODO: not working yet # organization = org.with_('contacts').get().serialize() organization = {**org.serialize(), "contacts": []} return view.render("Organizations/Edit", {"organization": organization})
def index(self, view: InertiaResponse): # TODO: not possible for now # users = Account.users_of_account(self.request.user().account.id) # users = self.request.user().account.users().order_by_name().filter( # self.request.only('search', 'role', 'trashed') # ).get() # TODO: not possible for now # users = self.request.user().account.users # users.set_appends(['name']) # TODO: not possible for now # users = User.where("account_id", self.request.user().account.id).get() # users.set_appends(['name']) users = self.request.user().account.users return view.render( 'Users/Index', { 'filters': self.request.all(internal_variables=False), 'users': users.serialize() # 'users': users.transform(lambda user: { # 'id': user.id, # 'email': user.email, # 'name': user.last_name + ' ' + user.first_name, # 'owner': user.owner, # 'photo': '#', # 'deleted_at': user.deleted_at # }).serialize() })
def edit(self, view: InertiaResponse): contact = Contact.find(self.request.param('contact')) # TODO: not working yet # contact = contact.with_('organizations').get().serialize() return view.render("Contacts/Edit", { "contact": contact.serialize(), "organizations": [] })
def index(self, view: InertiaResponse): # TODO: does not work yet # contacts = self.request.user().account.contacts().order_by_name().filter( # self.request.only('search', 'role', 'trashed') # ).get() # TODO: add pagination contacts = self.request.user().account.contacts return view.render( 'Contacts/Index', { 'filters': self.request.all(internal_variables=False), 'contacts': { "data": contacts.serialize(), "links": [] } })
def edit(self, view: InertiaResponse): def lazy_prop(): return "6" user = User.find(self.request.param("user")) return view.render( 'Users/Edit', { 'user': { 'id': user.id, 'first_name': user.first_name, 'last_name': user.last_name, 'email': user.email, 'owner': user.owner, 'photo': '#', # TODO: user.photoUrl(['w' => 60, 'h' => 60, 'fit' => 'crop']), 'deleted_at': user.deleted_at, }, 'other_one': lazy_prop })
def index(self, view: InertiaResponse): organizations = self.request.user().account.organizations # TODO add pagination return view.render( 'Organizations/Index', { 'filters': self.request.all(internal_variables=False), 'organizations': { 'data': organizations.serialize(), 'links': [] } # 'organizations': organizations.transform(lambda org: { # 'id': org.id, # 'name': org.name, # 'phone': org.phone, # 'city': org.city, # 'deleted_at': org.deleted_at # }).serialize() })
def create(self, view: InertiaResponse): return view.render('Users/Create')
def hello(self, view: InertiaResponse): return view.render("Hello", {"first_name": "Sam"}, custom_root_view="inertia_demo.html")
def lazy_view_with_request(self, view: InertiaResponse): def is_authenticated(request): return request.user() return view.render("Index", {"is_authenticated": is_authenticated})
def store(self, view: InertiaResponse): # TODO: implement self.request.session.flash('success', 'Contact created.') return view.redirect_to('contacts')
def create(self, view: InertiaResponse): return view.render('Organizations/Create')
def index(self, view: InertiaResponse): return view.render('Dashboard/Index')
def external(self, view: InertiaResponse): return view.location("https://inertiajs.com")
def inertia(self, view: InertiaResponse): def lazy_prop(): return "6" return view.render("Index", {"user": "******", "lazy": lazy_prop})
def show(self, view: InertiaResponse): return view.render("Index", custom_root_view="inertia_demo.html")
def create(self, view: InertiaResponse): return view.render('Contacts/Create')
def inertia(self, view: InertiaResponse): return view.render("Index")
def helloworld(self, view: InertiaResponse): return view.render("HelloWorld", {"first_name": "Sam"})
def lazy_view(self, view: InertiaResponse): def get_count(): return 2 return view.render("Index", {"count": get_count})
def show_login_form(self, view: InertiaResponse): return view.render("Auth/Login")
def custom_id(self, view: InertiaResponse): return view.render("Index", custom_root_view="test_custom_id")
def index(self, view: InertiaResponse): return view.render("Reports/Index")