Makes `created_by`, `create_date` & `update_date` readonly when
        editing.

        Author: Himanshu Shankar (https://himanshus.com)
963315
def get_readonly_fields(self, request, obj=None):
        

        # Get read only fields from super
        fields = list(super(CreateUpdateAdmin, self).get_readonly_fields(
            request=request, obj=obj))

        # Loop over ownership info field
        for k, v in self.ownership_info['fields'].items():

            # Check if model has k attribute
            # and field k is readonly
            # and k is not already in fields
            # and k is not in excluded field
            # (if not checked, form.Meta.exclude has same field twice)
            if (hasattr(self.model, k)
                    and ('readonly' in v and v['readonly'])
                    and k not in fields
                    and (not self.exclude
                         or (self.exclude and k not in self.exclude))):
                fields.append(k)
        return tuple(fields)
1354486
public void setMaxDateCreated(String maxDateCreated) {

        m_parameters.setMaxDateCreated(CmsStringUtil.getLongValue(maxDateCreated, Long.MAX_VALUE, "maxDateCreated"));
    }
1332472
def created_on(self):
    """"""
    s = self._info.get('timeCreated', None)
    return dateutil.parser.parse(s) if s else None
60077
def parse_date_created(dct):
    """"""
    date = dct['date-created']
    if date:
        return (int(date['@year']), int(date['@month']), int(date['@day']))
    else:
        return (None, None, None)
873627
def clear_start_date(self):
        
        if (self.get_start_date_metadata().is_read_only() or
                self.get_start_date_metadata().is_required()):
            raise NoAccess()
        default_start_date = self._start_date_metadata['default_date_time_values'][0]
        self.my_osid_object_form._my_map['startDate'] = DateTime(year=default_start_date.year,
                                                                 month=default_start_date.month,
                                                                 day=default_start_date.day,
                                                                 hour=default_start_date.hour,
                                                                 minute=default_start_date.minute,
                                                                 second=default_start_date.second,
                                                                 microsecond=default_start_date.microsecond)
257665
def remove_readonly(func, path, _):
    ""
    os.chmod(path, stat.S_IWRITE)
    func(path)
147938
def creation_date(self, value): # pylint: disable-msg=E0102
        """"""
        if not isinstance(value, datetime.date):
            raise TypeError
        self._config['creation_date'][0] = value.isoformat()
215436
private void setAllowedDate(final long date) {
        mAllowedDate = date;
        if (mSharedPreferences == null) {
            mSharedPreferences = mContext.getSharedPreferences(
                    PREFERENCES_GEOCODER, Context.MODE_PRIVATE);
        }
        final Editor e = mSharedPreferences.edit();
        e.putLong(KEY_ALLOW, date);
        e.apply();
    }
171877
protected void readOnlyUpdated() {
		boolean localReadOnly = isReadOnly();
		if (hasChanged(oldReadOnly, localReadOnly)) {
			oldReadOnly = localReadOnly;
			firePropertyChange(READONLY_PROPERTY, !localReadOnly, localReadOnly);
		}
	}
302395
public void updateDatesAndCalendar()
    {
        if ((this.getEditMode() == DBConstants.EDIT_NONE) || (this.getEditMode() == DBConstants.EDIT_ADD))
            return; // Only on initial setup
        boolean bUpdateDates = false;
        int iUpdateDays = (int)this.getField(CalendarControl.UPDATE_DAYS).getValue();
        Calendar calNow = new GregorianCalendar();
        if ((this.getField(CalendarControl.START_ANNIV_DATE).isNull())
            || (this.getField(CalendarControl.END_ANNIV_DATE).isNull()))
                bUpdateDates = true;
        else
        {
            Calendar calCutoff = ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).getCalendar();
            calCutoff.add(Calendar.DAY_OF_YEAR, iUpdateDays);
            if (calNow.after(calCutoff))
                bUpdateDates = true;
        }
        if (bUpdateDates)
        {
            int iBackDays = (int)this.getField(CalendarControl.ANNIV_BACK_DAYS).getValue();
            int iRangeDays = (int)this.getField(CalendarControl.ANNIVERSARY_DAYS).getValue();
            Calendar calStart = (Calendar)calNow.clone();
            calStart.add(Calendar.DAY_OF_YEAR, -iBackDays);
            Calendar calEnd = (Calendar)calStart.clone();
            calEnd.add(Calendar.DAY_OF_YEAR, iRangeDays - iBackDays);
            
            Calendar calOldEnd = ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).getCalendar();
            if (calOldEnd == null)
                calOldEnd = calNow;
        
            ((DateTimeField)this.getField(CalendarControl.START_ANNIV_DATE)).setCalendar(calStart, true, DBConstants.SCREEN_MOVE);
            ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).setCalendar(calEnd, true, DBConstants.SCREEN_MOVE);
            ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).setCalendar(calNow, true, DBConstants.SCREEN_MOVE);
            
            this.updateCalendar(calOldEnd, calEnd);  // Update the calendar
            
            try {
                this.writeAndRefresh();
            } catch (DBException ex) {
                ex.printStackTrace();
            }
        }
    }
