def get(self): self.context['message'] = 'Hello, World!' if self.request.args.has_key('key') and\ self.request.args.has_key('remove'): key = self.request.args.get('key') obj = SiteMonitor.getByID(key) obj.delete() return redirect('/sites') elif self.request.args.has_key('key'): key = self.request.args.get('key') obj = SiteMonitor.getByID(key) MyForm = model_form(SiteMonitor, SiteMonitorForm) form = MyForm(self.request.form, obj) self.context['form'] = form else: self.context['form'] = SiteMonitorForm() return self.render_response('views/manage_sites.html', **self.context)
def get(self): sites = SiteMonitor.getAll() log = [] for site in sites: if site.flagAtivo: result = self.checaSite(site.link, site.textCheck) lastStatus = Log.getLastLogSite(site.key()) nowStatus = result.get('status',False) if nowStatus != lastStatus: self.sendMail(site.link, site.name, result.get('status',False)) # elif not nowStatus: # self.sendMail(site.link, site.name, result.get('status',False)) log.append(result) save = Log(site_monitor = site.key(), date_creation = datetime.now(), status = result.get('status',False), time_access = result.get('time_access'), speed_access = result.get('speed_access')) save.put() return Response(log)
def post(self, **kwargs): """To process a form, we validate it, authenticate the User and pass the form instance to the template. """ #http://flask.pocoo.org/snippets/60/ if self.request.form.has_key('registre') and\ self.request.args.has_key('key'): key = self.request.args.get('key') obj = SiteMonitor.getByID(key) # Validate the form. if self.form.validate(): obj.name = self.form.name.data obj.link = self.form.link.data obj.textCheck = self.form.textCheck.data obj.date_creation = datetime.now() obj.flagAtivo = self.form.flagAtivo.data obj.put() return redirect('/sites') if self.request.form.has_key('registre'): self.context['form'] = self.form #SiteMonitorForm() self.context['errors_loginform_add'] = '' # Validate the form. if self.form.validate(): # Form is valid. Use the form data and redirect the user to the # final destination. record = SiteMonitor(name = self.form.name.data, link = self.form.link.data, textCheck = self.form.textCheck.data, date_creation = datetime.now(), flagAtivo = self.form.flagAtivo.data) record.put() return redirect('/sites') # Since the form didn't validate, render it again using self.get(). return self.render_response('views/manage_sites.html', **self.context)
def get(self): self.context['message'] = 'Historico / Graficos' self.context['resources'].css.append('start/jquery-ui-1.8.21.custom.css') for i in ['ajax-grafic.js','jquery-ui-1.8.21.custom.min.js','jquery.ui.datepicker-pt-BR.js']: self.context['resources'].js.append(i) #JSCharts #self.context['resources'].css.append('jscharts.js') #Outro grafico for i in ['highcharts.js','modules/exporting.js']: self.context['resources'].js.append(i) self.context['sites'] = SiteMonitor.getAll() startDate = date.today() - timedelta(days=1) self.context['start_date'] = startDate.strftime('%d/%m/%Y') self.context['end_date'] = date.today().strftime('%d/%m/%Y') return self.render_response('historygraphic.html', **self.context)
def get(self): self.context["message"] = "Monitoramento de Sites" self.context["sites"] = SiteMonitor.getAll() return self.render_response("homepage.html", **self.context)
def get(self): self.context['data'] = SiteMonitor.getAll() return self.render_response('views/list_sites.html', **self.context)