Exemple #1
0
def workspace_test():
	print_data('workspaces objects', br=False)

	for index in range(3):
		w = Workspace()
		w.name = 'New workspace name'
		w.description = 'Some new description'
		w.save()

	workspaces = Workspace.all()
	print_data('new objects -> model.all()', workspaces)

	w.name = 'Updated name'
	w.save()

	workspaces = Workspace.all()
	print_data('UPDATED -> model.all()', workspaces)

	workspaces = Workspace.get(id=w.id, name=w.name)
	print_data('GET -> model.get()', [workspaces])

	workspaces = Workspace.filter(name='New workspace name')
	print_data('FILTER -> model.filter()', workspaces)

	for index in range(2):
		o = Application()
		o.workspace_id = w.guid
		o.save()

	a = View()
	a.application_id = o.guid
	a.save()

	a = Resource()
	a.application_id = o.guid
	a.save()

	for index in range(3):
		o = Widget()
		o.workspace_id = w.guid
		o.save()

	for index in range(3):
		o = DataSource()
		o.workspace_id = w.guid
		o.save()

	objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all()
	print_data('All objects in db', objects)

#	[w.delete() for w in Workspace.all()]
	workspaces = Workspace.all()
	print_data('cleaned', workspaces)

	workspaces = Workspace.filter(include_deleted=True)
	print_data('cleaned with deleted if exists', workspaces)

	objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all()
	print_data('no objects left', objects)
Exemple #2
0
 def get(self, **kwargs): 
     admin = False 
     user =  self.current_user  
     page_id = kwargs.get('pageid')
     options_dict = {}
     try:
         pages = Page.get(user.pages)
         for p in pages:
             if p.id == page_id:
                 admin = True
                 page = p
                 widgets = Widget.all().filter('page =', page).filter('deleted = ', False).order('order')
                 options = Option.all().filter('type_reference =', page)
                 for option in options:
                     options_dict[option.name] = {'id': str(option.key().id()), 'value': option.value}
                 
     except:
         page = None
         widgets = None
         options_dict = None
     if admin:
         #page = Page.get_by_key_name(str(page_id))
         #add_app_url = 'https://www.facebook.com/add.php?api_key=a284fdd504b5191923362afabc0ea6c7&pages=1&page=141947329155355'
         upload_url = blobstore.create_upload_url('/upload')
         page_id = encrypt(page_id).encode('hex')
         self.render("app/edit.html", admin=True, page=page,upload_url=upload_url, page_id=page_id,widgets= widgets, options=options_dict) 
     else:
         self.redirect('/dashboard')
Exemple #3
0
 def get(self, **kwargs):
     page_id = self.request.get('page_id')
     try:
         page = Page.get_by_key_name(page_id)
         widgets = Widget.all().filter('page =', page).filter('deleted = ', False).order('order')
     except:
         page=None
         widgets=None
     self.render("app/fb-tab.html", page=page,widgets=widgets, method="get")
Exemple #4
0
def widget_test():
	print_data('widgets objects', br=False)
	workspaces = []
	for index in range(3):
		w = Workspace()
		w.name = 'New workspace name'
		w.description = 'Some new description'
		w.save()
		workspaces.append(w)

	for index in range(3):
		w = Widget()
		w.source = '<source>some stuff</source>'
		w.workspace_id = workspaces[0].guid if index in [0, 1] else workspaces[1].guid
		w.save()

	widgets = Widget.all()
	print_data('new objects -> model.all()', widgets)

	w.source = '<b>UDPATED</b>'
	w.save()
	w.reload()

	print_data('UPDATED', [w.source])

	widgets = Widget.get(id=w.id)
	print_data('GET -> model.get()', [widgets])

	widgets = Widget.filter(source='<source>some stuff</source>')
	print_data('FILTER -> model.filter()', widgets)

	for index, w in enumerate(workspaces):
		widgets = w.widgets
		print_data('workspace %s -> workspace.widgets' % str(index), widgets)

	[w.delete() for w in Widget.all()]
	objects = Widget.all() + Workspace.all()
	print_data('cleaned', objects)

	widgets = Widget.filter(include_deleted=True)
	print_data('cleaned with deleted if exists', widgets)
Exemple #5
0
    def post(self, **kwargs):
        #logging.info(self.request)
        signed_request = facebook.parse_signed_request(self.request.get('signed_request'),self.get_config('facebook','app_secret'))
        #logging.info(signed_request)
        try:
          user_id = signed_request['user_id']
        except:
          user_id = None
        page_id = signed_request['page']['id']
        liked = signed_request['page']['liked']
        admin = signed_request['page']['admin']
        options_dict = {}
        status = 'True'
        try:
          page = Page.get_by_key_name(page_id)
          #check active account or for expired account.
          if page.upgraded != '1':

            expire_date = page.created + datetime.timedelta(days=14)
            min_expire_date = datetime.datetime(2011,5,1)
        
            if (expire_date < min_expire_date):
              expire_date = min_expire_date

            if expire_date < datetime.datetime.now():
              status = 'False'

          
          
          widgets = Widget.all().filter('page =', page).filter('deleted = ', False).order('order')
          options = Option.all().filter('type_reference =', page)
          for option in options:
              options_dict[option.name] = {'id': str(option.key().id()), 'value': option.value}
        except:
          page=None
          widgets=None
          options_dict = None
        self.render("app/fb-tab.html", page=page,widgets=widgets, method="post",options=options_dict,admin=admin,status=status)