Example #1
0
 def graph(self, id=None, id2=None, filetype="json"):
     c.entity = h.fetch_obj(Entity, id, new_id=True)
     if not id2:
         redirect(c.entity.url(filetype, action="graph"), code=303)
     else:
         c.entity2 = h.fetch_obj(Entity, new_id=True)
         redirect(c.entity.url(filetype, action="graph"), code=303)
Example #2
0
    def search(self, id, id2=None):
        # Grab ID(s) from database and get their search string(s).
        c.entity = h.fetch_obj(Entity, id)
        if id2 is None:
            c.entity2 = None
        else:
            c.entity2 = h.fetch_obj(Entity, id2)

        # creating link ID(s) for Bing + Google manual search by removing parentheses

        if c.entity2 is None:
            c.entity2_url_label = ""
        else:
            c.entity2_url_label = ((c.entity2.label).split("("))[0]

        c.entity_url_label = ((c.entity.label).split("("))[0]

        # Run searches
        try:
            c.sep = EntityController._search_sep(c.entity, c.entity2)
        except:
            c.sep = None

        try:
            c.noesis = EntityController._search_noesis(c.entity, c.entity2)
        except:
            c.noesis = None
        # c.bing = EntityController._search_bing(c.entity, c.entity2)
        return render("entity/search.html")
Example #3
0
 def graph(self, id=None, id2=None, filetype='json'):
     c.entity = h.fetch_obj(model.Entity, id, new_id=True)
     if not id2:
         redirect(c.entity.url(filetype, action="graph"), code=303)
     else:
         c.entity2 = h.fetch_obj(model.Entity, new_id=True)
         redirect(c.entity.url(filetype, action="graph"), code=303)
Example #4
0
    def _get_evaluation(self,
                        id,
                        id2,
                        uid=None,
                        username=None,
                        autoCreate=True):
        idea1 = h.fetch_obj(Idea, id, new_id=True)
        idea2 = h.fetch_obj(Idea, id2, new_id=True)

        # Get user information
        if uid:
            uid = h.fetch_obj(User, uid).ID
        elif username:
            user = h.get_user(username)
            uid = user.ID if user else abort(403)
        else:
            uid = h.get_user(request.environ['REMOTE_USER']).ID

        evaluation_q = Session.query(IdeaEvaluation)
        evaluation = evaluation_q.filter_by(ante_id=id, cons_id=id2,
                                            uid=uid).first()

        # if an evaluation does not yet exist, create one
        if autoCreate and not evaluation:
            evaluation = IdeaEvaluation(id, id2, uid)
            Session.add(evaluation)

        return evaluation
Example #5
0
    def search(self, id, id2=None):
        # Grab ID(s) from database and get their search string(s).
        c.entity = h.fetch_obj(Entity, id)
        if id2 is None:
            c.entity2 = None
        else:
            c.entity2 = h.fetch_obj(Entity, id2)
        
        #creating link ID(s) for Bing + Google manual search by removing parentheses

        if c.entity2 is None:
            c.entity2_url_label = '' 
        else:
            c.entity2_url_label = ((c.entity2.label).split('('))[0]
            

        c.entity_url_label  = ((c.entity.label).split('('))[0]       

        # Run searches
        try:
            c.sep = EntityController._search_sep(c.entity, c.entity2)
        except Exception as e:
            c.sep = None

        try:
            c.noesis = EntityController._search_noesis(c.entity, c.entity2)
        except:
            c.noesis = None
        # c.bing = EntityController._search_bing(c.entity, c.entity2)
        return render('entity/search.html')
