@param \Orchid\Platform\Models\Announcement $announcement
@param \Illuminate\Http\Request             $request

@return \Illuminate\Http\RedirectResponse
507191
public function saveOrUpdate(Announcement $announcement, Request $request)
    {
        $announcement
            ->fill($request->get('announcement'))
            ->fill([
                'user_id' => $request->user()->id,
                'active'  => 1,
            ])->save();

        Alert::info(__('Announcement has been created or updated.'));

        return back();
    }
56581
public function newShippingAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $entity  = new NewsletterShipping();
        $data = $request->request->get('corebundle_newslettershippingtype');
        $formConfig = array();
        if(isset($data['type']) && $data['type'] == 'token'){
            $formConfig['token'] = true;
        }
        $form = $this->createForm('CoreExtraBundle\Form\NewsletterShippingType', $entity, $formConfig);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $emailArray = $this->get('core_manager')->getSubscriptorFromType($entity);
            $entity->setTotalSent(count($emailArray));
            
            /////////////////////////////////////////////////////////
            //Send every email with diferent token and store on DB //
            /////////////////////////////////////////////////////////
            if($entity->getType() == NewsletterShipping::TYPE_TOKEN){
                 //truncate table email token
                $em = $this->getDoctrine()->getEntityManager();
                $connection = $em->getConnection();
                $statement = $connection->prepare("TRUNCATE TABLE email_token");
                $statement->execute();
                
                foreach ($emailArray as $email) {
                    $emailToken = new EmailToken();
                    $emailToken->setEmail($email);
                    $token = sha1(uniqid());
                    $emailToken->setToken($token);
                    $em->persist($emailToken);
                    $body = preg_replace('/(#TOKEN#)/', $token, $entity->getNewsletter()->getBody());
                    $this->get('core.mailer')->sendShipping(array($email), NewsletterShipping::TYPE_TOKEN, $body);
                }
            }else{
                $body = $entity->getNewsletter()->getBody();
                $this->get('core.mailer')->sendShipping($emailArray, $entity->getType(), $body);
            }
            $em->persist($entity);
            $em->flush();

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $entity->getId()
                        ));
            }
            
            $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.created');

            return $this->redirect($this->generateUrl('coreextra_newsletter_showshipping', array('id' => $entity->getId())));
        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
353467
public function redirectAction(Request $request, Error404 $error404)
    {
        $redirection = new ErrorRedirection();
        $redirection->setError($error404);

        $form = $this->getError404RedirectionForm($redirection);
        $form->handleRequest($request);

        if ($request->query->get('novalidate', false) === false) {
            if ($form->isValid()) {
                if ($redirection->getLink()->getLinkType() !== Link::TYPE_NONE) {
                    $error404->setRedirection($redirection);
                    $redirection->setError($error404);
                    $redirection->setUrl($error404->getUrl());

                    $em = $this->getDoctrine()->getManager();
                    $em->persist($redirection);
                    $em->flush();

                    $this->congrat($this->get('translator')->trans('victoire.404.redirection.success'));

                    return $this->returnAfterRemoval($error404);
                }

                $form->addError(new FormError($this->get('translator')->trans('victoire.404.form.error.blank')));
            }

            $this->warn($this->get('translator')->trans('victoire.404.form.error.unvalid'));

            return new Response($this->renderView('@VictoireSeo/Error404/_list.html.twig', [
                'form'     => $form->createView(),
                'error'    => $error404,
                'isOpened' => true,
            ]), 200, [
                'X-Inject-Alertify' => true,
            ]);
        }

        // rebuild form to avoid wrong form error
        $form = $this->getError404RedirectionForm($redirection);

        return new JsonResponse([
            'html' => $this->renderView('@VictoireSeo/Error404/_list.html.twig', [
                'form'     => $form->createView(),
                'error'    => $error404,
                'isOpened' => true,
            ]),
        ]);
    }
475264
public function changeConfirmedAction(Request $request)
    {
        $this->getContainer()->get('compo_region.manager.region')->setConfirmed(true);

        return new JsonResponse([
            'is_confirmed' => true,
        ]);
    }
365477
public function listNotifications(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            $this->app->abort(400);
        }

        $page = (int) $request->query->get('page', 0);

        return $this->app->json($this->getEventsManager()->get_notifications_as_array(($page < 0 ? 0 : $page)));
    }
839882
def announcement_view(request, announcement_pk):
    '''  '''
    announce = get_object_or_404(Announcement, pk=announcement_pk)
    page_name = "View Announcement"
    profile = UserProfile.objects.get(user=request.user)
    pin_form = PinForm(
        request.POST if "pin" in request.POST else None,
        instance=announce,
        )
    can_edit = announce.incumbent == profile or request.user.is_superuser
    if pin_form.is_valid():
        pin_form.save()
        return HttpResponseRedirect(
            reverse('managers:view_announcement', kwargs={"announcement_pk": announcement_pk}),
            )
    return render_to_response('view_announcement.html', {
        'page_name': page_name,
        'pin_form': pin_form,
        'can_edit': can_edit,
        'announcement': announce,
        }, context_instance=RequestContext(request))
1044623
public function destroy(News $news, Request $request)
    {
        $this->deleteEntry($news, $request);

        return redirect_to_resource();
    }
1027331
def show_announcement_view(request):
    
    if request.method == "POST":
        announcement_id = request.POST.get("announcement_id")
        if announcement_id:
            announcement = Announcement.objects.get(id=announcement_id)
            announcement.user_map.users_hidden.remove(request.user)
            announcement.user_map.save()
            return http.HttpResponse("Unhidden")
        raise http.Http404
    else:
        return http.HttpResponseNotAllowed(["POST"], "HTTP 405: METHOD NOT ALLOWED")