76326
private void updateReadonly(EntityType entityType, Attribute attr, Attribute updatedAttr) {
    Map<String, Attribute> readonlyTableAttrs =
        getTableAttributesReadonly(entityType)
            .collect(toLinkedMap(Attribute::getName, Function.identity()));
    if (!readonlyTableAttrs.isEmpty()) {
      dropTableTriggers(entityType);
    }

    if (attr.isReadOnly() && !updatedAttr.isReadOnly()) {
      readonlyTableAttrs.remove(attr.getName());
    } else if (!attr.isReadOnly() && updatedAttr.isReadOnly()) {
      readonlyTableAttrs.put(updatedAttr.getName(), updatedAttr);
    }

    if (!readonlyTableAttrs.isEmpty()) {
      createTableTriggers(entityType, readonlyTableAttrs.values());
    }
  }
158277
def set_read_only(self, value):
        
        if self.__read_only__ != value:
            self.__read_only__ = value
            self._update_read_only()
882106
function (cb) {

            model.VersionedModel.find({ refId: record._id }, 'dateCreated modifiedBy', { lean: 1, sort: { dateCreated: -1 } }, function (err, result) {
                return cb(err, result);
            });

        }
257071
def publishing_set_update_time(sender, instance, **kwargs):
    
    if hasattr(instance, 'publishing_linked'):
        # Hack to avoid updating `publishing_modified_at` field when a draft
        # publishable item is saved as part of a `publish` operation. This
        # ensures that the `publishing_published_at` timestamp is later than
        # the `publishing_modified_at` timestamp when we publish, which is
        # vital for us to correctly detect whether a draft is "dirty".
        if getattr(instance, '_skip_update_publishing_modified_at', False):
            # Reset flag, in case instance is re-used (e.g. in tests)
            instance._skip_update_publishing_modified_at = False
            return
        instance.publishing_modified_at = timezone.now()
917571
public function postCreate()
    {

        // Check if we should store creations in our revision history
        // Set this value to true in your model if you want to
        if(empty($this->revisionCreationsEnabled))
        {
            // We should not store creations.
            return false;
        }

        if ((!isset($this->revisionEnabled) || $this->revisionEnabled))
        {
            $revisions[] = array(
                'revisionable_type' => $this->getMorphClass(),
                'revisionable_id' => $this->getKey(),
                'key' => self::CREATED_AT,
                'old_value' => null,
                'new_value' => $this->{self::CREATED_AT},
                'user_id' => $this->getSystemUserId(),
                'created_at' => new \DateTime(),
                'updated_at' => new \DateTime(),
            );

            $revision = static::newModel();
            \DB::table($revision->getTable())->insert($revisions);
        }
    }
551255
def update_or_create(self, attributes, values=None):
        
        instance = self.first_or_new(**attributes)

        instance.fill(values)

        instance.save()

        return instance
1189500
def timestamps!
      [:created_at, :updated_at].each do |name|
        _add_key(name)
        attr_reader name
        class_eval(<<-RUBY, __FILE__, __LINE__)
          def #{name}=(value)                       # def created_at=(value)
            if value.kind_of?(String)               #   if value.kind_of?(String)
              value = Time.cast_from_string(value)  #     value = Time.cast_from_string(value)
            end                                     #   end
            @#{name} = value.nil? ? nil : value.utc #   @created_at = value.nil? ? nil : value.utc
          end                                       # end
        RUBY
      end

      class_eval(<<-RUBY, __FILE__, __LINE__)
        def _save(safe)
          if new_record?
            self.created_at = self.updated_at = Time.now
          else
            original_updated_at = updated_at
            self.updated_at = Time.now
          end
          super
        rescue Mongo::MongoDBError => e
          if new_record?
            self.created_at = self.updated_at = nil
          else
            self.updated_at = original_updated_at
          end
          raise e
        end

        def _update(selector, data, safe)
          original_updated_at = updated_at
          self.updated_at = Time.now
          data[:updated_at] = updated_at
          super
        rescue Mongo::MongoDBError => e
          self.updated_at = original_updated_at
          raise e
        end
      RUBY
    end