Пример #1
0
    def persist(self,reportd,mail_message):
            boats = Boat.all()
            boats.filter("passcode = ", reportd['passcode'])
            boats.filter("active =", True)

            emaillog=EmailLog()
            emaillog.rawemail=db.Text(mail_message.original.as_string())

            #TODO: I don't like this way of figuring out if we got any rows
            count=0
            for boat in boats:
                if (boat.key().name()==string.upper(reportd['boat'])):
                    count=count+1
                    break # Return the first one
                else:
                    boat=None

            if (count <1 or boats == None or boat == None):
                logging.error("Unable to persist report could not find boat "+string.upper(reportd['boat'])+":"+reportd['passcode'])
            else:
                report=Report(parent=boat)
                report.lat=reportd['lat']
                report.lon=reportd['lon']
                payload={
                         'comment' : reportd['comment']
                        }
                report.setPayload(payload)
                report.put()
                emaillog.report_ref=report
                reportd['time']=strftime("%Y/%m/%d %H:%M", gmtime())
                self.outbound(boat,reportd)

            emaillog.put()
Пример #2
0
    def map(self):
        track=[]
        marker=None
        boatid=string.upper(self.request.get('boat'))
        showmarkers=string.upper(self.request.get('markers'))
        showinfo=string.upper(self.request.get('popup'))
        zoom=self.request.get('zoom')
        #TODO: Validate input
        if (zoom==''):
            zoom=6
        if (showmarkers==''):
            showmarkers='true'
        if (showinfo==''):
            showinfo='false'
        boats=Boat.all()
        # TODO: Is there a better way to filter this? We can't use key_name because we don't know ancestor
        for boat in boats:
            logging.error(boat.key().name() + " vs " + boatid)
            if (boat.key().name()!=boatid):
                boat=None;
            else:
                break
        if (boats != None and boat!=None):
            reports=Report.all()
            reports.ancestor(boat)
            reports.order("created")
            for report in reports:
                #logging.error(report.payload)
                entry={}
                entry['date']=report.created.strftime("%Y-%m-%d %H:%M:%S")
                entry['lat']='%.2f' % (report.lat)
                entry['lon']='%.2f' % (report.lon)
                entry['boat']=boat.key().name()
                comment=''
                if (report.payload!=None and report.payload!=''):
                    comment=report.getPayload()['comment']
                entry['comment']=comment
                track.append(entry)
                marker=entry # This is the last one

        values={}
        values['marker']=marker
        values['track']=track
        values['zoom']=zoom
        values['showmarkers']=string.lower(showmarkers)
        values['showinfo']=string.lower(showinfo)
        return self.render('map',values)
Пример #3
0
    def list(self):
        values = {}
        boats = Boat.all()
        boats.ancestor(self.dbuser)
        boats.filter("active =", True)
        boats.order("created")

        list = []
        count = 0
        for boat in boats:
            count = count + 1
            logging.info(boat.payload)
            tmp = {
                "id": boat.key().name(),
                "name": boat.boat_name,
                "passcode": boat.passcode,
                "payload": boat.getPayload(),
            }
            list.append(tmp)

        values["count"] = count
        values["boats"] = list

        return self.render("list", values)