1367794
public function update(NewsCategory $category, Request $request)
	{
		$attributes = request()->validate(NewsCategory::$rules, NewsCategory::$messages);

        $category = $this->updateEntry($category, $attributes);

        return redirect_to_resource();
	}
749899
def view_announcement_view(request, id):
    
    announcement = get_object_or_404(Announcement, id=id)

    return render(request, "announcements/view.html", {"announcement": announcement})
5801
public function changeNotifications(Request $request)
    {
        $this->validate(
            $request,
            [
                'notifications' => 'required|array',
            ]
        );

        foreach ($request->input('notifications') as $notification => $enable) {
            Auth::user()->setNotification($notification, $enable);
        }

        Auth::user()->save();

        return redirect()->back()->withStatus(trans('mustard::account.notifications_changed'));
    }
219830
public function postCreate(ModelCreateRequest $request)
    {
        if (!$this->modelAdmin->hasCreating()) {
            return $this->missingMethod();
        }

        $this->modelAdmin->create();

        return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully created.', 'dismissable' => false]]);
    }
1171824
public function addAction(Request $request): Response
    {
        $form = $this->formFactory->addLocation(
            new ContentLocationAddData()
        );
        $form->handleRequest($request);

        $contentInfo = $form->getData()->getContentInfo();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentLocationAddData $data) {
                $contentInfo = $data->getContentInfo();

                foreach ($data->getNewLocations() as $newLocation) {
                    $locationCreateStruct = $this->locationService->newLocationCreateStruct($newLocation->id);
                    $this->locationService->createLocation($contentInfo, $locationCreateStruct);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Location '%name%' created.") */
                            'location.create.success',
                            ['%name%' => $newLocation->getContentInfo()->name],
                            'location'
                        )
                    );
                }

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                    'locationId' => $contentInfo->mainLocationId,
                    '_fragment' => LocationsTab::URI_FRAGMENT,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirect($this->generateUrl('_ezpublishLocation', [
            'locationId' => $contentInfo->mainLocationId,
            '_fragment' => LocationsTab::URI_FRAGMENT,
        ]));
    }
783291
public function verify(Request $request)
    {
        if ($user = User::find($request->route('id'))) {
            $user->markEmailAsVerified();
            event(new Verified($user));
        }

        return redirect($this->redirectPath())->with('verified', true);
    }
551331
public function activate(ActivateRequest $request, $id)
    {
        $record    = $this->modelRepository->findOrFail($id);
        $success   = false;
        $result    = null;
        $activated = $request->get('activate');

        if ($this->getModelInformation()->list->activatable) {
            $success = true;
            $result  = $this->changeModelActiveState($record, $activated);
        }

        if ($activated) {
            event( new Events\ModelActivatedInCms($record) );
        } else {
            event( new Events\ModelDeactivatedInCms($record) );
        }

        if (request()->ajax()) {
            return response()->json([ 'success' => $success, 'active' => $result ]);
        }

        if ($success && config('cms-models.notifications.flash.activate')) {
            cms_flash(
                cms_trans(
                    'models.store.success-message-' . ($result ? 'activate' : 'deactivate'),
                    [ 'record' => $this->getSimpleRecordReference($id, $record) ]
                ),
                FlashLevel::SUCCESS
            );
        }

        return redirect()->back();
    }
161334
public function messagesSendAction(Request $request)
    {
        $query = $request->request->all();
        $messages = $this->om->findList('Claroline\PlannedNotificationBundle\Entity\Message', 'uuid', $query['messages']);
        $users = $this->om->findList('Claroline\CoreBundle\Entity\User', 'uuid', $query['users']);
        $this->manager->sendMessages($messages, $users);

        return new JsonResponse('success', 200);
    }
1333785
def request_announcement_view(request):
    """"""
    if request.method == "POST":
        form = AnnouncementRequestForm(request.POST)
        logger.debug(form)
        logger.debug(form.data)

        if form.is_valid():
            teacher_objs = form.cleaned_data["teachers_requested"]
            logger.debug("teacher objs:")
            logger.debug(teacher_objs)

            if len(teacher_objs) > 2:
                messages.error(request, "Please select a maximum of 2 teachers to approve this post.")
            else:
                obj = form.save(commit=True)
                obj.user = request.user
                # SAFE HTML
                obj.content = safe_html(obj.content)

                obj.save()

                ann = AnnouncementRequest.objects.get(id=obj.id)
                logger.debug(teacher_objs)
                approve_self = False
                for teacher in teacher_objs:
                    ann.teachers_requested.add(teacher)
                    if teacher == request.user:
                        approve_self = True
                ann.save()

                if approve_self:
                    ann.teachers_approved.add(teacher)
                    ann.save()
                    if settings.SEND_ANNOUNCEMENT_APPROVAL:
                        admin_request_announcement_email(request, form, ann)
                    ann.admin_email_sent = True
                    ann.save()
                    return redirect("request_announcement_success_self")

                else:
                    if settings.SEND_ANNOUNCEMENT_APPROVAL:
                        request_announcement_email(request, form, obj)
                    return redirect("request_announcement_success")
                return redirect("index")
        else:
            messages.error(request, "Error adding announcement request")
    else:
        form = AnnouncementRequestForm()
    return render(request, "announcements/request.html", {"form": form, "action": "add"})