def get(self): # Get the id from the get parameter ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to page with all products? ''' self.redirect('/') return # Fetch the data for this product product = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) # generic template_values['id'] = ID template_values['name'] = product.name template_values['product'] = product template_values['producer'] = product.getProducer() template_values['rating'] = product.getRating() # urls template_values['url'] = self.request.url template_values['path'] = "product" template_values['qr_url'] = self.request.url.replace('viewproduct','qr') template_values['image_url'] = self.request.url.replace('viewproduct', 'productimage') template_values['comment_url'] = '%s/viewproduct?%s' % (self.request.host_url, urllib.urlencode({'id': ID})) # interactions - producer template_values['can_edit'] = False user = users.get_current_user() if user: if product.owner == user and bene_query.getCurrentUser().isProducer: template_values['can_edit'] = True template_values['edit_link'] = '/editproduct?%s' % urllib.urlencode({'id': ID}) template_values['show_qr'] = True # interactions - consumer template_values['in_closet'] = False template_values['add_closet'] = False if user: if bene_query.getCurrentUser().isConsumer: consumer = bene_query.getCurrentConsumer() if consumer: if consumer.hasProduct(product.key()): template_values['in_closet'] = True template_values['rem_closet_link'] = '/removefromcloset?%s' % urllib.urlencode({'id': ID}) else: template_values['add_closet'] = True template_values['add_closet_link'] = '/addtocloset?%s' % urllib.urlencode({'id': ID}) template_values['num_configs'] = product.numConfigs() template_values['configs'] = product.getConfigs() template_values['num_products'] = product.numProducts() template_values['closet_count'] = product.getClosetCount() path = os.path.join(os.path.dirname(__file__), 'viewproduct.html') self.response.out.write(template.render(path, template_values).decode('utf-8')) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return _name = self.request.get('name') _description = self.request.get('description') _picture = self.request.get('picture') _producer.name = _name _producer.description = _description _producer.addPicture(_picture) _producer.put() self.redirect('/viewproducer?%s' % urllib.urlencode({'id': _producer.key()})) return
def get(self): user = users.get_current_user() if not user: # not signed in self.redirect('/?%s' % urllib.urlencode({'signin': True})) return if bene_query.getCurrentUser().isProducer: # producers don't have closets self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # if consumer page doesn't exist, need to create one self.redirect('/createconsumer?%s' % urllib.urlencode({'msg': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to viewcloset? ''' self.redirect('/') return product = db.get(ID) if not product: # invalid product template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return # if not already in closet, add to closet, and redirect back to product page #return if not _consumer.hasProduct(product.key()): _consumer.addProduct(product.key()) _consumer.put() self.redirect('/mobilepage?%s' % urllib.urlencode({'id': product.key()})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return producer = bene_query.getCurrentProducer() if producer == None: # no producer signed up, so ask to sign up self.redirect('/') return # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = producer.key() template_values['producer'] = producer template_values['products'] = producer.getProducts() template_values['can_edit'] = False user = users.get_current_user() if user: if producer.owner == user: template_values['can_edit'] = True path = os.path.join(os.path.dirname(__file__), 'viewproducerproducts.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect("/?signin=True") return if bene_query.getCurrentUser().isProducer: # producers aren't allowed here self.redirect("/") return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer page, so create one self.redirect("/") return # Make a dictionary for template name = _consumer.name profile = _consumer.profile template_values = bene_util.initTemplate(self.request.uri) template_values["id"] = _consumer.key() template_values["consumer"] = _consumer template_values["name"] = name template_values["profile"] = profile template_values["can_edit"] = False user = users.get_current_user() if user: if _consumer.owner == user: template_values["can_edit"] = True template_values["edit_link"] = "/editconsumer" path = os.path.join(os.path.dirname(__file__), "viewconsumer.html") self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer != None: # already has a producer page self.redirect('/') return _name = self.request.get('name') _picture = self.request.get('picture') _description = self.request.get('description') p = entities.Producer(name = _name, email=bene_util.getEmail(user), owner=user, description=_description, verified=False) p.addPicture(_picture) p.put() self.redirect('/') return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return _name = bene_util.sanitize(self.request.get('name')) _description = bene_util.sanitize(self.request.get('description')) _picture = self.request.get('picturedata') _email_public = self.request.get('email') _producer.name = _name _producer.description = _description _producer.email_public = _email_public _producer.addPicture(_picture) _producer.put() self.redirect('/myprofile') return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers aren't allowed here self.redirect('/') return _consumer = bene_query.getCurrentConsumer(); if _consumer == None: # no consumer page, so create one self.redirect('/') return # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _consumer.key() template_values['consumer'] = _consumer template_values['products'] = _consumer.getProducts() template_values['path'] = self.request.path template_values['can_edit_local'] = False user = users.get_current_user() if user: if _consumer.owner == user: template_values['can_edit_local'] = True path = os.path.join(os.path.dirname(__file__), 'viewcloset.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _producer.key() template_values['name_old'] = _producer.name template_values['description_old'] = _producer.description template_values['email_public_old'] = _producer.email_public template_values['cropentity'] = _producer path = os.path.join(os.path.dirname(__file__), 'editproducer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isProducer: # producers aren't allowed here self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer page, so create one self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _consumer.key() template_values['name_old'] = _consumer.name template_values['profile_old'] = _consumer.profile template_values['email_public_old'] = _consumer.email_public template_values['cropentity'] = _consumer path = os.path.join(os.path.dirname(__file__), 'editconsumer.html') self.response.out.write(template.render(path, template_values)) return '''
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isProducer: # producers aren't allowed here self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer page, so create one self.redirect('/') return _name = bene_util.sanitize(self.request.get('name')) _profile = bene_util.sanitize(self.request.get('profile')) _picture = self.request.get('picturedata') _email_public = self.request.get('email') _consumer.name = _name _consumer.profile = _profile _consumer.email_public = _email_public _consumer.addPicture(_picture) _consumer.put() self.redirect('/myprofile') return '''
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer != None: # already has a producer page self.redirect('/') return _name = bene_util.sanitize(self.request.get('name')) _picture = self.request.get('picturedata') _description = bene_util.sanitize(self.request.get('description')) _email_public = self.request.get('email') p = entities.Producer(name=_name, email=bene_util.getEmail(user), email_public=_email_public, owner=user, description=_description, verified=False) p.addPicture(_picture) p.put() self.redirect('/producerhome?%s' % urllib.urlencode({'verifyone': True})) return
def get(self): # Get the id from the get parameter ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to page with all products? ''' self.redirect('/') return # Fetch the data for this producer producer = db.get(ID) ''' an error in getting the producer will be redirected to exception handler''' # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = ID template_values['producer'] = producer template_values['product_lines'] = producer.getProductLines() template_values['path'] = "product" template_values['can_edit_local'] = False user = users.get_current_user() if user: if producer.owner == user and bene_query.getCurrentUser( ).isProducer: template_values['can_edit_local'] = True path = os.path.join(os.path.dirname(__file__), 'viewproducerproducts.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if user: # if user signed in signed_in_user = bene_query.getCurrentUser() if signed_in_user.isProducer: if not bene_query.getCurrentProducer( ): # if producer page doesn't exist, need to create one self.redirect('/createproducer?%s' % urllib.urlencode({ 'redirect': 'producerhome', 'msg': True })) else: # if setup done, then go to home page self.redirect('/producerhome') return else: if not bene_query.getCurrentConsumer(): self.redirect('/createconsumer?%s' % urllib.urlencode({ 'redirect': 'consumerhome', 'msg': True })) return else: self.redirect('/consumerhome') return else: # otherwise, show button for signing in and searching template_values = bene_util.initTemplate(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'home.html') self.response.out.write(template.render(path, template_values)) return
def get(self): # Get the id from the get parameter ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to page with all products? ''' self.redirect('/') return # Fetch the data for this product product = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' _factory = product.getFactory() if _factory and _factory.location: latitude = _factory.location.lat longitude = _factory.location.lon else: latitude = None longitude = None # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = ID template_values['name'] = product.name template_values['producer'] = product.getProducer() template_values['latitude'] = latitude template_values['longitude'] = longitude template_values['url'] = self.request.url template_values['qr_url'] = self.request.url.replace('view','qr') template_values['factory'] = _factory template_values['badges'] = product.getBadges() template_values['rating'] = product.rating template_values['workers'] = product.getWorkers() if product.picture: template_values['has_image'] = True else: template_values['has_image'] = False template_values['can_edit'] = False user = users.get_current_user() if user: if product.owner == user: template_values['can_edit'] = True template_values['edit_link'] = '/editproduct?%s' % urllib.urlencode({'id': ID}) template_values['in_closet'] = False template_values['add_closet'] = False if user: if bene_query.getCurrentUser().isConsumer: consumer = bene_query.getCurrentConsumer() if consumer: if consumer.hasProduct(product.key()): template_values['in_closet'] = True template_values['rem_closet_link'] = '/removefromcloset?%s' % urllib.urlencode({'id': ID}) else: template_values['add_closet'] = True template_values['add_closet_link'] = '/addtocloset?%s' % urllib.urlencode({'id': ID}) path = os.path.join(os.path.dirname(__file__), 'viewproduct.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return template_values = bene_util.urldecode(self.request.uri) template_values['factories'] = _producer.getFactories() path = os.path.join(os.path.dirname(__file__), 'createworker.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to ? ''' self.redirect('/') return _worker = db.get(ID) ''' an error in getting the worker will be redirected to exception handler''' db.delete(ID) self.redirect('/myworkers') return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect("/?signin=True") return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect("/") return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect("/") return if not _producer.verified: # if producer is not verified self.redirect("/producerhome?%s" % urllib.urlencode({"verify": True})) return template_values = bene_util.initTemplate(self.request.uri) template_values["factories"] = _producer.getFactories() template_values["workers"] = _producer.getWorkers() template_values["badges"] = entities.Badge.all() path = os.path.join(os.path.dirname(__file__), "createproduct.html") self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['producer'] = _producer template_values['path'] = "message" __msgs = _producer.getSentMsg() _msgs = [] for _msg in __msgs: _msgs.append(_msg) if _msgs: _msgs.reverse() template_values['messages'] = _msgs path = os.path.join(os.path.dirname(__file__), 'viewoutbox.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect("/?signin=True") return if bene_query.getCurrentUser().isProducer: # producers aren't allowed here self.redirect("/") return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer page, so create one self.redirect("/") return _name = self.request.get("name") _profile = self.request.get("profile") _picture = self.request.get("picture") _consumer.name = _name _consumer.profile = _profile _consumer.addPicture(_picture) _consumer.put() self.redirect("/viewconsumer?%s" % urllib.urlencode({"id": _consumer.key()})) return """
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers can't do this self.redirect('/') return if bene_query.getCurrentConsumer() != None: # already exists self.redirect('/') return # no consumer, so add to store _name = self.request.get('name') _picture = self.request.get('picture') _profile = self.request.get('profile') c = entities.Consumer(name=_name, email=bene_util.getEmail(user), owner=user, profile=_profile, verified=False) c.addPicture(_picture) c.put() self.redirect('/') return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers aren't allowed here self.redirect('/') return _consumer = bene_query.getCurrentConsumer(); if _consumer == None: # no consumer page, so create one self.redirect('/') return # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _consumer.key() template_values['consumer'] = _consumer template_values['products'] = _consumer.getProducts() template_values['can_edit_local'] = False user = users.get_current_user() if user: if _consumer.owner == user: template_values['can_edit_local'] = True path = os.path.join(os.path.dirname(__file__), 'viewcloset.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to ? ''' self.redirect('/') return _worker = db.get(ID) ''' an error in getting the worker will be redirected to exception handler''' if _worker.owner != user: # not 'owner' of worker. I know it sounds very pre-emancipation self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return template_values = bene_util.initTemplate(self.request.uri) template_values['name_old'] = _worker.name template_values['profile_old'] = _worker.profile template_values['unique_old'] = _worker.unique _factories_old = [_worker.getFactory()] template_values['factories_old'] = _factories_old template_values['factories'] = [] ''' TODO: Make this more efficient. For some reason, 'factory not in _factories_old' doesn't work ''' _factories = _producer.getFactories() if _factories: for factory in _factories: if factory: add = True if _factories_old: for factory_old in _factories_old: if factory_old: if factory_old.key() == factory.key(): add = False if add: template_values['factories'].append(factory) path = os.path.join(os.path.dirname(__file__), 'editworker.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers can't do this self.redirect('/') return if bene_query.getCurrentConsumer() != None: # already exists self.redirect('/') return # no consumer, so add to store _name = bene_util.sanitize(self.request.get('name')) _picture = bene_util.sanitize(self.request.get('picturedata')) _profile = self.request.get('profile') _email_public = self.request.get('email') c = entities.Consumer(name=_name, has_unread=0, email=bene_util.getEmail(user), email_public=_email_public, owner=user, profile=_profile, verified=False) c.addPicture(_picture) c.put() self.redirect('/consumerhome?%s' % urllib.urlencode({'firsttime': True})) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to page with all factories? ''' self.redirect('/') return _factory = db.get(ID) ''' an error in getting the factory will be redirected to exception handler''' if _factory.owner != user: # if not owner of factory self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _factory.name = self.request.get('name') _factory.address = self.request.get('address') _unique_save = _factory.unique _factory.unique = self.request.get('unique') if bene_util.doesFactoryExist(_factory) and _unique_save != _factory.unique : # if factory with same unique exists self.redirect('/editfactory?%s' % (urllib.urlencode({'id' : ID, 'repeatedit' : True}))) return _picture = self.request.get('picture') _factory.addPicture(_picture) _location = self.request.get('location') fields = _location.split(',') if len(fields) == 2: try: lat = float(fields[0]) lon = float(fields[1]) gp = db.GeoPt(lat, lon) except ValueError: gp = None else: gp = None _factory.location = gp _factory.put() self.redirect('/viewfactory?%s' % urllib.urlencode({'id': ID})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers can't access this self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no producer signed up, so ask to sign up self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['consumer'] = _consumer _msgs = _consumer.getReceivedMsg() if _msgs: _msgs.reverse() template_values['messages'] = _msgs template_values['num_unread'] = _consumer.has_unread template_values['path'] = 'message' _consumer.has_unread = 0 _consumer.put() path = os.path.join(os.path.dirname(__file__), 'viewinbox.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return producer = bene_query.getCurrentProducer() if producer == None: # no producer signed up, so ask to sign up self.redirect('/') return # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = producer.key() template_values['producer'] = producer template_values['product_lines'] = producer.getProductLines() template_values['path'] = "product" template_values['can_edit_local'] = False user = users.get_current_user() if user: if producer.owner == user: template_values['can_edit_local'] = True path = os.path.join(os.path.dirname(__file__), 'viewproducerproducts.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return _name = self.request.get('name') _address = self.request.get('address') _location = self.request.get('location') _unique = self.request.get('unique') _picture = self.request.get('picture') fields = _location.split(',') if len(fields) == 2: try: lat = float(fields[0]) lon = float(fields[1]) gp = db.GeoPt(lat, lon) except ValueError: gp = None else: gp = None f = entities.Factory(name=_name, address=_address, location=gp, unique=_unique, owner=user) f.addProducer(_producer) f.addPicture(_picture) if bene_util.doesFactoryExist(f): self.redirect('/createfactory?%s' % urllib.urlencode({'repeat': True})) return f.put() if self.request.get('more'): # want to add more self.redirect('/createfactory?%s' % urllib.urlencode({'added': True})) return # otherwise redirect to factory page self.redirect('/viewfactory?%s' % urllib.urlencode({'id' : f.key()}))
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return _name = self.request.get('name') _factory = self.request.get('factory') _workers = self.request.get_all('workers') _badges = self.request.get_all('badges') _picture = self.request.get('picture') _unique = self.request.get('unique') p = entities.Product(name=_name, unique=_unique, owner=user) p.addPicture(_picture) if _factory: p.addFactory(db.get(_factory)) p.addProducer(_producer) for _badge in _badges: p.addBadge(_badge) if bene_util.doesProductExist(p): # already exists self.redirect('/createproduct?%s' % urllib.urlencode({'repeat': True})) return p.put() # add product to workers if _workers: key = p.key() for _worker in _workers: if _worker: worker = db.get(_worker) worker.addProduct(key) worker.put() if self.request.get('more'): # want to add more self.redirect('/createproduct?%s' % urllib.urlencode({'added': True})) return # otherwise redirect to product page self.redirect('/mobilepage?%s' % urllib.urlencode({'id' : p.key()}))
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return producer = bene_query.getCurrentProducer() if producer == None: # no producer signed up, so ask to sign up self.redirect('/') return # Make a dictionary for template template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = producer.key() template_values['producer'] = producer workers = producer.getWorkers() template_values['workers'] = workers num_workers = 0 if workers: for worker in workers: if worker: num_workers += 1 if num_workers == 0: template_values['no_workers'] = True else: template_values['no_workers'] = False locations = producer.getLocations() template_values['locations'] = locations num_workers_with_loc = 0 if locations: for location in locations: if location: _workers = location.getWorkers() if _workers: for worker in _workers: if worker: num_workers_with_loc += 1 template_values[ 'num_worker_no_location'] = num_workers - num_workers_with_loc template_values['can_edit_local'] = False user = users.get_current_user() if user: if producer.owner == user: template_values['can_edit_local'] = True path = os.path.join(os.path.dirname(__file__), 'viewproducerworkers.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _productgeneric = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' if _productgeneric.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _text = bene_util.sanitize(self.request.get('text')) msg = entities.MessageFromProducer( text=_text, sender=_producer, receiver=_productgeneric, num_receivers=_productgeneric.getClosetCount()) msg.put() msg_key = msg.key() _consumers = _productgeneric.getConsumers() if _consumers: for _consumer in _consumers: if _consumer: _consumer.addReceivedMsg(msg_key) _consumer.has_unread += 1 _consumer.put() self.redirect('/myoutbox') return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to ? ''' self.redirect('/') return _worker = db.get(ID) if not _worker: # doesn't exist template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return if _worker.owner != user: # not 'owner' of worker. I know it sounds very pre-emancipation self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _worker.name = self.request.get('name') _worker.profile = self.request.get('profile') _unique_save = _worker.unique _worker.unique = self.request.get('unique') if bene_util.doesWorkerExist(_worker) and _unique_save != _worker.unique: # if worker already exists self.redirect('/editworker?%s' % (urllib.urlencode({'id' : ID, 'repeatedit' : True}))) return _factory = self.request.get('factory') if _factory: _worker.factory = db.get(_factory) _picture = self.request.get('picture') _worker.addPicture(_picture) _worker.put() self.redirect('/viewworker?%s' % urllib.urlencode({'id': ID})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _productgeneric = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' if _productgeneric.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = ID template_values['path'] = "message" template_values['num_sent'] = _productgeneric.getClosetCount() if _productgeneric.isConfig: template_values['name'] = _productgeneric.getName() template_values['is_config'] = True template_values['config'] = _productgeneric template_values['line'] = _productgeneric.getProductLine() elif _productgeneric.isLine: template_values['name'] = _productgeneric.name template_values['is_line'] = True template_values['line'] = _productgeneric path = os.path.join(os.path.dirname(__file__), 'producermsg.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect(users.create_login_url(self.request.uri)) return if not bene_query.getCurrentUser(): # no user exists producer = self.request.get('producer') consumer = self.request.get('consumer') if producer and not consumer: # make person a producer only in most restricted case u = entities.User(email=user.nickname(), owner=user, isConsumer=False, isProducer=True) u.put() self.redirect('/createproducer') return else: # all other cases, make consumer u = entities.User(email=user.nickname(), owner=user, isConsumer=True, isProducer=False) u.put() self.redirect('/createconsumer') return if bene_query.getCurrentUser().isProducer: # signed in producer if bene_query.getCurrentProducer() == None: # no producer page, so create one self.redirect('/createproducer') return else: # already has producer page, so redirect self.redirect('/producerhome') return else: # signed in consumer if bene_query.getCurrentConsumer() == None: # no consumer page, so create on self.redirect('/createconsumer') return else: # already has consumer page, so redirect self.redirect('/consumerhome') return
def get(self): ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: if no id is sent, defaults to a page with all workers? ''' self.redirect('/') worker = db.get(ID) ''' an error in getting the worker will be redirected to exception handler''' # Make a dictionary for template name = worker.name location = worker.getLocation() profile = worker.profile picture = worker.getPicture() producer = worker.getProducer() products = worker.getProductLines() if location: if location.location: latitude = location.location.lat longitude = location.location.lon else: latitude = None longitude = None else: latitude = None longitude = None template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = worker.key() template_values['worker'] = worker template_values['name'] = name template_values['picture'] = picture template_values['profile'] = profile template_values['location'] = location template_values['producer'] = producer template_values['products'] = products template_values['latitude'] = latitude template_values['longitude'] = longitude template_values['url'] = self.request.url template_values['path'] = "worker" template_values['can_edit'] = False user = users.get_current_user() if user: if worker.owner == user and bene_query.getCurrentUser().isProducer: template_values['can_edit'] = True template_values[ 'edit_link'] = '/editworker?%s' % urllib.urlencode( {'id': ID}) path = os.path.join(os.path.dirname(__file__), 'viewworker.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect(users.create_login_url(self.request.uri)) return producer = bene_util.sanitize(self.request.get('producer')) consumer = bene_util.sanitize(self.request.get('consumer')) u = bene_query.getCurrentUser() if not u: # no user exists if producer and not consumer: # make person a producer only in most restricted case u = entities.User(email=bene_util.getEmail(user), owner=user, isConsumer=False, isProducer=True) u.put() self.redirect('/createproducer') return else: # all other cases, make consumer u = entities.User(email=bene_util.getEmail(user), owner=user, isConsumer=True, isProducer=False) u.put() self.redirect('/createconsumer') return if producer and not consumer: # signed in producer if u.isConsumer: # if previously signed in as consumer u.isConsumer = False u.isProducer = True u.put() if bene_query.getCurrentProducer( ) == None: # no producer page, so create one self.redirect('/createproducer') return else: # already has producer page, so redirect self.redirect('/producerhome') return else: # signed in consumer if u.isProducer: # if previously signed in as producer u.isConsumer = True u.isProducer = False u.put() if bene_query.getCurrentConsumer( ) == None: # no consumer page, so create on self.redirect('/createconsumer') return else: # already has consumer page, so redirect self.redirect('/consumerhome') return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to ? ''' self.redirect('/') return _worker = db.get(ID) ''' an error in getting the worker will be redirected to exception handler''' if _worker.owner != user: # not 'owner' of worker. I know it sounds very pre-emancipation self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _worker.name = self.request.get('name') _worker.profile = self.request.get('profile') _unique_save = _worker.unique _worker.unique = self.request.get('unique') if bene_util.doesWorkerExist(_worker) and _unique_save != _worker.unique: # if worker already exists self.redirect('/editworker?%s' % (urllib.urlencode({'id' : ID, 'repeatedit' : True}))) return _factory = self.request.get('factory') if _factory: _worker.factory = db.get(_factory) _picture = self.request.get('picture') _worker.addPicture(_picture) _worker.put() self.redirect('/viewworker?%s' % urllib.urlencode({'id': ID})) return
def get(self): ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to page with all locations? ''' self.redirect('/') return location = db.get(ID) ''' an error in getting the location will be redirected to exception handler''' # Make a dictionary for template name = location.name producer = location.getProducer() productlist = location.getProductLines() workers = location.getWorkers() address = location.address if location.location: latitude = location.location.lat longitude = location.location.lon else: latitude = None longitude = None template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = ID template_values['name'] = name template_values['location'] = location template_values['producer'] = producer template_values['products'] = productlist template_values['workers'] = workers template_values['latitude'] = latitude template_values['longitude'] = longitude template_values['url'] = self.request.url template_values['address'] = address template_values['qr_url'] = self.request.url.replace('view', 'qr') template_values['path'] = "location" template_values['can_edit'] = False user = users.get_current_user() if user: if location.owner == user and bene_query.getCurrentUser( ).isProducer: template_values['can_edit'] = True template_values[ 'edit_link'] = '/editlocation?%s' % urllib.urlencode( {'id': ID}) path = os.path.join(os.path.dirname(__file__), 'viewlocation.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _productline = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' if _productline.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return # edit product line _picture = self.request.get('picturedata') _name = bene_util.sanitize(self.request.get('name')) _description = bene_util.sanitize(self.request.get('description')) if _name != _productline.name or _description != _productline.description or _picture: _name_save = _productline.name _productline.name = _name _productline.description = _description if bene_util.doesSimilarProductLineExist(_productline) and _name_save != _productline.name: # already exists self.redirect('/editproduct?%s' % urllib.urlencode({'repeatedit': True, 'id': ID})) return _productline.addPicture(_picture) _productline.put() self.redirect('/view?%s' % urllib.urlencode({'id': ID})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return # Make a dictionary for template name = _producer.name description = _producer.description products = _producer.getProducts() workers = _producer.getWorkers() factories = _producer.getFactories() template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _producer.key() template_values['name'] = name template_values['description'] = description template_values['factories'] = factories template_values['products'] = products template_values['producer'] = _producer template_values['workers'] = workers template_values['url'] = self.request.url template_values['can_edit'] = False user = users.get_current_user() if user: if _producer.owner == user: template_values['can_edit'] = True template_values['edit_link'] = '/editproducer' if _producer.getPicture(): template_values['has_image'] = True else: template_values['has_image'] = False path = os.path.join(os.path.dirname(__file__), 'viewproducer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to page with all locations? ''' self.redirect('/') return _location = db.get(ID) ''' an error in getting the location will be redirected to exception handler''' if _location.owner != user: # if not owner of location self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = ID template_values['name_old'] = _location.name template_values['address_old'] = _location.address template_values['unique_old'] = _location.unique template_values['description_old'] = _location.description template_values['path'] = "location" template_values['cropentity'] = _location path = os.path.join(os.path.dirname(__file__), 'editlocation.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # not signed in self.redirect('/?%s' % urllib.urlencode({'signin': True})) return if bene_query.getCurrentUser( ).isProducer: # producers don't have closets self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # if consumer page doesn't exist, need to create one self.redirect('/createconsumer?%s' % urllib.urlencode({'msg': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent, default to viewcloset? ''' self.redirect('/') return product = db.get(ID) if not product: # invalid product template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return # if not already in closet, add to closet, and redirect back to product page #return if not _consumer.hasProduct(product.key()): _consumer.addProduct(product.key()) _consumer.put() # add to closet count if product.isConfig: product.addClosetCount() product.addConsumer(_consumer.key()) product.put() if product.isUnit: productconfig = product.getProductConfig() productconfig.addClosetCount() productconfig.addConsumer(_consumer.key()) productconfig.put() self.redirect('/view?%s' % urllib.urlencode({'id': product.key()})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers can't do this self.redirect('/') return if bene_query.getCurrentConsumer() != None: # has consumer page self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'createconsumer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent, default to page with all factories? ''' self.redirect('/') return _factory = db.get(ID) if not _factory: template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return if _factory.owner != user: # if not owner of factory self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return template_values = bene_util.urldecode(self.request.uri) template_values['id'] = ID template_values['name_old'] = _factory.name template_values['address_old'] = _factory.address template_values['unique_old'] = _factory.unique path = os.path.join(os.path.dirname(__file__), 'editfactory.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return _name = self.request.get('name') _factory = self.request.get('factory') _picture = self.request.get('picture') _profile = self.request.get('profile') _unique = self.request.get('unique') w = entities.Worker(name=_name, profile=_profile, unique=_unique, owner=user) w.addProducer(_producer) if _factory: w.addFactory(db.get(_factory)) w.addPicture(_picture) if bene_util.doesWorkerExist(w): # already exists self.redirect('/createworker?%s' % urllib.urlencode({'repeat': True})) return w.put() if self.request.get('more'): # want to add more self.redirect('/createworker?%s' % urllib.urlencode({'added': True})) return # otherwise redirect to worker page self.redirect('/viewworker?%s' % urllib.urlencode({'id' : w.key()}))
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producers can't do this self.redirect('/') return if bene_query.getCurrentConsumer() != None: # has consumer page self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['email_public_old'] = bene_util.getEmail(user) path = os.path.join(os.path.dirname(__file__), 'createconsumer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return template_values = bene_util.initTemplate(self.request.uri) _locations = _producer.getLocations() template_values['locations'] = _locations count = 0 if _locations: for location in _locations: if location: count += 1 if len(location.name) > 10: count += 1 if not count: count = 1 template_values['pathheight'] = count * 40 if count == 0: template_values['no_locations'] = True elif count > 0: template_values['no_locations'] = False template_values['workers'] = _producer.getWorkers() template_values['badges'] = entities.Badge.all() template_values['path'] = "product" path = os.path.join(os.path.dirname(__file__), 'createproduct.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer != None: # already has a producer page self.redirect('/') return template_values = bene_util.urldecode(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'createproducer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # if not signed in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isProducer: # producer can't get to consumer home page self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # if consumer page doesn't exist, need to create one self.redirect('/createconsumer?%s' % urllib.urlencode({'redirect': 'consumerhome', 'msg': True})) return # if setup done, then show home page template_values = bene_util.initTemplate(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'consumerhome.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'producerhome.html') self.response.out.write(template.render(path, template_values)) return
def get(self): ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: if no id is sent, defaults to a page with all producers? ''' self.redirect('/') return _producer = db.get(ID) ''' an error in getting the producer will be redirected to exception handler''' # Make a dictionary for template name = _producer.name description = _producer.description product_lines = _producer.getProductLines()[0:4] workers = _producer.getWorkers()[0:4] locations = _producer.getLocations()[0:4] email_public = _producer.email_public template_values = bene_util.initTemplate(self.request.uri) template_values['id'] = _producer.key() template_values['name'] = name template_values['email_public'] = email_public template_values['description'] = description template_values['locations'] = locations template_values['product_lines'] = product_lines template_values['producer'] = _producer template_values['workers'] = workers template_values['url'] = self.request.url template_values['path'] = self.request.path template_values['can_edit'] = False user = users.get_current_user() if user: if _producer.owner == user and bene_query.getCurrentUser( ).isProducer: template_values['can_edit'] = True template_values['edit_link'] = '/editproducer' path = os.path.join(os.path.dirname(__file__), 'viewproducer.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = bene_util.sanitize(self.request.get('id')) if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _unit = db.get(ID) ''' an error in getting the product will be redirected to exception handler''' if _unit.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return # remove db.delete(_unit.key()) self.redirect('/myproducts') return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return template_values = bene_util.initTemplate(self.request.uri) template_values['path'] = self.request.path path = os.path.join(os.path.dirname(__file__), 'producerhome.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if not user: # if not signed in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isProducer: # producer can't get to consumer home page self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # if consumer page doesn't exist, need to create one self.redirect('/createconsumer?%s' % urllib.urlencode({ 'redirect': 'consumerhome', 'msg': True })) return # if setup done, then show home page template_values = bene_util.initTemplate(self.request.uri) path = os.path.join(os.path.dirname(__file__), 'consumerhome.html') self.response.out.write(template.render(path, template_values)) return
def get(self): user = users.get_current_user() if user: # if user signed in signed_in_user = bene_query.getCurrentUser() if signed_in_user.isProducer: if not bene_query.getCurrentProducer(): # if producer page doesn't exist, need to create one self.redirect('/createproducer?%s' % urllib.urlencode({'redirect': 'producerhome', 'msg': True})) else: # if setup done, then go to home page self.redirect('/producerhome') return else: if not bene_query.getCurrentConsumer(): self.redirect('/createconsumer?%s' % urllib.urlencode({'redirect': 'consumerhome', 'msg': True})) return else: self.redirect('/consumerhome') return else: # otherwise, show button for signing in and searching template_values = {} path = os.path.join(os.path.dirname(__file__), 'home.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser( ).isProducer: # producers can't access this self.redirect('/') return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer signed up, so ask to sign up self.redirect('/') return productConfigKey = bene_util.sanitize( self.request.get('productConfigKey')) _productconfig = db.get(productConfigKey) _productconfig.updateRating( float(bene_util.sanitize(self.request.get('adv1'))), _consumer) _productconfig.put() '''
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect("/?signin=True") return if bene_query.getCurrentUser().isProducer: # producers aren't allowed here self.redirect("/") return _consumer = bene_query.getCurrentConsumer() if _consumer == None: # no consumer page, so create one self.redirect("/") return template_values = bene_util.urldecode(self.request.uri) template_values["name_old"] = _consumer.name template_values["profile_old"] = _consumer.profile path = os.path.join(os.path.dirname(__file__), "editconsumer.html") self.response.out.write(template.render(path, template_values)) return """
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return ''' PRODUCER PROFILE ''' if bene_query.getCurrentUser().isProducer: _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return # Make a dictionary for template name = _producer.name description = _producer.description products = _producer.getProducts() workers = _producer.getWorkers() factories = _producer.getFactories() template_values = bene_util.urldecode(self.request.uri) template_values['id'] = _producer.key() template_values['name'] = name template_values['description'] = description template_values['factories'] = factories template_values['products'] = products template_values['producer'] = _producer template_values['workers'] = workers template_values['url'] = self.request.url template_values['can_edit'] = False user = users.get_current_user() if user: if _producer.owner == user: template_values['can_edit'] = True if _producer.getPicture(): template_values['has_image'] = True else: template_values['has_image'] = False path = os.path.join(os.path.dirname(__file__), 'viewproducer.html') self.response.out.write(template.render(path, template_values)) return ''' CONSUMER PROFILE ''' _consumer = bene_query.getCurrentConsumer(); if _consumer == None: # no consumer page, so create one self.redirect('/') return # Make a dictionary for template name = _consumer.name profile = _consumer.profile template_values = bene_util.urldecode(self.request.uri) template_values['id'] = _consumer.key() template_values['consumer'] = _consumer template_values['name'] = name template_values['profile'] = profile template_values['can_edit'] = False user = users.get_current_user() if user: if _consumer.owner == user: template_values['can_edit'] = True path = os.path.join(os.path.dirname(__file__), 'viewconsumer.html') self.response.out.write(template.render(path, template_values)) return
def post(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _product = db.get(ID) if not _product: # product doesn't exist template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return if _product.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _product.name = self.request.get('name') _unique_save = _product.unique _product.unique = self.request.get('unique') if bene_util.doesProductExist(_product) and _unique_save != _product.unique: # if product already exists self.redirect('/editproduct?%s' % (urllib.urlencode({'id' : ID, 'repeatedit' : True}))) return _factory = self.request.get('factory') if _factory: _product.addFactory(db.get(_factory)) _picture = self.request.get('picture') _product.addPicture(_picture) # badges _badges = self.request.get_all('badges') _badges_old = _product.getBadges() if _badges_old: for badge in _badges_old: if not _badges: # convert None to empty array _badges = [] if badge not in _badges: _product.remBadge(badge) if _badges: for badge in _badges: if not _badges_old: # convert None to empty array _badges_old = [] if badge not in _badges_old: _product.addBadge(badge) _product.put() # workers ''' TODO: FIX THIS. Make it more efficient ''' _workers = self.request.get_all('workers') _workers_old = _product.getWorkers() key = _product.key() if _workers_old: for worker in _workers_old: worker.remProduct(key) worker.put() if _workers: for _worker in _workers: if _worker: worker = db.get(_worker) worker.addProduct(key) worker.put() self.redirect('/mobilepage?%s' % urllib.urlencode({'id': ID})) return
def get(self): user = users.get_current_user() if not user: # need to sign in self.redirect('/?signin=True') return if bene_query.getCurrentUser().isConsumer: # consumers can't access this self.redirect('/') return _producer = bene_query.getCurrentProducer() if _producer == None: # no producer signed up, so ask to sign up self.redirect('/') return if not _producer.verified: # if producer is not verified self.redirect('/producerhome?%s' % urllib.urlencode({'verify': True})) return ID = self.request.get('id') if not ID: ''' TODO: If no ID sent? ''' self.redirect('/') return _product = db.get(ID) if not _product: # product doesn't exist template_values = {} path = os.path.join(os.path.dirname(__file__), 'not_found.html') self.response.out.write(template.render(path, template_values)) return if _product.owner != user: # if current user doesn't own product self.redirect('/producerhome?%s' % urllib.urlencode({'not_owner': True})) return _factories_old = _product.getFactories() _workers_old = _product.getWorkers() _badges_old = _product.getBadges() template_values = bene_util.urldecode(self.request.uri) template_values['id'] = ID template_values['factories_old'] = _factories_old template_values['workers_old'] = _workers_old template_values['badges_old'] = _badges_old template_values['unique_old'] = _product.unique template_values['name_old'] = _product.name ''' TODO: Find better way to do below. For some reason equality doesn't work implicitly. Need to explicitly check equality of key() ''' template_values['factories'] = [] for factory in _producer.getFactories(): add = True for factory_old in _factories_old: if factory_old.key() == factory.key(): add = False if add: template_values['factories'].append(factory) template_values['workers'] = [] for worker in _producer.getWorkers(): add = True for worker_old in _workers_old: if worker_old.key() == worker.key(): add = False if add: template_values['workers'].append(worker) template_values['badges'] = [] for badge in entities.Badge.all(): add = True for badge_old in _badges_old: if badge_old.key() == badge.key(): add = False if add: template_values['badges'].append(badge) path = os.path.join(os.path.dirname(__file__), 'editproduct.html') self.response.out.write(template.render(path, template_values)) return