Add event page.

    Currently, there is an approval process for events. If a user is an
    events administrator, they can create events directly. Otherwise,
    their event is added in the system but must be approved.
776864
def add_event_view(request):
    
    is_events_admin = request.user.has_admin_permission('events')
    if not is_events_admin:
        return redirect("request_event")

    if request.method == "POST":
        form = EventForm(data=request.POST, all_groups=request.user.has_admin_permission('groups'))
        logger.debug(form)
        if form.is_valid():
            obj = form.save()
            obj.user = request.user
            # SAFE HTML
            obj.description = safe_html(obj.description)

            # auto-approve if admin
            obj.approved = True
            obj.approved_by = request.user
            messages.success(request, "Because you are an administrator, this event was auto-approved.")
            obj.created_hook(request)

            obj.save()
            return redirect("events")
        else:
            messages.error(request, "Error adding event.")
    else:
        form = EventForm(all_groups=request.user.has_admin_permission('groups'))
    context = {"form": form, "action": "add", "action_title": "Add" if is_events_admin else "Submit", "is_events_admin": is_events_admin}
    return render(request, "events/add_modify.html", context)
811631
public function Add() {
		if(!$this->_Permission())
			return;

      $this->Title(T('Add Role'));

      // Use the edit form with no roleid specified.
      $this->View = 'Edit';
      $this->Edit();
   }
904476
public function eventAfterUpdate()
    {
        $this->updateNavItemTimesamp();
        if (!empty($this->_olds)) {
            $oldPlaceholderVar = $this->_olds['placeholder_var'];
            $oldPrevId = (int) $this->_olds['prev_id'];
            if ($oldPlaceholderVar != $this->placeholder_var || $oldPrevId != $this->prev_id) {
                $this->reindex($this->nav_item_page_id, $oldPlaceholderVar, $oldPrevId);
            }
            $this->reindex($this->nav_item_page_id, $this->placeholder_var, $this->prev_id);
            Log::add(2, ['tableName' => 'cms_nav_item_page_block_item', 'action' => 'update', 'row' => $this->id, 'pageTitle' => $this->droppedPageTitle, 'blockName' => $this->block->getNameForLog()], 'cms_nav_item_page_block_item', $this->id);
        }
    }
194195
protected function bindEvents(): void
    {
        $userConfig = $this->app['config'][static::$abstract];

        $handler = new EventHandler($this->app->events, $userConfig);

        $handler->subscribe();

        $handler->subscribeQueueEvents($this->app->queue);

        if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) {
            $handler->subscribeAuthEvents();
        }
    }
508523
function createEvent(params, cb) {
  var resourcePath = config.addURIParams("/events", params);
  var method = "POST";
  var data = {
    uid: params.guid,
    timestamp: (new Date().toISOString()),
    details: params.data.msg,
    eventClass: 'APP_STATE',
    eventType: params.data.type,
    eventLevel: 'FATAL',
    env: params.environment,
    domain: params.domain,
    dyno: '',
    appName: params.appname,
    updateBy: ''
  };

  params.resourcePath = resourcePath;
  params.method = method;
  params.data = data;

  mbaasRequest.app(params, cb);
}
1308416
def _page_update(self, event):
        
        try:
            if event.schema == 'wikipage':
                self._update_index()

        except Exception as e:
            self.log("Page creation notification error: ", event, e,
                     type(e), lvl=error)
691212
def add_events(new_events)
      new_events.map do |new_event|
        # Check for other states that use a different class type for their name.
        # This typically prevents string / symbol misuse.
        if conflict = events.detect { |event| event.name.class != new_event.class }
          raise ArgumentError, "#{new_event.inspect} event defined as #{new_event.class}, #{conflict.name.inspect} defined as #{conflict.name.class}; all events must be consistent"
        end

        unless event = events[new_event]
          events << event = Event.new(self, new_event)
        end

        event
      end
    end
1200014
def add_role_to_user(self, user, role):
        
        user.add_role(role)
        self.save(user)
        events.user_got_role_event.send(user, role=role)
634939
def _AddEvent(self, event):
    
    if hasattr(event, 'event_data_row_identifier'):
      event_data_identifier = identifiers.SQLTableIdentifier(
          self._CONTAINER_TYPE_EVENT_DATA,
          event.event_data_row_identifier)
      lookup_key = event_data_identifier.CopyToString()

      event_data_identifier = self._event_data_identifier_mappings[lookup_key]
      event.SetEventDataIdentifier(event_data_identifier)

    # TODO: add event identifier mappings for event tags.

    self._storage_writer.AddEvent(event)
