Exemplo n.º 1
0
    def post(self):

        if UserManager.get_current_user() == None:
            self.redirect('/user-not-found')
            return

        delete_message = 'ok'

        project_key_string = self.request.get('project-key')

        if (project_key_string == '' or project_key_string == None):
            delete_message = 'No project key provided'
        else:

            project = Project.get_by_id(int(project_key_string))

            if UserManager.get_user_has_privilege_for_operation(project):

                project_key = ndb.Key(Project, project.key.integer_id())
                actions = Action.query(ancestor=project_key)

                # Start with the project
                to_delete = [project.key]

                # No find all its actions
                for action in actions:

                    # Add those to the list
                    to_delete.append(action.key)

                    # Now get all the action details
                    action_detail_key = ndb.Key(Project,
                                                project.key.integer_id(),
                                                Action,
                                                action.key.integer_id())

                    action_details = ActionDetail.query(
                        ancestor=action_detail_key)

                    for action_detail in action_details:
                        to_delete.append(action_detail.key)

                ndb.delete_multi(to_delete)

            else:
                delete_message = 'Permission denied.'

        template = JINJA_ENVIRONMENT.get_template(
            'templates/_endpoints/action-update.json')
        self.response.write(template.render({"message": delete_message}))
Exemplo n.º 2
0
  def post(self):

    if UserManager.get_current_user() == None:
      self.redirect('/user-not-found')
      return

    delete_message = 'ok'

    project_key_string = self.request.get('project-key')

    if (project_key_string == '' or project_key_string == None):
      delete_message = 'No project key provided'
    else:

      project = Project.get_by_id(int(project_key_string))

      if UserManager.get_user_has_privilege_for_operation(project):

        project_key = ndb.Key(Project, project.key.integer_id())
        actions = Action.query(ancestor=project_key)

        # Start with the project
        to_delete = [project.key]

        # No find all its actions
        for action in actions:

          # Add those to the list
          to_delete.append(action.key)

          # Now get all the action details
          action_detail_key = ndb.Key(
            Project, project.key.integer_id(),
            Action, action.key.integer_id()
          )

          action_details = ActionDetail.query(ancestor=action_detail_key)

          for action_detail in action_details:
            to_delete.append(action_detail.key)

        ndb.delete_multi(to_delete)

      else:
        delete_message = 'Permission denied.'

    template = JINJA_ENVIRONMENT.get_template('templates/_endpoints/action-update.json')
    self.response.write(template.render({
      "message": delete_message
    }))
Exemplo n.º 3
0
    def get(self, key):

        if UserManager.get_current_user() == None:
            self.redirect('/user-not-found')
            return

        project = Project.get_by_id(int(key))

        if project == None:
            self.redirect('/')
            return

        if not UserManager.get_user_has_privilege_for_operation(project):
            self.redirect('/')
            return

        project_key = ndb.Key(Project, int(key))
        template_path = 'templates/project/action.html'
        data = {
            'project_key':
            key,
            'project_secret':
            project.secret,
            'logs':
            Log.query(ancestor=project_key).order(-Log.date).fetch(5),
            'actions':
            Action.query(ancestor=project_key).order(Action.name),
            'action_upload_url':
            blobstore.create_upload_url('/action/import'),
            'sign_out_url':
            UserManager.get_signout_url(),
            'gravatar_url':
            UserManager.get_gravatar_url(),
            'user_email':
            UserManager.get_email(),
            'user_is_admin':
            UserManager.is_admin(),
            'sections': [{
                "name": "Projects",
                "url": "/project/list"
            }, {
                "name": project.name
            }]
        }

        template = JINJA_ENVIRONMENT.get_template(template_path)
        self.response.write(template.render(data))
Exemplo n.º 4
0
  def get(self, key):

    if UserManager.get_current_user() == None:
      self.redirect('/user-not-found')
      return

    project = Project.get_by_id(int(key))

    if project == None:
      self.redirect('/')
      return

    if not UserManager.get_user_has_privilege_for_operation(project):
      self.redirect('/')
      return

    project_key = ndb.Key(Project, int(key))
    template_path = 'templates/project/action.html'
    data = {
      'project_key': key,
      'project_secret': project.secret,
      'logs': Log.query(ancestor=project_key).order(-Log.date).fetch(5),
      'actions': Action.query(ancestor=project_key).order(Action.name),
      'action_upload_url': blobstore.create_upload_url('/action/import'),
      'sign_out_url': UserManager.get_signout_url(),
      'gravatar_url': UserManager.get_gravatar_url(),
      'user_email': UserManager.get_email(),
      'user_is_admin': UserManager.is_admin(),
      'sections': [{
        "name": "Projects",
        "url": "/project/list"
      },{
        "name": project.name
      }]
    }

    template = JINJA_ENVIRONMENT.get_template(template_path)
    self.response.write(template.render(data))