Example #6
0
    def admin(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        c.sepdirnew = False
        c.alreadysepdir = False

        redirect = request.params.get('redirect', False)
        add = request.params.get('add', False)
        limit = request.params.get('limit', None)
        entity_q = Session.query(Entity)
        c.found = False
        c.custom = False
        c.new = False

        if request.params.get('q'):
            q = request.params['q']
            o = Entity.label.like(q)
            entity_q = entity_q.filter(o).order_by(func.length(Entity.label))
            # if only 1 result, go ahead and view that idea
            if redirect and entity_q.count() == 1:
                print "have a q, entityq count = 1"
                c.journal = h.fetch_obj(Journal, entity_q.first().ID)
                c.found = True
                id = c.journal.ID
                c.message = 'Entity edit page for journal ' + c.journal.name
                if request.params.get('entry_sep_dir'):
                    entry_sep_dir = request.params['entry_sep_dir']
                    if not (c.journal.sep_dir):
                        c.journal.sep_dir = request.params['entry_sep_dir']
                        c.sepdirnew = True
                    else:
                        c.alreadysepdir = True
                        c.entry_sep_dir = request.params['entry_sep_dir']

                return render('admin/journal-edit.html')
            else:
                print "That didn't journal."

        if id is None:
            print "I am here"
            c.message = "Please input an entity label using the search bar to the left."
            return render('admin/idea-edit.html')
        else:
            c.journal = h.fetch_obj(Journal, id)
            c.found = True
            c.message = 'Entity edit page for journal ' + c.journal.name
            if request.params.get('entry_sep_dir'):
                entry_sep_dir = request.params['entry_sep_dir']
                if not (c.journal.sep_dir):
                    c.journal.sep_dir = request.params['entry_sep_dir']
                    c.sepdirnew = True
                else:
                    c.alreadysepdir = True
                    c.entry_sep_dir = request.params['entry_sep_dir']

            return render('admin/journal-edit.html')
Example #7
0
    def admin(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)
        
        c.sepdirnew = False
        c.alreadysepdir = False

        redirect = request.params.get('redirect', False)
        add = request.params.get('add', False)
        limit = request.params.get('limit', None)
        entity_q = Session.query(Entity)
        c.found = False    
        c.custom = False
        c.new = False

        if request.params.get('q'):
            q = request.params['q']
            o = Entity.label.like(q)
            entity_q = entity_q.filter(o).order_by(func.length(Entity.label))
            # if only 1 result, go ahead and view that idea
            if redirect and entity_q.count() == 1:
                print "have a q, entityq count = 1"
                c.journal = h.fetch_obj(Journal, entity_q.first().ID)
                c.found = True
                id = c.journal.ID
                c.message = 'Entity edit page for journal ' + c.journal.name
                if request.params.get('entry_sep_dir'):
                        entry_sep_dir = request.params['entry_sep_dir']
                        if not (c.journal.sep_dir):
                            c.journal.sep_dir = request.params['entry_sep_dir']
                            c.sepdirnew = True
                        else:
                            c.alreadysepdir = True
                            c.entry_sep_dir = request.params['entry_sep_dir']
                            
                return render('admin/journal-edit.html')
            else: 
                print "That didn't journal."

        if id is None:
            print "I am here"
            c.message = "Please input an entity label using the search bar to the left."
            return render ('admin/idea-edit.html')
        else:
            c.journal = h.fetch_obj(Journal, id)
            c.found = True
            c.message = 'Entity edit page for journal ' + c.journal.name
            if request.params.get('entry_sep_dir'):
                entry_sep_dir = request.params['entry_sep_dir']
                if not (c.journal.sep_dir):
                    c.journal.sep_dir = request.params['entry_sep_dir']
                    c.sepdirnew = True
                else:
                    c.alreadysepdir = True
                    c.entry_sep_dir = request.params['entry_sep_dir']
                    
            return render ('admin/journal-edit.html') 
Example #8
0
    def _get_anon_evaluation(self, id, id2, ip, autoCreate=True):
        idea1 = h.fetch_obj(Idea, id, new_id=True)
        idea2 = h.fetch_obj(Idea, id2, new_id=True)

        evaluation_q = Session.query(AnonIdeaEvaluation)
        evaluation = evaluation_q.filter_by(ante_id=id, cons_id=id2, ip=ip).first()

        # if an evaluation does not yet exist, create one
        if autoCreate and not evaluation:
            evaluation = AnonIdeaEvaluation(id, id2,ip)
            Session.add(evaluation)

        return evaluation
Example #9
0
    def _delete_unary(self, type, id, id2=None):
        thinker = h.fetch_obj(Thinker, id)

        id2 = request.params.get('id2', id2)
        obj = h.fetch_obj(unary_vars[type]['object'], id2)

        if obj in getattr(thinker, unary_vars[type]['property']):
            getattr(thinker, unary_vars[type]['property']).remove(obj)

        Session.commit()

        response.status_int = 200
        return "OK"
Example #10
0
    def _get_anon_evaluation(self, id, id2, ip, autoCreate=True):
        idea1 = h.fetch_obj(Idea, id, new_id=True)
        idea2 = h.fetch_obj(Idea, id2, new_id=True)

        evaluation_q = Session.query(AnonIdeaEvaluation)
        evaluation = evaluation_q.filter_by(ante_id=id, cons_id=id2, ip=ip).first()

        # if an evaluation does not yet exist, create one
        if autoCreate and not evaluation:
            evaluation = AnonIdeaEvaluation(id, id2,ip)
            Session.add(evaluation)

        return evaluation
Example #11
0
    def _delete_unary(self, type, id, id2=None):
        thinker = h.fetch_obj(Thinker, id)

        id2 = request.params.get('id2', id2)
        obj = h.fetch_obj(unary_vars[type]['object'], id2)

        if obj in getattr(thinker, unary_vars[type]['property']):
            getattr(thinker, unary_vars[type]['property']).remove(obj)

        Session.commit()

        response.status_int = 200
        return "OK"
Example #12
0
    def evaluation(self, id, id2):
        c.entity = h.fetch_obj(Idea, id)
        c.entity2 = h.fetch_obj(Entity, id2)
        if isinstance(c.entity2, Node):
            c.entity2 = c.entity2.idea
            id2 = c.entity2.ID
        if not isinstance(c.entity2, Idea):
            # no evaluation implemented
            response.status_int = 501

            return ''

        c.edit = True
        c.alert = request.params.get('alert', True)
       
        # retrieve evaluation for pair
        c.generality = int(request.params.get('generality', -1))
        c.relatedness = int(request.params.get('relatedness', -1))
        
        # retrieve user information
        identity = request.environ.get('repoze.who.identity')
        c.uid = None if not identity else identity['user'].ID
        
        #TODO: Place cookie auth here
        try:
            cookie = request.params.get('cookieAuth', 'null')
            username = h.auth.get_username_from_cookie(cookie) or ''
            user = h.get_user(username)
            if user is not None:
                c.uid = user.ID

        except ValueError:
            # invalid IP, abort
            abort(403)

        # use the user's evaluation if present, otherwise a null eval
        if c.uid and (c.generality == -1 or c.relatedness == -1):
            eval_q = Session.query(IdeaEvaluation.generality, 
                                       IdeaEvaluation.relatedness)
            eval_q = eval_q.filter_by(uid=c.uid, ante_id=id, cons_id=id2)

            c.generality, c.relatedness = eval_q.first() or\
                (int(request.params.get('generality', -1)), 
                 int(request.params.get('relatedness', -1)))


        if c.relatedness != -1:
            c.edit = request.params.get('edit', False)

        return render('idea/eval.html')
Example #13
0
    def triple(self, id):

        c.entity = h.fetch_obj(Thinker, id)
        #parese the triple
        triple = request.params.get('triple').split()
        subject_t = triple[0]
        predicate_t = triple[1]
        objectURLComponents = triple[2].split('/')  #parse triple for last
        check = "no teacher or student"
        #lastComponentIndex = objectURLComponents.__len__()-1
        object_t = objectURLComponents[-1]
        #- subject is the same as the id
        #- predicate is from the list and will be used in a if/elif/elif/elif/elif ... to see what database to add it to
        if "dbpedia.org" in objectURLComponents:
            object_t_label = object_t.replace("_", " ")
            obj = Thinker(object_t_label)
            obj.wiki = object_t
        elif "inpho.cogs.indiana.edu" in objectURLComponents:
            obj = h.fetch_obj(Thinker, object_t)
        '''if(inpho):

            obj = h.fetch_obj(Thinker, object_t) # returns the SQLAlchemy object
           elif(dbpedia)
            obj = Thinker(object_t) # returns the SQLAlchemy object
        '''
        if predicate_t == 'ns1:influenced':
            c.entity.influenced.append(obj)
        elif predicate_t == 'ns1:influenced_by':
            c.entity.influenced_by.append(obj)
        elif predicate_t == 'ns1:student':
            c.entity.students.append(obj)
        elif predicate_t == 'ns1:teacher':
            c.entity.teachers.append(obj)
        '''
        elif predicate == 'profession':

        elif predicate == 'birth_date':

        elif predicate == 'death_date':

        else predicate == 'nationality':
        '''

        Session.commit()
        subject_to_display = subject_t.split("/")[len(subject_t.split("/")) -
                                                  1]
        predicate_to_display = predicate_t.split(":")[1]
        object_to_display = object_t
        return "OK : " + subject_to_display + " " + predicate_to_display + " " + object_to_display
Example #14
0
    def evaluation(self, id, id2):
        c.entity = h.fetch_obj(Idea, id)
        c.entity2 = h.fetch_obj(Entity, id2)
        if isinstance(c.entity2, Node):
            c.entity2 = c.entity2.idea
            id2 = c.entity2.ID
        if not isinstance(c.entity2, Idea):
            # no evaluation implemented
            response.status_int = 501

            return ''

        c.edit = True
        c.alert = request.params.get('alert', True)

        # retrieve evaluation for pair
        c.generality = int(request.params.get('generality', -1))
        c.relatedness = int(request.params.get('relatedness', -1))

        # retrieve user information
        identity = request.environ.get('repoze.who.identity')
        c.uid = None if not identity else identity['user'].ID

        #TODO: Place cookie auth here
        try:
            cookie = request.params.get('cookieAuth', 'null')
            username = h.auth.get_username_from_cookie(cookie) or ''
            user = h.get_user(username)
            if user is not None:
                c.uid = user.ID

        except ValueError:
            # invalid IP, abort
            abort(403)

        # use the user's evaluation if present, otherwise a null eval
        if c.uid and (c.generality == -1 or c.relatedness == -1):
            eval_q = Session.query(IdeaEvaluation.generality,
                                   IdeaEvaluation.relatedness)
            eval_q = eval_q.filter_by(uid=c.uid, ante_id=id, cons_id=id2)

            c.generality, c.relatedness = eval_q.first() or\
                (int(request.params.get('generality', -1)),
                 int(request.params.get('relatedness', -1)))

        if c.relatedness != -1:
            c.edit = request.params.get('edit', False)

        return render('idea/eval.html')
Example #15
0
    def panel(self, id, id2): 
        c.entity = h.fetch_obj(Entity, id)
        c.entity2 = h.fetch_obj(Entity, id2)

        # redirection for Idea-Idea panels
        if isinstance(c.entity, Node):
            c.entity = c.entity.idea
            id = c.entity.ID
        if isinstance(c.entity2, Node):
            c.entity2 = c.entity2.idea
            id = c.entity2.ID
        if isinstance(c.entity, Idea) and isinstance(c.entity2, Idea):
            h.redirect(c.entity.url(action='panel', id2=id2), code=303)
        
        return self.search(id, id2)
Example #16
0
    def panel(self, id, id2):
        c.entity = h.fetch_obj(Entity, id)
        c.entity2 = h.fetch_obj(Entity, id2)

        # redirection for Idea-Idea panels
        if isinstance(c.entity, Node):
            c.entity = c.entity.idea
            id = c.entity.ID
        if isinstance(c.entity2, Node):
            c.entity2 = c.entity2.idea
            id = c.entity2.ID
        if isinstance(c.entity, Idea) and isinstance(c.entity2, Idea):
            h.redirect(c.entity.url(action="panel", id2=id2), code=303)

        return self.search(id, id2)
Example #17
0
    def triple(self, id):
    
        c.entity = h.fetch_obj(Thinker, id)
        #parese the triple
        triple = request.params.get('triple').split()
        subject_t = triple[0]
        predicate_t = triple[1]
        objectURLComponents = triple[2].split('/')#parse triple for last
        check = "no teacher or student"
        #lastComponentIndex = objectURLComponents.__len__()-1
        object_t = objectURLComponents[-1]
        #- subject is the same as the id
        #- predicate is from the list and will be used in a if/elif/elif/elif/elif ... to see what database to add it to
        if "dbpedia.org" in objectURLComponents:
            object_t_label = object_t.replace("_"," ")
            obj = Thinker(object_t_label)
            obj.wiki = object_t
        elif "inpho.cogs.indiana.edu" in objectURLComponents:
            obj = h.fetch_obj(Thinker, object_t) 
        '''if(inpho):

            obj = h.fetch_obj(Thinker, object_t) # returns the SQLAlchemy object
           elif(dbpedia)
            obj = Thinker(object_t) # returns the SQLAlchemy object
        '''
        if predicate_t == 'ns1:influenced':
             c.entity.influenced.append(obj)
        elif predicate_t == 'ns1:influenced_by':
            c.entity.influenced_by.append(obj)
        elif predicate_t =='ns1:student':
            c.entity.students.append(obj)
        elif predicate_t == 'ns1:teacher':
            c.entity.teachers.append(obj)
        '''
        elif predicate == 'profession':

        elif predicate == 'birth_date':

        elif predicate == 'death_date':

        else predicate == 'nationality':
        '''
	
        Session.commit()
	subject_to_display=subject_t.split("/")[len(subject_t.split("/"))-1]
	predicate_to_display=predicate_t.split(":")[1]
	object_to_display=object_t
        return "OK : "+subject_to_display+" "+predicate_to_display+" "+object_to_display
Example #18
0
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        c.thinker = h.fetch_obj(Thinker, id)
        
        return render('thinker/thinker-edit.html')
Example #19
0
    def evaluate(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        c.idea = h.fetch_obj(Idea, id, new_id=True)
        node_q = Session.query(Node).filter_by(concept_id=id)
        c.node = node_q.first()
        if request.environ.get('REMOTE_USER', False):
            user = h.get_user(request.environ['REMOTE_USER'])

            sq = Session.query(IdeaEvaluation.cons_id)
            sq = sq.filter(IdeaEvaluation.ante==c.idea)
            sq = sq.filter(IdeaEvaluation.uid==user.ID)
            sq = sq.subquery()

            to_evaluate = c.idea.related.outerjoin((sq, Idea.ID==sq.c.cons_id))
            to_evaluate = to_evaluate.filter(sq.c.cons_id==None)

        else:
            to_evaluate = c.idea.related

        c.paginator = paginate.Page(
            to_evaluate,
            page=int(request.params.get('page', 1)),
            items_per_page=10,
            controller='idea',
            action='edit',
            id=id
        )


        return render('idea/idea-edit.html')
Example #20
0
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        c.thinker = h.fetch_obj(Thinker, id)

        return render('thinker/thinker-edit.html')
Example #21
0
    def _list_property(self,
                       property,
                       id,
                       filetype='html',
                       limit=False,
                       sep_filter=False,
                       type='idea'):
        c.idea = h.fetch_obj(Idea, id)

        limit = int(request.params.get('limit', limit))
        start = int(request.params.get('start', 0))
        sep_filter = request.params.get('sep_filter', sep_filter)
        property = getattr(c.idea, property)
        if sep_filter:
            property = property.filter(Entity.sep_dir != '')

        # TODO: Fix hacky workaround for the AppenderQuery vs. Relationship
        # property issue - upgrading SQLAlchemy may fix this by allowing us to
        # use len() in a smart way.
        try:
            c.total = property.count()
        except TypeError:
            c.total = len(property)

        if limit:
            property = property[start:start + limit]

        c.entities = property
        c.nodes = Session.query(Node).filter(
            Node.parent_id == None).order_by("name").all()
        return render('%s/%s-list.%s' % (type, type, filetype))
Example #22
0
 def _list_property(self, property, id, filetype='html', limit=False, sep_filter=False, type='idea'):
     c.idea = h.fetch_obj(Idea, id)
      
     limit = int(request.params.get('limit', limit))
     start = int(request.params.get('start', 0))
     sep_filter = request.params.get('sep_filter', sep_filter)
     property = getattr(c.idea, property)
     if sep_filter:
         property = property.filter(Entity.sep_dir != '')
     
     # TODO: Fix hacky workaround for the AppenderQuery vs. Relationship
     # property issue - upgrading SQLAlchemy may fix this by allowing us to
     # use len() in a smart way.
     try:
         c.total = property.count()
     except TypeError:
         c.total = len(property)
         
      
     if limit:
         property = property[start:start+limit]
     
     c.entities = property
     c.nodes = Session.query(Node).filter(Node.parent_id == None).order_by("name").all()
     return render('%s/%s-list.%s' %(type, type, filetype))
Example #23
0
    def first_order(self,
                    id=None,
                    filetype='html',
                    limit=False,
                    sep_filter=False):

        c.idea = h.fetch_obj(Idea, id)

        limit = request.params.get('limit', limit)
        sep_filter = request.params.get('sep_filter', sep_filter)
        children = [child for ins in c.idea.nodes for child in ins.children]
        parents = [ins.parent for ins in c.idea.nodes if ins.parent]
        siblings = [child for ins in parents for child in ins.children]

        c.entities = []
        c.entities.extend(parents)
        c.entities.extend(children)
        c.entities.extend(siblings)

        if sep_filter:
            c.entities = [i.idea for i in c.entities if i.idea.sep_dir]
        else:
            c.entities = [i.idea for i in c.entities]

        if c.idea in c.entities:
            c.entities.remove(c.idea)

        c.total = len(c.entities)

        #c.nodes = Session.query(Node).filter_by(parent_id=0).order_by("Name")
        return render('idea/idea-list.' + filetype)
Example #24
0
    def _list_property(self,
                       property,
                       id,
                       filetype='html',
                       limit=False,
                       sep_filter=False,
                       type='thinker'):
        c.thinker = h.fetch_obj(Thinker, id)

        limit = int(request.params.get('limit', limit))
        start = int(request.params.get('start', 0))
        sep_filter = request.params.get('sep_filter', sep_filter)
        property = getattr(c.thinker, property)
        if sep_filter:
            property = property.filter(Entity.sep_dir != '')

        try:
            c.total = property.count()
        except TypeError:
            c.total = len(property)

        if limit:
            property = property[start:start + limit]

        c.entities = property
        return render('%s/%s-list.%s' % (type, type, filetype))
Example #25
0
    def first_order(self, id=None, filetype='html', limit=False,
                    sep_filter=False):

        c.idea = h.fetch_obj(Idea, id)
         
        limit = request.params.get('limit', limit)
        sep_filter = request.params.get('sep_filter', sep_filter)
        children = [child for ins in c.idea.nodes 
                        for child in ins.children] 
        parents = [ins.parent for ins in c.idea.nodes if ins.parent]
        siblings = [child for ins in parents
                          for child in ins.children]

        c.ideas = []
        c.ideas.extend(parents)
        c.ideas.extend(children)
        c.ideas.extend(siblings) 

        if sep_filter:
            c.ideas = [i.idea for i in c.ideas if i.idea.sep_dir]
        else:
            c.ideas = [i.idea for i in c.ideas]

        if c.idea in c.ideas: 
            c.ideas.remove(c.idea)

        #c.nodes = Session.query(Node).filter_by(parent_id=0).order_by("Name")
        return render('idea/idea-list.' + filetype)
Example #26
0
    def evaluate(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        c.idea = h.fetch_obj(Idea, id, new_id=True)
        node_q = Session.query(Node).filter_by(concept_id=id)
        c.node = node_q.first()
        if request.environ.get('REMOTE_USER', False):
            user = h.get_user(request.environ['REMOTE_USER'])

            sq = Session.query(IdeaEvaluation.cons_id)
            sq = sq.filter(IdeaEvaluation.ante == c.idea)
            sq = sq.filter(IdeaEvaluation.uid == user.ID)
            sq = sq.subquery()

            to_evaluate = c.idea.related.outerjoin(
                (sq, Idea.ID == sq.c.cons_id))
            to_evaluate = to_evaluate.filter(sq.c.cons_id == None)

        else:
            to_evaluate = c.idea.related

        c.paginator = paginate.Page(to_evaluate,
                                    page=int(request.params.get('page', 1)),
                                    items_per_page=10,
                                    controller='idea',
                                    action='edit',
                                    id=id)

        response.headers['Access-Control-Allow-Origin'] = '*'

        return render('idea/idea-edit.html')
    def view(self, id, filetype='html'):
        sep_filter = request.params.get('sep_filter', False)
        c.sep_filter = sep_filter

        c.school_of_thought = h.fetch_obj(model.SchoolOfThought,
                                          id,
                                          new_id=True)
        return render('school_of_thought/school_of_thought.%s' % filetype)
Example #28
0
    def url(self, id=None, url=None):
        # Get entity and render template
        entity = h.fetch_obj(self._type, id, new_id=True)

        if entity.check_url():
            return "200 OK"
        else:
            abort(404)
Example #29
0
    def url(self, id=None, url=None):
        # Get entity and render template
        entity = h.fetch_obj(self._type, id, new_id=True)

        if entity.check_url():
            return "200 OK"
        else:
            abort(404)
Example #30
0
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        c.school_of_thought = h.fetch_obj(SchoolOfThought, id)

        return render('school_of_thought/school_of_thought-edit.html')
Example #31
0
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        c.work = h.fetch_obj(Work, id)
        
        return render('work/work-edit.html')
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        c.school_of_thought = h.fetch_obj(SchoolOfThought, id)

        return render('school_of_thought/school_of_thought-edit.html')
Example #33
0
    def view(self, id, filetype='html'):
        sep_filter = request.params.get('sep_filter', False) 
        c.sep_filter = sep_filter

        if filetype=='json':
            response.content_type = 'application/json'

        c.work = h.fetch_obj(Work, id, new_id=True)
        return render('work/work.%s' % filetype)
Example #34
0
    def graph(self, id=None, filetype='nwb', limit=False):
        c.sep_filter = request.params.get('sep_filter', False) 
        c.n = int(request.params.get('n', 8))
        c.recur = int(request.params.get('recur', 3))
        c.thresh = float(request.params.get('thresh', 0))

        c.idea = h.fetch_obj(Idea, id, new_id=True)
        
        return render('idea/graph.' + filetype)
Example #35
0
    def view(self, id, filetype='html'):
        sep_filter = request.params.get('sep_filter', False) 
        c.sep_filter = sep_filter

        if filetype=='json':
            response.content_type = 'application/json'

        c.thinker = h.fetch_obj(Thinker, id, new_id=True)
        return render('thinker/thinker.%s' % filetype)
Example #36
0
    def view(self, id, filetype='html'):
        sep_filter = request.params.get('sep_filter', False) 
        c.sep_filter = sep_filter

        if filetype=='json':
            response.content_type = 'application/json'

        c.school_of_thought = h.fetch_obj(model.SchoolOfThought, id, new_id=True)
        return render('school_of_thought/school_of_thought.%s' % filetype)
Example #37
0
    def edit(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        c.work = h.fetch_obj(Work, id)

        return render('work/work-edit.html')
Example #38
0
    def graph(self, id=None, filetype='nwb', limit=False):
        c.sep_filter = request.params.get('sep_filter', False)
        c.n = int(request.params.get('n', 8))
        c.recur = int(request.params.get('recur', 3))
        c.thresh = float(request.params.get('thresh', 0))

        c.idea = h.fetch_obj(Idea, id, new_id=True)

        return render('idea/graph.' + filetype)
Example #39
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        idea = h.fetch_obj(Idea, id, new_id=True)
        terms = ['sep_dir'] 

        h.update_obj(idea, terms, request.params)

        return self.view(id)
Example #40
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)

        idea = h.fetch_obj(Idea, id, new_id=True)
        terms = ['sep_dir'] 

        h.update_obj(idea, terms, request.params)

        return self.view(id)
Example #41
0
    def _delete_date(self, id, id2):
        c.entity = h.fetch_obj(Entity, id, new_id=True)
        # get the date object
        date = self._get_date(id, id2)

        if date in c.entity.dates:
            idx = c.entity.dates.index(date)
            Session.delete(c.entity.dates[idx])
            Session.commit()
        
        return "OK"
Example #42
0
    def _delete_date(self, id, id2):
        c.entity = h.fetch_obj(Entity, id, new_id=True)
        # get the date object
        date = self._get_date(id, id2)

        if date in c.entity.dates:
            idx = c.entity.dates.index(date)
            Session.delete(c.entity.dates[idx])
            Session.commit()

        return "OK"
Example #43
0
    def view(self, id, filetype='html'):
        sep_filter = request.params.get('sep_filter', False)
        c.sep_filter = sep_filter

        if filetype == 'json':
            response.content_type = 'application/json'

        c.school_of_thought = h.fetch_obj(model.SchoolOfThought,
                                          id,
                                          new_id=True)
        return render('school_of_thought/school_of_thought.%s' % filetype)
Example #44
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        thinker = h.fetch_obj(Thinker, id)
        terms = ['sep_dir', 'wiki'] 

        h.update_obj(thinker, terms, request.params)

        return self.view(id)
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        school_of_thought = h.fetch_obj(SchoolOfThought, id)
        terms = ['sep_dir']

        h.update_obj(school_of_thought, terms, request.params)

        return self.view(id)
Example #46
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        thinker = h.fetch_obj(Thinker, id)
        terms = ['sep_dir', 'wiki']

        h.update_obj(thinker, terms, request.params)

        return self.view(id)
Example #47
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        journal = h.fetch_obj(Journal, id)
        terms = ['openAccess', 'URL', 'ISSN', 'noesisInclude', 'student', 'active']

        h.update_obj(journal, terms, request.params)

        return self.view(id)
Example #48
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        work = h.fetch_obj(model.Work, id)
        terms = ['sep_dir'] 

        h.update_obj(work, terms, request.params)

        return self.view(id)
Example #49
0
    def update(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        school_of_thought = h.fetch_obj(SchoolOfThought, id)
        terms = ['sep_dir'] 

        h.update_obj(school_of_thought, terms, request.params)

        return self.view(id)
Example #50
0
    def delete(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        idea = h.fetch_obj(Idea, id, new_id=True)
        
        h.delete_obj(idea)

        # Issue an HTTP success
        response.status_int = 200
        return "OK"
Example #51
0
    def delete(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        idea = h.fetch_obj(Idea, id, new_id=True)
        
        h.delete_obj(idea)

        # Issue an HTTP success
        response.status_int = 200
        return "OK"
Example #52
0
    def delete(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        journal = h.fetch_obj(Journal, id)

        h.delete_obj(journal)

        # Issue an HTTP success
        response.status_int = 200
        return "OK"
Example #53
0
    def delete(self, id=None):
        if not h.auth.is_logged_in():
            abort(401)
        if not h.auth.is_admin():
            abort(403)

        journal = h.fetch_obj(Journal, id)
        
        h.delete_obj(journal)

        # Issue an HTTP success
        response.status_int = 200
        return "OK"
Example #54
0
    def related_entries(self, id, filetype="html"):
        c.entity = h.fetch_obj(Entity, id)

        related = sep.get_related()
        related = related[c.entity.sep_dir]

        c.entities = []
        for sep_dir in related:
            entity = Session.query(Entity).filter(Entity.sep_dir == sep_dir).first()
            if entity is not None:
                c.entities.append(entity)

        return render("entity/entity-list.%s" % (filetype))
Example #55
0
    def _get_evaluation(self, id, id2, uid=None, username=None, 
                        autoCreate=True):
        idea1 = h.fetch_obj(Idea, id, new_id=True)
        idea2 = h.fetch_obj(Idea, id2, new_id=True)

        # Get user information
        if uid:
            uid = h.fetch_obj(User, uid).ID
        elif username:
            user = h.get_user(username)
            uid = user.ID if user else abort(404)
        else:
            uid = h.get_user(request.environ['REMOTE_USER']).ID

        evaluation_q = Session.query(IdeaEvaluation)
        evaluation = evaluation_q.filter_by(ante_id=id, cons_id=id2, uid=uid).first()

        # if an evaluation does not yet exist, create one
        if autoCreate and not evaluation:
            evaluation = IdeaEvaluation(id, id2, uid)
            Session.add(evaluation)

        return evaluation
Example #56
0
    def searchpatterns(self, id):
        c.entity = h.fetch_obj(Entity, id, new_id=True)

        # add a new search pattern
        pattern = request.params.get('pattern', None)
        if pattern is None:
            abort(400)
        
        if pattern not in c.entity.searchpatterns:
            c.entity.searchpatterns.append(unicode(pattern))

            Session.commit()

        return "OK"
Example #57
0
 def _list_property(self, property, id, filetype='html', limit=False, sep_filter=False, type='idea'):
     c.idea = h.fetch_obj(Idea, id)
      
     limit = request.params.get('limit', limit)
     sep_filter = request.params.get('sep_filter', sep_filter)
     property = getattr(c.idea, property)
     if sep_filter:
         property = property.filter(Entity.sep_dir != '')
     if limit:
         property = property[0:limit-1]
     
     c.ideas = property
     c.nodes = Session.query(Node).filter(Node.parent_id == None).order_by("name").all()
     return render('%s/%s-list.%s' %(type, type, filetype))
Example #58
0
    def update(self, id=None):
        terms = ['label', 'sep_dir', 'last_accessed', 'language', 'openAccess', 'active', 'student', 'ISSN']

        URL = request.params.get('URL', None)
        if URL is not None:
            journal = h.fetch_obj(Journal, id)
            if URL == 'none' or URL == 'None':
                journal.URL = None
            else:
                journal.URL = unquote(URL)
                journal.check_url()
            Session.commit()

        super(JournalController, self).update(id, terms)
Example #59
0
 def _list_property(self, property, id, filetype='html', limit=False, sep_filter=False, type='idea'):
     c.idea = h.fetch_obj(Idea, id)
      
     limit = request.params.get('limit', limit)
     sep_filter = request.params.get('sep_filter', sep_filter)
     property = getattr(c.idea, property)
     if sep_filter:
         property = property.filter(Entity.sep_dir != '')
     if limit:
         property = property[0:limit-1]
     
     c.ideas = property
     c.nodes = Session.query(Node).filter(Node.parent_id == None).order_by("name").all()
     return render('%s/%s-list.%s' %(type, type, filetype))