POST a new submission
164361
def POST(self, courseid, taskid, isLTI):
        
        username = self.user_manager.session_username()

        course = self.course_factory.get_course(courseid)
        if not self.user_manager.course_is_open_to_user(course, username, isLTI):
            return self.template_helper.get_renderer().course_unavailable()

        task = course.get_task(taskid)
        if not self.user_manager.task_is_visible_by_user(task, username, isLTI):
            return self.template_helper.get_renderer().task_unavailable()

        self.user_manager.user_saw_task(username, courseid, taskid)

        is_staff = self.user_manager.has_staff_rights_on_course(course, username)
        is_admin = self.user_manager.has_admin_rights_on_course(course, username)

        userinput = web.input()
        if "@action" in userinput and userinput["@action"] == "submit":
            # Verify rights
            if not self.user_manager.task_can_user_submit(task, username, isLTI):
                return json.dumps({"status": "error", "text": _("You are not allowed to submit for this task.")})

            # Retrieve input random and check still valid
            random_input = self.database.user_tasks.find_one({"courseid": task.get_course_id(), "taskid": task.get_id(), "username": username}, { "random": 1 })
            random_input = random_input["random"] if "random" in random_input else []
            for i in range(0, len(random_input)):
                s = "@random_" + str(i)
                if s not in userinput or float(userinput[s]) != random_input[i]:
                    return json.dumps({"status": "error", "text": _("Your task has been regenerated. This current task is outdated.")})

            # Reparse user input with array for multiple choices
            init_var = {
                problem.get_id(): problem.input_type()()
                for problem in task.get_problems() if problem.input_type() in [dict, list]
            }
            userinput = task.adapt_input_for_backend(web.input(**init_var))

            if not task.input_is_consistent(userinput, self.default_allowed_file_extensions, self.default_max_file_size):
                web.header('Content-Type', 'application/json')
                return json.dumps({"status": "error", "text": _("Please answer to all the questions and verify the extensions of the files "
                                                              "you want to upload. Your responses were not tested.")})
            del userinput['@action']

            # Get debug info if the current user is an admin
            debug = is_admin
            if "@debug-mode" in userinput:
                if userinput["@debug-mode"] == "ssh" and debug:
                    debug = "ssh"
                del userinput['@debug-mode']

            # Start the submission
            try:
                submissionid, oldsubids = self.submission_manager.add_job(task, userinput, debug)
                web.header('Content-Type', 'application/json')
                return json.dumps({"status": "ok", "submissionid": str(submissionid), "remove": oldsubids, "text": _("<b>Your submission has been sent...</b>")})
            except Exception as ex:
                web.header('Content-Type', 'application/json')
                return json.dumps({"status": "error", "text": str(ex)})

        elif "@action" in userinput and userinput["@action"] == "check" and "submissionid" in userinput:
            result = self.submission_manager.get_submission(userinput['submissionid'], user_check=not is_staff)
            if result is None:
                web.header('Content-Type', 'application/json')
                return json.dumps({'status': "error", "text": _("Internal error")})
            elif self.submission_manager.is_done(result, user_check=not is_staff):
                web.header('Content-Type', 'application/json')
                result = self.submission_manager.get_input_from_submission(result)
                result = self.submission_manager.get_feedback_from_submission(result, show_everything=is_staff)

                # user_task always exists as we called user_saw_task before
                user_task = self.database.user_tasks.find_one({
                    "courseid":task.get_course_id(),
                    "taskid": task.get_id(),
                    "username": {"$in": result["username"]}
                })

                default_submissionid = user_task.get('submissionid', None)
                if default_submissionid is None:
                    # This should never happen, as user_manager.update_user_stats is called whenever a submission is done.
                    return json.dumps({'status': "error", "text": _("Internal error")})

                return self.submission_to_json(task, result, is_admin, False, default_submissionid == result['_id'], tags=task.get_tags())
            else:
                web.header('Content-Type', 'application/json')
                return self.submission_to_json(task, result, is_admin)

        elif "@action" in userinput and userinput["@action"] == "load_submission_input" and "submissionid" in userinput:
            submission = self.submission_manager.get_submission(userinput["submissionid"], user_check=not is_staff)
            submission = self.submission_manager.get_input_from_submission(submission)
            submission = self.submission_manager.get_feedback_from_submission(submission, show_everything=is_staff)
            if not submission:
                raise web.notfound()
            web.header('Content-Type', 'application/json')

            return self.submission_to_json(task, submission, is_admin, True, tags=task.get_tags())

        elif "@action" in userinput and userinput["@action"] == "kill" and "submissionid" in userinput:
            self.submission_manager.kill_running_submission(userinput["submissionid"])  # ignore return value
            web.header('Content-Type', 'application/json')
            return json.dumps({'status': 'done'})
        elif "@action" in userinput and userinput["@action"] == "set_submission" and "submissionid" in userinput:
            web.header('Content-Type', 'application/json')
            if task.get_evaluate() != 'student':
                return json.dumps({'status': "error"})

            if self.set_selected_submission(course, task, userinput["submissionid"]):
                return json.dumps({'status': 'done'})
            else:
                return json.dumps({'status': 'error'})
        else:
            raise web.notfound()