894224
def event(request, id):
    ""
    
    try:
        evt = Event.objects.get(pk=id)
    except Event.DoesNotExist:
        return HttpResponseRedirect(reverse('overseer:index'))
    
    update_list = list(evt.eventupdate_set.order_by('-date_created'))
    
    return respond('overseer/event.html', {
        'event': evt,
        'update_list': update_list,
    }, request)
1000405
public void addEvent(UserFeedbackEvent.Level level, UserFeedbackEvent.Stage stage, String message) {
    addEvent(new UserFeedbackEvent(autoML, level, stage, message));
  }
87178
def list_events_view(request):
    '''  '''
    page_name = "Upcoming Events"
    profile = UserProfile.objects.get(user=request.user)
    event_form = EventForm(
        request.POST if 'post_event' in request.POST else None,
        profile=profile,
    )
    if event_form.is_valid():
        event_form.save()
        return HttpResponseRedirect(reverse('events:list'))

    # a pseudo-dictionary, actually a list with items of form (event, ongoing,
    # rsvpd, rsvp_form), where ongoing is a boolean of whether the event is
    # currently ongoing, rsvpd is a boolean of whether the user has rsvp'd to
    # the event
    events_dict = list()
    for event in Event.objects.filter(end_time__gte=now()):
        rsvp_form = RsvpForm(
            request.POST if "rsvp-{0}".format(event.pk) in request.POST else None,
            instance=event,
            profile=profile,
        )
        if rsvp_form.is_valid():
            rsvpd = rsvp_form.save()
            if rsvpd:
                message = MESSAGES['RSVP_ADD'].format(event=event.title)
            else:
                message = MESSAGES['RSVP_REMOVE'].format(event=event.title)
            messages.add_message(request, messages.SUCCESS, message)
            return HttpResponseRedirect(reverse('events:list'))

        ongoing = ((event.start_time <= now()) and (event.end_time >= now()))
        rsvpd = (profile in event.rsvps.all())
        events_dict.append((event, ongoing, rsvpd, rsvp_form))

    if request.method == "POST":
        messages.add_message(request, messages.ERROR, MESSAGES["EVENT_ERROR"])

    return render_to_response('list_events.html', {
        'page_name': page_name,
        'events_dict': events_dict,
        'now': now(),
        'event_form': event_form,
    }, context_instance=RequestContext(request))
852461
def _process_event(self, data, url, services_incl_filter=None, services_excl_filter=None, custom_tags=None):
        '''
        
        '''
        hostname = data['svname']
        service_name = data['pxname']
        key = "%s:%s" % (hostname, service_name)
        status = self.host_status[url][key]
        custom_tags = [] if custom_tags is None else custom_tags

        if self._is_service_excl_filtered(service_name, services_incl_filter, services_excl_filter):
            return

        data_status = data['status']
        if status is None:
            self.host_status[url][key] = data_status
            return

        if status != data_status and data_status in ('up', 'down'):
            # If the status of a host has changed, we trigger an event
            try:
                lastchg = int(data['lastchg'])
            except Exception:
                lastchg = 0

            # Create the event object
            ev = self._create_event(
                data_status, hostname, lastchg, service_name, data['back_or_front'], custom_tags=custom_tags
            )
            self.event(ev)

            # Store this host status so we can check against it later
            self.host_status[url][key] = data_status
248460
private void safePostEvent(Event event) {
        EventAdmin ea = eventAdminRef.getService();
        if (ea != null) {
            ea.postEvent(event);
        } else if (tc.isEventEnabled()) {
            Tr.event(tc, "The EventAdmin service is unavailable. Unable to post the Event: " + event);
        }
    }
355903
def add_event(self, event):
        
        if not isinstance(event, event_pb2.Event):
            raise TypeError("Expected an event_pb2.Event proto, "
                            " but got %s" % type(event))
        self._async_writer.write(event.SerializeToString())
883579
def add_event(self, event):
        
        self._events.append(event)
        self._events_by_name[event.get_name] = event
1073728
def post_event(self, event):
        

        url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, self.api_version,
                                                       self.project_id,
                                                       event.event_collection)
        headers = utilities.headers(self.write_key)
        payload = event.to_json()
        response = self.fulfill(HTTPMethods.POST, url, data=payload, headers=headers, timeout=self.post_timeout)
        self._error_handling(response)