def update(self, revision, data, user=None): """Using revision and data update all data pretaining to self :param str or None revision: The revision that data points to :param dict data: Metadata recieved from waterbutler :returns: FileVersion """ self.name = data['name'] self.materialized_path = data['materialized'] version = FileVersion(identifier=revision) version.update_metadata(data, save=False) # Transform here so it can be sortted on later if data['modified'] is not None and data['modified'] != '': data['modified'] = parse_date( data['modified'], ignoretz=True, default=timezone.now() # Just incase nothing can be parsed ) # if revision is none then version is the latest version # Dont save the latest information if revision is not None: version.save() self.versions.add(version) for entry in self.history: if ('etag' in entry and 'etag' in data) and (entry['etag'] == data['etag']): break else: # Insert into history if there is no matching etag if data.get('modified'): utils.insort(self.history, data, lambda x: x['modified']) # If modified not included in the metadata, insert at the end of the history else: self.history.append(data) # Finally update last touched self.last_touched = timezone.now() self.save() return version
def update(self, revision, data, user=None): """Using revision and data update all data pretaining to self :param str or None revision: The revision that data points to :param dict data: Metadata recieved from waterbutler :returns: FileVersion """ self.name = data['name'] self.materialized_path = data['materialized'] version = FileVersion(identifier=revision) version.update_metadata(data, save=False) # Transform here so it can be sortted on later if data['modified'] is not None and data['modified'] != '': data['modified'] = parse_date( data['modified'], ignoretz=True, default=timezone.now() # Just incase nothing can be parsed ) # if revision is none then version is the latest version # Dont save the latest information if revision is not None: version.save() self.versions.add(version) for entry in self.history: if ('etag' in entry and 'etag' in data) and (entry['etag'] == data['etag']): break else: # Insert into history if there is no matching etag if data.get('modified'): utils.insort(self.history, data, lambda x: x['modified']) # If modified not included in the metadata, insert at the end of the history else: self.history.append(data) # Finally update last touched self.last_touched = timezone.now() self.save() return version
def update(self, revision, data, user=None): """Using revision and data update all data pretaining to self :param str or None revision: The revision that data points to :param dict data: Metadata recieved from waterbutler :returns: FileVersion """ self.name = data['name'] self.materialized_path = data['materialized'] version = FileVersion(identifier=revision) version.update_metadata(data, save=False) # Transform here so it can be sortted on later data['modified'] = parse_date( data['modified'] or '', # None breaks things to pass a string ignoretz=True, default=datetime.datetime.utcnow( ) # Just incase nothing can be parsed ) # if revision is none then version is the latest version # Dont save the latest information if revision is not None: version.save() self.versions.append(version) for entry in self.history: if entry['etag'] == data['etag']: break else: # Insert into history if there is no matching etag utils.insort(self.history, data, lambda x: x['modified']) # Finally update last touched self.last_touched = datetime.datetime.utcnow() self.save() return version
def update(self, revision, data, user=None): """Using revision and data update all data pretaining to self :param str or None revision: The revision that data points to :param dict data: Metadata recieved from waterbutler :returns: FileVersion """ self.name = data['name'] self.materialized_path = data['materialized'] version = FileVersion(identifier=revision) version.update_metadata(data, save=False) # Transform here so it can be sortted on later data['modified'] = parse_date( data['modified'] or '', # None breaks things to pass a string ignoretz=True, default=datetime.datetime.utcnow() # Just incase nothing can be parsed ) # if revision is none then version is the latest version # Dont save the latest information if revision is not None: version.save() self.versions.append(version) for entry in self.history: if entry['etag'] == data['etag']: break else: # Insert into history if there is no matching etag utils.insort(self.history, data, lambda x: x['modified']) # Finally update last touched self.last_touched = datetime.datetime.utcnow() self.save() return version