374036
def post(self):
        """"""
        run_payload = utils.uni_to_str(json.loads(request.get_data()))
        run_payload['id'] = str(uuid.uuid4())
        LOG.info('Triggering new ansible run %s', run_payload['id'])
        run = self.manager.create_run(run_payload)
        return run_model.format_response(run), http_client.CREATED
42050
def post(self, request, bot_id, format=None):
        
        return super(HandlerList, self).post(request, bot_id, format)
346946
def post_submission(self):
        
        # Check that the subreddit can be submitted to
        name = self.content.name
        if '+' in name or name in ('/r/all', '/r/front', '/r/me', '/u/saved'):
            self.term.show_notification("Can't post to {0}".format(name))
            return

        submission_info = docs.SUBMISSION_FILE.format(name=name)
        with self.term.open_editor(submission_info) as text:
            if not text:
                self.term.show_notification('Canceled')
                return
            elif '\n' not in text:
                self.term.show_notification('Missing body')
                return

            title, content = text.split('\n', 1)
            with self.term.loader('Posting', delay=0):
                submission = self.reddit.submit(name, title, text=content,
                                                raise_captcha_exception=True)
                # Give reddit time to process the submission
                time.sleep(2.0)
            if self.term.loader.exception:
                raise TemporaryFileError()

        if not self.term.loader.exception:
            # Open the newly created submission
            self.selected_page = self.open_submission_page(submission=submission)
1256392
async def post(self, request):
        """"""
        form = await self.get_form(request)
        if not form.validate():
            raise muffin.HTTPBadRequest(
                text=json.dumps(form.errors), content_type='application/json')
        await self.save_form(form, request)
        raise muffin.HTTPFound(self.url)
874247
function action_putpost(si,args,done) {
    var ent_type = parse_ent(args)

    var ent = si.make(ent_type.zone,ent_type.base,ent_type.name)

    var data = args.data || {}

    var good = _.filter(_.keys(data),function(k){return !~k.indexOf('$')})

    var fields = _.pick(data,good)
    ent.data$(fields)

    if( null != ent_type.entid ) {
      ent.id = ent_type.entid
    }
    else if( null != data.id$ && options.allow_id ) {
      ent.id$ = data.id$
    }

    save_aspect(si,{args:args,ent:ent},done,function(ctxt,done){
      ctxt.ent.save$(function(err,ent){
        var data = ent ? ent.data$(true,'string') : null
        done(err, data)
      })
    })
  }
596
def post(self):
        """"""
        self.set_header("Content-Type", "application/json")
        key = uuid.uuid4().hex
        metadata = json.loads(self.request.body.decode())
        metadata["uuid"] = key
        self.database[key] = metadata
        result = json.dumps({"uuid": key})
        self.write(result)
893140
def post(self, request, question_level, question_number, format=None):
        
        user = User.objects.get(username=request.user.username)
        question = Question.objects.filter(question_level=question_level).filter(question_number=question_number)
        if int(user.profile.user_access_level) < int(question_level):
            content = {'user_nick':profile.user_nick, 'please move along': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)

        time_last = None
        time_last_query = Comment.objects.filter(comment_user__username=request.user.username).order_by('comment_timestamp').last()
        if time_last_query:
            time_last = time_last_query.comment_timestamp
        time_limit = self.get_contest_consecutive_submission_halt_time() # the halt time for submission is kept same as submission halt time

