def get_context_data(self, *args, **kwargs): context = super(AppMixin, self).get_context_data(*args, **kwargs) app_name = kwargs['app_name'] context['app'] = self.get_app(app_name) context['tabs'] = engine.get('app').tabs return context
def get(self, request, *args, **kwargs): app_name = kwargs['app_name'] page = int(request.GET.get('page', '1')) skip = (page * 20) - 20 limit = page * 20 url = '{}/deploys?app={}&skip={}&limit={}'.format( settings.TSURU_HOST, app_name, skip, limit) response = requests.get(url, headers=self.authorization) deploys = [] if response.status_code != 204: deploys = response.json() or [] context = {} context['deploys'] = deploys context['app'] = self.get_app(app_name) context['tabs'] = engine.get('app').tabs if len(deploys) >= 20: context['next'] = page + 1 if page > 0: context['previous'] = page - 1 return TemplateResponse(request, self.template, context=context)
from tsuru_dashboard import engine class AutoScaleTab(engine.Tab): name = 'autoscale' url_name = 'autoscale-app-info' try: engine.get('app').register_tab(AutoScaleTab) except engine.AppNotFound: pass