Exemplo n.º 1
0
 def post(self):
     add_prospect_form = ProviderProspectForm().get_form(self.request.POST, request_webob=self.request)
     if add_prospect_form.validate():
         provider_prospect = ProviderProspect()
         add_prospect_form.populate_obj(provider_prospect)
         provider_prospect.put()
         self.redirect("/admin/prospects")
     else:
         # validate failed
         self.render_prospect_list(add_prospect_form=add_prospect_form)
Exemplo n.º 2
0
 def post(self):
     add_prospect_form = ProviderProspectForm().get_form(
         self.request.POST, request_webob=self.request)
     if add_prospect_form.validate():
         provider_prospect = ProviderProspect()
         add_prospect_form.populate_obj(provider_prospect)
         provider_prospect.put()
         self.redirect("/admin/prospects")
     else:
         # validate failed
         self.render_prospect_list(add_prospect_form=add_prospect_form)
Exemplo n.º 3
0
Arquivo: db.py Projeto: phiiil/veosan
def fetch_page_of_provider_prospects(cursor_key=None,
                                     page_size=50,
                                     search_keyword=None):
    ''' 
        Returns three values: prospects, next_curs, prev_curs
        
        Search uses a workaround to imitate LIKE:
        http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query
    
    '''
    cursor = Cursor(urlsafe=cursor_key)
    if search_keyword:
        limit = search_keyword + u"\ufffd"
        query = ProviderProspect.query(
            ProviderProspect.last_name >= search_keyword,
            ProviderProspect.last_name < limit)

        query = query.order(ProviderProspect.last_name)
    else:
        query = ProviderProspect.query()
    # forward and back
    forward_query = query.order(ProviderProspect.category,
                                ProviderProspect.last_name,
                                ProviderProspect.key)
    backward_query = query.order(-ProviderProspect.category,
                                 -ProviderProspect.last_name,
                                 -ProviderProspect.key)
    # fetch next
    prospects, next_curs, more = forward_query.fetch_page(page_size,
                                                          start_cursor=cursor)
    logging.info('next_curs: %s  more: %s' % (next_curs, more))
    # fetch prev (just to get cursor position)
    if cursor_key:
        reversed_cursor = cursor.reversed()
        prev_prospects, prev_curs, prev_more = backward_query.fetch_page(
            page_size, start_cursor=reversed_cursor)
        # reverse the cursor (GAE docs is wrong on this)
        if prev_curs:
            prev_curs = prev_curs.reversed()
    else:
        prev_curs = None
        prev_more = None

    if not more:
        next_curs = None

    #if not prev_more:
    #    prev_curs = None
    return prospects, next_curs, prev_curs
Exemplo n.º 4
0
Arquivo: db.py Projeto: deltron/veosan
def fetch_page_of_provider_prospects(cursor_key=None, page_size=50, search_keyword=None):
    ''' 
        Returns three values: prospects, next_curs, prev_curs
        
        Search uses a workaround to imitate LIKE:
        http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query
    
    '''
    cursor = Cursor(urlsafe=cursor_key)
    if search_keyword:
        limit = search_keyword + u"\ufffd"
        query = ProviderProspect.query(ProviderProspect.last_name >= search_keyword, ProviderProspect.last_name < limit)
        
        query = query.order(ProviderProspect.last_name)
    else:
        query = ProviderProspect.query()
    # forward and back
    forward_query = query.order(ProviderProspect.category, ProviderProspect.last_name, ProviderProspect.key)
    backward_query = query.order(-ProviderProspect.category, -ProviderProspect.last_name, -ProviderProspect.key)
    # fetch next
    prospects, next_curs, more = forward_query.fetch_page(page_size, start_cursor=cursor)
    logging.info('next_curs: %s  more: %s' % (next_curs, more))
    # fetch prev (just to get cursor position)
    if cursor_key:
        reversed_cursor = cursor.reversed()
        prev_prospects, prev_curs, prev_more = backward_query.fetch_page(page_size, start_cursor=reversed_cursor)
        # reverse the cursor (GAE docs is wrong on this)
        if prev_curs:
            prev_curs = prev_curs.reversed()
    else:
        prev_curs = None
        prev_more = None
    
    if not more:
        next_curs = None

    #if not prev_more:
    #    prev_curs = None
    return prospects, next_curs, prev_curs
Exemplo n.º 5
0
def create_prospect(**args):
    pp = ProviderProspect(**args)
    pp.put()
Exemplo n.º 6
0
Arquivo: db.py Projeto: phiiil/veosan
def get_prospect_from_prospect_id(prospect_id):
    if prospect_id:
        return ProviderProspect.query(
            ProviderProspect.prospect_id == prospect_id).get()
    else:
        return None
Exemplo n.º 7
0
Arquivo: db.py Projeto: phiiil/veosan
def get_provider_prospect_from_email(email):
    prospect = ProviderProspect.query(ProviderProspect.email == email).get()
    logging.debug('ProviderProspect for email %s is %s' % (email, prospect))
    return prospect
Exemplo n.º 8
0
Arquivo: db.py Projeto: phiiil/veosan
def fetch_prospects():
    return ProviderProspect.query().order(ProviderProspect.last_name,
                                          ProviderProspect.first_name)
Exemplo n.º 9
0
Arquivo: db.py Projeto: deltron/veosan
def fetch_prospects():
    return ProviderProspect.query().order(ProviderProspect.last_name, ProviderProspect.first_name)
Exemplo n.º 10
0
Arquivo: db.py Projeto: deltron/veosan
def get_prospect_from_prospect_id(prospect_id):
    if prospect_id:
        return ProviderProspect.query(ProviderProspect.prospect_id == prospect_id).get()
    else:
        return None  
Exemplo n.º 11
0
Arquivo: db.py Projeto: deltron/veosan
def get_provider_prospect_from_email(email):
    prospect = ProviderProspect.query(ProviderProspect.email == email).get()
    logging.debug('ProviderProspect for email %s is %s' % (email, prospect))
    return prospect
Exemplo n.º 12
0
def create_prospect(**args):
    pp = ProviderProspect(**args)
    pp.put()