Exemple #1
0
    def get(self):
        usr = users.get_current_user()

        if usr:
            url_usr = users.create_logout_url("/")
            lines = Line.query(Line.email == usr.email())
            linesOthers = Line.query(Line.email != usr.email())
            quotes = []

            for l in lines:
                quotes.append(l.line.lower())

            linesNew = []

            for line in linesOthers:
                if line.line.lower() not in quotes:
                    linesNew.append(line)

        else:
            url_usr = users.create_login_url("/")
            linesNew = []

        print(linesNew)
        values_template = {"lines": linesNew, "usr": usr, "url_usr": url_usr}

        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(
            jinja.render_template("list.html", **values_template))
Exemple #2
0
def no_upcoming():
    top = Line("A", Direction(TOP_NORTH_NAME, []),
               Direction(TOP_SOUTH_NAME, []), [])
    bottom = Line("C", Direction(BOTTOM_NORTH_NAME, []),
                  Direction(BOTTOM_SOUTH_NAME, []), [])

    drawing.create_image(top, bottom, "test/output/no_upcoming.png")
Exemple #3
0
def no_upcoming_alerts():
    top = Line("A", Direction(TOP_NORTH_NAME,
                              []), Direction(TOP_SOUTH_NAME, []),
               ["Broken Elevator", "Station Improvements"])
    bottom = Line("C", Direction(BOTTOM_NORTH_NAME, []),
                  Direction(BOTTOM_SOUTH_NAME, []),
                  ["Delays", "Weekend Service"])

    drawing.create_image(top, bottom, "test/output/no_upcoming_alerts.png")
Exemple #4
0
    def get(self):
        usr = users.get_current_user()
        line = Line.get(self.request)

        if usr:
            lineLike = Line(title=line.title, artist=line.artist, line=line.line, email=usr.email())
            lineLike.put()
            time.sleep(1)
            return self.redirect("/lines/list")

        else:
            return self.redirect("/")
Exemple #5
0
def many_upcoming():
    top = Line(
        "A",
        Direction(TOP_NORTH_NAME, [now + 90, now + 120, now + 180, now + 280]),
        Direction(TOP_SOUTH_NAME, [now + 90, now + 120, now + 180]), [])
    bottom = Line(
        "C",
        Direction(BOTTOM_NORTH_NAME,
                  [now + 90, now + 120, now + 180, now + 280]),
        Direction(BOTTOM_SOUTH_NAME, [now + 90, now + 120, now + 180]), [])

    drawing.create_image(top, bottom, "test/output/many_upcoming.png")
Exemple #6
0
def many_upcoming_alerts():
    top = Line(
        "A",
        Direction(TOP_NORTH_NAME, [now + 90, now + 120, now + 180, now + 280]),
        Direction(TOP_SOUTH_NAME, [now + 90, now + 120, now + 180]),
        ["Broken Elevator", "Station Improvements"])
    bottom = Line(
        "C",
        Direction(BOTTOM_NORTH_NAME,
                  [now + 90, now + 120, now + 180, now + 280]),
        Direction(BOTTOM_SOUTH_NAME, [now + 90, now + 120, now + 180]), [])

    drawing.create_image(top, bottom, "test/output/many_upcoming_alerts.png")
Exemple #7
0
def build_line_from_config(line_config: Dict, arrival_times):
    return Line(
        line_config["name"],
        Direction(line_config["uptown_name"], arrival_times[line_config["stop_id"] + "N"].arrival_times),
        Direction(line_config["downtown_name"], arrival_times[line_config["stop_id"] + "S"].arrival_times),
        alerts.get_alerts_for_line(line_config["name"])
    )
Exemple #8
0
    def get(self):
        usr = users.get_current_user()
        line = Line.get(self.request)
        if usr:
            line.key.delete()
            time.sleep(1)
            return self.redirect("/")

        else:
            return self.redirect("/")
Exemple #9
0
    def post(self):
        usr = users.get_current_user()

        if usr:

            title = self.request.get("edTitle", "")
            artist = self.request.get("edArtist", "")
            line = self.request.get("edLine","")


            if not(title) or not(artist) or not(line):
                return self.redirect("/")
            else:
                line = Line(title=title, artist=artist, line=line, email=usr.email())
                line.put()
                time.sleep(1)
                return self.redirect("/")

        else:
            return self.redirect("/")
Exemple #10
0
class Star(Point):
    x: int
    y: int
    line: Line

    def __init__(self, x: int, y: int, length: int, width: int):
        Point.__init__(self, x, y, 5)

        self.x = x
        self.y = y
        self.line = Line(length, width)

    def dictionary(self):
        return {"x": self.x, "y": self.y, "line": self.line.dictionary()}
Exemple #11
0
    def get(self):
        usr = users.get_current_user()

        if usr:
            url_usr = users.create_logout_url("/")
            lines = Line.query(Line.email == usr.email())
        else:
            url_usr = users.create_login_url("/")
            lines = []

        values_template= {
            "lines" : lines,
            "usr": usr,
            "url_usr": url_usr
        }

        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(jinja.render_template("index.html", **values_template))
