Exemple #1
0
    def get(self):
        
        session = get_current_session()

        partner_name = self.request.get('partner_name')

        # Load from session if using breadcrumb
        if partner_name == '':
            if session.has_key('partner'):
                partner_name = session['partner']
        
        session['partner'] = partner_name


        if session.has_key('postcode'):
            postcode = session['postcode']

        template_values = {
            'postcode': postcode,
            'partner' : model.get_partner(partner_name),
            'menuitems' : model.menuitem.query(
            ancestor=model.partner_key(partner_name)).order(ndb.GenericProperty("itemid")).fetch(300)
        }

        template = JINJA_ENVIRONMENT.get_template('templates/menu.html')
        self.response.write(template.render(template_values))
Exemple #2
0
def grab(partner_name, fname):
  #This section grabs the data
  
  __location__ = os.path.realpath(
      os.path.join(os.getcwd(), os.path.dirname(__file__)))
  fpath = os.path.join(__location__, "menus", fname)
  # you now have a filepath that you can open the file with

  #open the file, the opened file is called importfile
  with open(fpath, 'rU') as importfile:
    dataimport = csv.reader(importfile, quotechar='"')
    # dataimport then reads opened file

    # for each row opened, print a comma, then the row.
    for row in dataimport:
      # adds entry
      print "New Entry -------"
      print partner_name
      myItem = model.menuitem(parent=model.partner_key(partner_name))
      print "loading: " + row[0]
      myItem.itemid = int(row[0])     
      print "loading: " + row[1]
      myItem.tabname = row[1]
      print "loading: " + row[2]
      myItem.item = row[2]
      print "loading: " + row[3]
      myItem.subitem = row[3]
      print "loading price: ", row[4]
      if (row[4] == ""):
        row[4] = 0
      print "loading price: ", row[4]
      myItem.price = float(row[4])
      print "loading: ", row[5]
      if (row[5] == ""):
        row[5] = 0
      print "reloading from pricemin: ", row[5]
      myItem.pricemin = float(row[5])
      print "loading: ", row[6]
      if (row[6] == ""):
        row[6] = 0
      print "reloading from pricemax: ", row[6]
      myItem.pricemax = float(row[6])
      print "loading: ", row[7]
      myItem.time = row[7]
      myItem.put()

      # prints to screen
      print row
  print 'DONE'
Exemple #3
0
    def post(self):

        print "IN REVIEW"
        #creates new order and associates it with the partner
        partner_name = self.request.get('partner_name')

        partner_k = model.partner_key(partner_name)
        myOrder = model.order(parent=partner_k)

        # get order info and load it into a model
        myOrder.first_name = self.request.get('first_name')
        myOrder.last_name = self.request.get('last_name')
        myOrder.address1 = self.request.get('Address_line_1')
        myOrder.address2 = self.request.get('Address_line_2')
        myOrder.address3 = self.request.get('Address_line_3')
        myOrder.postcode = self.request.get('Postcode')
        myOrder.collectioninstructions = self.request.get('Collect_instructions')
        myOrder.phonenumber = self.request.get('Phone_number')
        myOrder.email = self.request.get('Email')
        myOrder.collection_time_date = self.request.get('collection_day_output') + ', ' + self.request.get('collection_time_output')
        myOrder.delivery_time_date = self.request.get('delivery_day_output') + ', ' + self.request.get('delivery_time_output')
        myOrder.service_partner = partner_name
        myOrder.approx_cost = "Agreed when cleaner sees your clothes"
        myOrder.payment_method = self.request.get('payment_method')

        myOrder.put()

        session = get_current_session()
        session['ordernumber'] = myOrder.key.id()
        session['partnername'] = partner_name

        continue_message = ''
        if myOrder.payment_method == 'cash':
            continue_message = 'You are paying in cash when your cleaned clothes are delivered.'
        elif myOrder.payment_method == 'paypal':
            continue_message = 'You are billed automatically when your cleaner confirms the price. Continue to PayPal to complete your order. '

        template_values = {
            "continue_message": continue_message,
            "order" : myOrder,
            "partner_name" : partner_name
        }
        template = JINJA_ENVIRONMENT.get_template('templates/review.html')
        self.response.write(template.render(template_values))
Exemple #4
0
  def post(self): 
    ## Get the POST data and put it into variables
    # Blob data: ('logo' is file upload field in the form)
    upload_files = self.get_uploads('logo')
    blob_info = upload_files[0]
    blob_key = blob_info.key()

    partner_name = self.request.get('name')
    # Create a new "Partner" with a new partner key
    partner = model.Partner(parent=model.partner_key(partner_name))

    
    partner_outcodes = self.request.get('outcodes')
    partner_outcodes = quopri.decodestring(partner_outcodes)
    partner_outcodes = partner_outcodes.split()
    partner_address = self.request.get('address')
    partner_minimum_order = self.request.get('minimum_order')
    partner_delivery_cost = self.request.get('delivery_cost')

    partner.phonenumber = self.request.get('phonenumber')
    partner.phonenumber_2 = self.request.get('phonenumber_2')
    partner.email = self.request.get('email')
    partner.email_2 = self.request.get('email_2')
    partner.email_3 = self.request.get('email_3')

    
    # Give the new partner our data
    partner.name = partner_name
    partner.address = partner_address
    partner.outcodes = partner_outcodes
    partner.minimum_order = int(partner_minimum_order)
    partner.delivery_cost = partner_delivery_cost

    fname = self.request.get('filename')

    partner.start_hr = int(self.request.get('start_hr'))
    partner.start_min = int(self.request.get('start_min'))
    partner.end_hr = int(self.request.get('end_hr'))
    partner.end_min = int(self.request.get('end_min'))
    partner.window_size = int(self.request.get('window_size'))

    partner.last_orders_hr = int(self.request.get('last_orders_hr'))
    partner.last_orders_min = int(self.request.get('last_orders_min'))
    partner.end_of_morning_hr = int(self.request.get('end_of_morning_hr'))
    partner.end_of_morning_min = int(self.request.get('end_of_morning_min'))

    partner.last_orders_same_day_hr = int(self.request.get('last_orders_same_day_hr'))
    partner.last_orders_same_day_min = int(self.request.get('last_orders_same_day_min'))

    partner.shirts = self.request.get('shirts')
    partner.suits = self.request.get('suits')



    days = self.request.get('days')
    day_list = days.split()
    day_list = map(int, day_list)
    partner.days = day_list

    # OLD:
    # partner.start_day = int(self.request.get('start_day'))
    # partner.end_day = int(self.request.get('end_day'))


    partner.logo_key = blob_key # n.b. blobstore.BlobReferenceProperty() takes a blob_info
    
    partner.populate_slots()

    # Use to clear all items
    clear_items(partner_name) 

    # Populate if no items exist
    if fname:
      grab(partner_name, fname)



    partner.put()

    # redirect
    self.redirect('/viewpartners')
Exemple #5
0
def clear_items(partner_name):
  print "IN CLEAR_ITEMS"
  query = model.menuitem.query(ancestor=model.partner_key(partner_name))
  partners = query.fetch(keys_only=True)
  ndb.delete_multi(partners)