#        print time_last, time_limit, datetime.datetime.now(), time_limit <= datetime.datetime.now()

        if(time_last is None or time_last + time_limit <= datetime.datetime.now()):

            serializer = CommentSerializer(data=request.data)
            if not request.data['comment_message'] or len(str(request.data['comment_message'])) >= 255:
                content = {'user_nick':profile.user_nick, 'Try to submit something small': 'Like your Dick' }
                return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
            if serializer.is_valid():
                serializer.save(comment_user = request.user,
                                comment_question = question[0],
                )
                checker_queue.delay(int(serializer.data['id']))
                return Response(serializer.data, status=status.HTTP_201_CREATED)
            else:
                return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
        else:
            content = {'user_nick':profile.user_nick, 'Try to submit after some time': 'Nothing to see here' }
            return Response(content, status=status.HTTP_406_NOT_ACCEPTABLE)
1350846
def post(self, request, bot_id, format=None):
        
        return super(HookList, self).post(request, bot_id, format)
1191621
void submit() {

        List<CmsUUID> selectedIds = getSelectedIds();
        List<CmsUUID> updated = Lists.newArrayList();
        CmsObject cms = m_dialogContext.getCms();
        try {
            for (CmsUUID selectedId : selectedIds) {
                cms.restoreDeletedResource(selectedId);
                updated.add(selectedId);
            }
            m_dialogContext.finish(updated);
        } catch (CmsException e) {
            m_dialogContext.error(e);
        }
    }
854629
def submit(label, *args)
      options = args.extract_options!
      new_class = options[:class] || "btn btn-primary"
      @template.content_tag("div",
        super(label, *(args << options.merge(:class => new_class))), :class => "form-actions")
    end
875882
def post_post():
    
    authorid = request.form.get('authorid', None)
    Post(request.form['title'],
         request.form['content'],
         users[authorid])
    return redirect("/posts")
167944
def submit(self):
        """"""
        self._newflg = False
        ret = list()
        for buf in self._buffer.values():
            buf = copy.deepcopy(buf)
            if self._fdpext:
                buf['fpout'] = f"{self._fproot}/{buf['label']}.{self._fdpext}"
            else:
                del buf['fpout']
            buf['index'] = tuple(buf['index'])
            ret.append(Info(buf))
        ret += self._stream
        return tuple(ret)
995866
def submit_link(self, title, url):
        
        return self._reddit.submit_link(self.display_name, title, url)
260337
public synchronized void post()
   {
    if (tc.isEntryEnabled()) SibTr.entry(tc, "post", ""+count);
      --count;
      if (count >= 0)
         notify();
    if (tc.isEntryEnabled()) SibTr.exit(tc, "post");
   }
466975
def new(obj):
    
    title = request.form['title']
    _site.config['ADDITIONAL_METADATA']['author.uid'] = current_user.uid
    try:
        title = title.encode(sys.stdin.encoding)
    except (AttributeError, TypeError):
        title = title.encode('utf-8')
    try:
        if obj == 'post':
            f = NewPostForm()
            if f.validate():
                _site.commands.new_post(title=title,
                                        author=current_user.realname,
                                        content_format='html')
            else:
                return error("Bad Request", 400)
        elif obj == 'page':
            f = NewPageForm()
            if f.validate():
                _site.commands.new_page(title=title,
                                        author=current_user.realname,
                                        content_format='html')
            else:
                return error("Bad Request", 400)
        else:
            return error("Cannot create {0} — unknown type.".format(obj), 400)
    except SystemExit:
        return error("This {0} already exists!".format(obj), 500)
    finally:
        del _site.config['ADDITIONAL_METADATA']['author.uid']
    # reload post list and go to index
    scan_site()
    if db is not None:
        db.set('site:needs_rebuild', '1')
    else:
        site.coil_needs_rebuild = '1'
    return redirect(url_for('index'))
293332
def post(self, request, *args, **kwargs):
        """"""
        try:
            kwargs = self.load_object(kwargs)
        except Exception as e:
            return self.render_te_response({
                'title': str(e),
            })

        if not self.has_permission(request):
            return self.render_te_response({
                'title': 'No access',
            })
        return self.render_te_response(self.handle_dialog(*args, **kwargs))