def get(self, user):
        """Get all institutions."""
        INSTITUTION_ATTRIBUTES = [
            'name', 'key', 'acronym', 'address', 'photo_url', 'description',
            'admin', 'cover_photo', 'institutional_email'
        ]
        ACTIVE_STATE = "active"

        page = to_int(
            self.request.get('page', Utils.DEFAULT_PAGINATION_OFFSET),
            QueryException, "Query param page must be an integer")
        limit = to_int(
            self.request.get('limit', Utils.DEFAULT_PAGINATION_LIMIT),
            QueryException, "Query param limit must be an integer")

        queryInstitutions = Institution.query(
            Institution.state == ACTIVE_STATE)

        queryInstitutions, more = offset_pagination(page, limit,
                                                    queryInstitutions)

        array = [
            institution.make(INSTITUTION_ATTRIBUTES)
            for institution in queryInstitutions
        ]

        data = {'institutions': array, 'next': more}

        self.response.write(json.dumps(data))
Ejemplo n.º 2
0
    def get(self):

        self.templateVars["institutions"] = Institution.query().fetch()
        self.templateVars["authors"] = Author.query().fetch()
        self.templateVars["conferences"] = Conference.query().fetch()
        self.templateVars["publications"] = Publication.query().fetch()
        self.templateVars["contents"] = Content.query().fetch()
        return self.render("admin.html")
Ejemplo n.º 3
0
def clear_data_store():
    # Clean the Datastore
    users = User.query().fetch(keys_only=True)
    ndb.delete_multi(users)

    posts = Post.query().fetch(keys_only=True)
    ndb.delete_multi(posts)

    institutions = Institution.query().fetch(keys_only=True)
    ndb.delete_multi(institutions)

    invites = Invite.query().fetch(keys_only=True)
    ndb.delete_multi(invites)

    events = Event.query().fetch(keys_only=True)
    ndb.delete_multi(events)

    index_institution = search.Index(name=INDEX_INSTITUTION)
    delete_all_in_index(index_institution)
    index_user = search.Index(name=INDEX_USER)
    delete_all_in_index(index_user)