View a specific occurrence and optionally handle any updates.

    Context parameters:

    ``occurrence``
        the occurrence object keyed by ``pk``

    ``form``
        a form object for updating the occurrence
967783
def occurrence_view(
    request,
    event_pk,
    pk,
    template='swingtime/occurrence_detail.html',
    form_class=forms.SingleOccurrenceForm
):
    '''
    
    '''
    occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
    if request.method == 'POST':
        form = form_class(request.POST, instance=occurrence)
        if form.is_valid():
            form.save()
            return http.HttpResponseRedirect(request.path)
    else:
        form = form_class(instance=occurrence)

    return render(request, template, {'occurrence': occurrence, 'form': form})
1322071
def form_valid(self, form):
        
        form.save()
        return super(SubscriptionView, self).form_valid(form)
900130
def get_context(self, **kwargs):
        
        context = self.get_context_data(form=self.form_obj, **kwargs)
        context.update(super(FormAdminView, self).get_context())
        return context
522607
def _on_model_save(sender, **kwargs):
    """"""
    instance = kwargs.pop("instance")
    update_fields = kwargs.pop("update_fields")
    for index in instance.search_indexes:
        try:
            _update_search_index(
                instance=instance, index=index, update_fields=update_fields
            )
        except Exception:
            logger.exception("Error handling 'on_save' signal for %s", instance)
1151073
def handler(event, context):  # pylint: disable=W0613
    
    records = deserialize_records(event['Records'])

    # Split records into two groups, update and delete.
    # We don't want to query for deleted records.
    update_records, delete_records = group_records_by_type(records, UPDATE_EVENTS)

    LOG.debug('[@] Processing update records...')
    process_update_records(update_records)
    LOG.debug('[@] Completed processing of update records.')

    LOG.debug('[@] Processing delete records...')
    process_delete_records(delete_records)
    LOG.debug('[@] Completed processing of delete records.')

    LOG.debug('[@] Successfully updated current Historical table')
399998
def get_form(self, id=None, *args, **kwargs):
        
        if id:
            kwargs['id'] = id
        form = self.find(_form_ptn, *args, **kwargs)
        if form is not None:
            return Form(form)
426321
def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root,
                                   specific_occurrence_const, specific_occurrence)
      source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source"
      if !occurrence_identifier.blank?
        # if it doesn't exist, add extracted occurrence to the map
        # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}"
        @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier
        specific_occurrence ||= occurrence_identifier
        specific_occurrence_const = "#{source_data_criteria}".upcase
      else
        # create variable occurrences that do not already exist
        if @is_variable
          # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}"
          @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier
        end
        occurrence = @occurrences_map.try(:[], strip_tokens(source_data_criteria))
        unless occurrence
          fail "Could not find occurrence mapping for #{source_data_criteria}, #{source_data_criteria_root}"
        end
        # puts "\tUsing #{occurrence} for #{@id}"
        specific_occurrence ||= occurrence
      end

      specific_occurrence = 'A' unless specific_occurrence
      specific_occurrence_const = source_data_criteria.upcase unless specific_occurrence_const
      [source_data_criteria, source_data_criteria_root, source_data_criteria_extension,
       specific_occurrence, specific_occurrence_const]
    end
400791
def action_update(self):
        

        order = []
        form = self.request.form
        attachments = form.get("attachments", [])

        for attachment in attachments:
            # attachment is a form mapping, not a dictionary -> convert
            values = dict(attachment)

            uid = values.pop("UID")
            obj = api.get_object_by_uid(uid)

            # delete the attachment if the delete flag is true
            if values.pop("delete", False):
                self.delete_attachment(obj)
                continue

            # remember the order
            order.append(uid)

            # update the attachment with the given data
            obj.update(**values)
            obj.reindexObject()

        # set the attachments order to the annotation storage
        self.set_attachments_order(order)

        # redirect back to the default view
        return self.request.response.redirect(self.context.absolute_url())
782175
def form_valid(self, form):
        
        form.send_email(to=self.to_addr)
        return super(EmailView, self).form_valid(form)
385431
def check_url_does_not_exists(form, field):
    ''''''
    if field.data != field.object_data and Reuse.url_exists(field.data):
        raise validators.ValidationError(_('This URL is already registered'))
157088
def filter_repeated(self):
        '''
        
        '''
        defaults = {
            'occurrences': 1,
            'interval': 30,
            'refresh': 1800
        }

        # Override defaults with anything defined in the settings
        if isinstance(self.settings['sensu_plugin'], dict):
            defaults.update(self.settings['sensu_plugin'])

        occurrences = int(self.event['check'].get(
            'occurrences', defaults['occurrences']))
        interval = int(self.event['check'].get(
            'interval', defaults['interval']))
        refresh = int(self.event['check'].get(
            'refresh', defaults['refresh']))

        if self.event['occurrences'] < occurrences:
            self.bail('not enough occurrences')

        if (self.event['occurrences'] > occurrences and
                self.event['action'] == 'create'):
            return

        number = int(refresh / interval)
        if (number == 0 or
                (self.event['occurrences'] - occurrences) % number == 0):
            return

        self.bail('only handling every ' + str(number) + ' occurrences')
377109
def render_done(self, form, **kwargs):
        
        final_form_list = []
        # walk through the form list and try to validate the data again.
        for form_key in self.get_form_list():
            form_obj = self.get_form(step=form_key,
                data=self.storage.get_step_data(form_key),
                files=self.storage.get_step_files(form_key))
            if not form_obj.is_valid():
                return self.render_revalidation_failure(form_key, form_obj, **kwargs)
            final_form_list.append(form_obj)

        # render the done view and reset the wizard before returning the
        # response. This is needed to prevent from rendering done with the
        # same data twice.
        done_response = self.done(final_form_list, **kwargs)
        self.storage.reset()
        return done_response
146954
def get_kwargs(self, form, name):
        
        kwargs = {
            'prefix': self.get_prefix(form, name),
            'initial': self.get_initial(form, name),
        }
        kwargs.update(self.default_kwargs)
        return kwargs
229406
def formfield(self, **kwargs):
        """"""

        defaults = {
            'form_class': LocalizedTextFieldForm
        }

        defaults.update(kwargs)
        return super().formfield(**defaults)
498932
def get_if_present(self, name, default=None):
        
        if not self.processed_data:
            raise exceptions.FormNotProcessed('The form data has not been processed yet')

        if name in self.field_dict:
            return self[name]

        return default
519410
public function updateEditForm($form){
		if($this->modelIsMultiSitesAware()) {
			$managedSites = Multisites::inst()->sitesManagedByMember();
			$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
			$plural = singleton($this->owner->modelClass)->plural_name();
			if(!count($source)){
				$form->setFields(FieldList::create(
					LiteralField::create('NotAManager', "You do not have permission to manage $plural on any Sites")
				));
			}
		}
	}
528768
def process_form(self, instance, field, form, empty_marker=None,
                     emptyReturnsMarker=False):
        
        fieldName = field.getName()
        if fieldName + "_uid" in form:
            uid = form.get(fieldName + "_uid", '')
            if field.multiValued and\
                    (isinstance(uid, str) or isinstance(uid, unicode)):
                uid = uid.split(",")
        elif fieldName in form:
            uid = form.get(fieldName, '')
            if field.multiValued and\
                    (isinstance(uid, str) or isinstance(uid, unicode)):
                uid = uid.split(",")
        else:
            uid = None
        return uid, {}