示例#1
0
 def to_index_dict(self):
     return {
         'id': self.id,
         'api_url': url_for('entities.view', id=self.id),
         'label': self.label,
         'type': unicode(self.type)
     }
示例#2
0
 def to_dict(self):
     return {
         'id': self.id,
         'display_name': self.display_name,
         'system_role': self.system_role,
         'email': self.email,
         'api_url': url_for('users.view', id=self.id),
         'created_at': self.created_at,
         'updated_at': self.updated_at,
     }
示例#3
0
def send_validation_link(user, subject, message):
    url = url_for('validate_account', id=user.id,
                  token=user.validation_token)
    log.debug('Activation URL: %s', url)
    try:
        msg = Message(subject, recipients=[user.email])
        msg.body = message % url
        mail.send(msg)
    except Exception, e:
        log.exception(e)
示例#4
0
def status():
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': current_user.api_key if authz.logged_in() else None,
        'user': current_user if authz.logged_in() else None,
        'permissions': {
            READ: authz.system_read(),
            EDIT: authz.system_edit(),
            MANAGE: authz.system_manage()
        },
        'logout': url_for('.logout')
    })
示例#5
0
 def to_dict(self, enrich=False):
     data = {
         'id': self.id,
         'api_url': url_for('contexts.view', id=self.id),
         'created_at': self.created_at,
         'updated_at': self.updated_at,
         'source_url': self.source_url,
         'resource_name': self.resource_name,
         'active': self.active,
         'user_id': self.user_id,
         'publisher': self.publisher,
         'publisher_url': self.publisher_url
     }
     if enrich:
         data['enrich_root'] = self.enrich_root
         data['enrich_status'] = self.enrich_status
         data['enrich_score'] = self.enrich_score
     return data
示例#6
0
def update(id):
    authz.require(authz.system_edit())
    context = obj_or_404(Context.by_id(id))
    context.update(request_data())
    db.session.commit()
    return redirect(url_for('.view', id=context.id))
示例#7
0
def create():
    authz.require(authz.system_edit())
    context = Context.create(current_user, request_data())
    db.session.commit()
    return redirect(url_for('.view', id=context.id))
示例#8
0
def logout():
    logout_user()
    return redirect(request.args.get('next_url', url_for('index')))