Exemple #12
0
    def parse(self):
        for sale in self.sales['orders']:
            self.sale = Sale(self.db)
            self.line = Line(self.db)
            self.payment = Payment(self.db)
            self.address = Address(self.db)
            self.transaction = Transaction(self.db)

            order_id = sale['orderId'].split('!')[0]
            self.sale.setOrderId(order_id)
            self.line.setOrderId(order_id)
            self.address.setOrderId(order_id)
            self.sale.setLastUpdated(sale['lastModifiedDate'])

            if self.syncNeeded():
                self.sale.setLegacyOrderId(sale['legacyOrderId'])
                self.sale.setSaleDate(sale['creationDate'])
                self.sale.setBuyerUsername(sale['buyer']['username'])
                self.sale.setStatus(sale['orderAddressStatus'])
                self.sale.add()

                self.fee = Fee(self.db)
                self.fee.setOrderId(order_id)
                self.fee.setFinalValueFee(sale['totalMarketplaceFee']['value'])
                self.fee.addEbayFee()

                for line_items in sale['lineItems']:
                    self.line_item_id = line_items['lineItemId']
                    self.line.setItemId(line_items['legacyItemId'])
                    self.line.setLineItemId(self.line_item_id)
                    self.line.setTitle(line_items['title'])
                    self.line.setSaleFormat(line_items['soldFormat'])
                    self.line.setQuantity(line_items['quantity'])
                    self.line.setAddressStatus(
                        line_items['lineItemAddressStatus'])
                    self.line.add()

                    self.payment.setLineItemId(self.line_item_id)
                    self.payment.setCurrency(
                        line_items['lineItemCost']['convertedFromCurrency'])
                    self.payment.setItemCost(
                        line_items['lineItemCost']['convertedFromValue'])
                    self.payment.setPostageCost(
                        line_items['deliveryCost']['shippingCost']
                        ['convertedFromValue'])

                for payment in sale['paymentSummary']['payments']:
                    self.transaction.setProcessorName(payment['paymentMethod'])
                    self.transaction.setProcessorId(
                        sale['salesRecordReference'])
                    self.transaction.setTransactionDate(payment['paymentDate'])
                    self.transaction.setUpdateDate(payment['paymentDate'])
                    self.transaction.setTransactionAmount(
                        sale['pricingSummary']['total']['value'])
                    self.transaction.setTransactionCurrency(
                        sale['pricingSummary']['total']['currency'])
                    self.transaction.setFeeAmount(0)
                    self.transaction.setFeeCurrency(
                        sale['pricingSummary']['total']['currency'])
                    self.transaction.setTransactionStatus('S')

                    if not self.transaction.alreadyExists():
                        transaction_id = self.transaction.add()

                    self.payment.setPaymentDate(payment['paymentDate'])
                    self.payment.setPaymentStatus(payment['paymentStatus'])
                    self.payment.setTransactionId(transaction_id)
                    self.payment.add()

                for shipping in sale['AddressStartInstructions']:
                    ship_to = shipping['shippingStep']['shipTo']
                    self.address.setBuyerName(ship_to['fullName'])
                    self.address.setAddressLine1(
                        ship_to['contactAddress']['addressLine1'])
                    self.address.setCity(ship_to['contactAddress']['city'])

                    try:
                        self.address.setCounty(
                            ship_to['contactAddress']['stateOrProvince'])
                    except KeyError:
                        self.address.setCounty("")

                    self.address.setPostCode(
                        ship_to['contactAddress']['postalCode'])
                    self.address.setCountryCode(
                        ship_to['contactAddress']['countryCode'])
                    self.address.add()
Exemple #13
0
    def __init__(self, x: int, y: int, length: int, width: int):
        Point.__init__(self, x, y, 5)

        self.x = x
        self.y = y
        self.line = Line(length, width)
Exemple #14
0
def create_line(token, origin_code, destination_code, line_status, line_type,
                line_kilometre, line_runtime, location_list):
    """
    创建线路信息
    :param token:
    :param origin_code:
    :param destination_code:
    :param line_status:
    :param line_type:
    :param line_kilometre:
    :param line_runtime:
    :param location_list:
    :return: cs.OK, {}
    """
    try:
        user = hgetall(get_token(token))
        if (not user) or int(
                user['role_type']) != cs.USER_ROLE_INFO[u"线路规划专员"]:
            return cs.AUTH_ERROR, None
        # 验证始发地目的地
        origin_location = get_location(origin_code)
        destination_location = get_location(destination_code)
        if not origin_location and not destination_location:
            return cs.LOCATION_CODE_ERR, None

        # 验证径停点 空校验,正确性校验
        if not location_list:
            return cs.LOCATION_INFO_ERR, None
        for item in list(location_list):

            location = get_location(int(item['location_code']))
            if not location:
                return cs.LOCATION_CODE_ERR, {
                    'location_code': item['location_code']
                }

        # 生成线路编码
        line_code = "MOT{}TO{}".format(origin_code, destination_code)
        line_code_count = db.session.query(Line.id).filter(
            Line.line_code.like('%' + str('MOT' + origin_code + 'TO' +
                                          destination_code) + '%')).count()
        amounter = str(line_code_count + 1).zfill(5)
        line_code = "{}{}".format(line_code, amounter)

        # 生成线路名称
        origin_name = origin_location.location_name
        destination_name = destination_location.location_name
        line_name = "{}-{}".format(origin_name, destination_name)
        location_number = len(location_list)
        # 添加线路信息
        line = Line(line_code, line_name, origin_code, destination_code,
                    line_status, line_type, line_kilometre, line_runtime,
                    location_number, user['id'])

        # 添加径停点信息
        for item in location_list:
            line_location = LineLocations(line_code, origin_code,
                                          destination_code,
                                          item['location_code'],
                                          item['sequence'],
                                          cs.LINE_LOCATION_STATUS_INFO[u"启用"],
                                          user['id'])
            db.session.add(line_location)
        db.session.add(line)
        db.session.commit()
        return cs.OK, {'line_code': line_code}
    except:
        logger.error('create_line err:{}'.format(traceback.format_exc(), ))
        raise
    finally:
        db.session.rollback()