@@ -268,6 +268,11 @@ class Dataset(CreatorsMixin):
268
268
269
269
SUPPORTED_SCHEMES = ('' , 'file' , 'http' , 'https' , 'git+https' , 'git+ssh' )
270
270
271
+ EDITABLE_FIELDS = [
272
+ 'creator' , 'date_published' , 'description' , 'in_language' , 'keywords' ,
273
+ 'license' , 'name' , 'url' , 'version' , 'created' , 'files'
274
+ ]
275
+
271
276
_id = jsonld .ib (default = None , context = '@id' )
272
277
273
278
creator = jsonld .container .list (
@@ -334,7 +339,7 @@ def to_unix(el):
334
339
@property
335
340
def uid (self ):
336
341
"""UUID part of identifier."""
337
- return self ._id .split ('/' )[- 1 ]
342
+ return self .identifier .split ('/' )[- 1 ]
338
343
339
344
@created .default
340
345
def _now (self ):
@@ -353,6 +358,13 @@ def creators_csv(self):
353
358
"""Comma-separated list of creators associated with dataset."""
354
359
return ',' .join (creator .short_name for creator in self .creator )
355
360
361
+ @property
362
+ def editable (self ):
363
+ """Subset of attributes which user can edit."""
364
+ obj = self .asjsonld ()
365
+ data = {field_ : obj .pop (field_ ) for field_ in self .EDITABLE_FIELDS }
366
+ return data
367
+
356
368
def find_file (self , file_path , return_index = False ):
357
369
"""Find a file in files container."""
358
370
for index , file_ in enumerate (self .files ):
@@ -370,13 +382,7 @@ def update_metadata(self, other_dataset):
370
382
if is_doi (other_dataset .identifier ):
371
383
self ._id = other_dataset .identifier
372
384
373
- update_fields = [
374
- 'creator' , 'date_published' , 'description' , 'identifier' ,
375
- 'in_language' , 'keywords' , 'license' , 'name' , 'url' , 'version' ,
376
- 'created' , 'files'
377
- ]
378
-
379
- for field_ in update_fields :
385
+ for field_ in self .EDITABLE_FIELDS :
380
386
val = getattr (other_dataset , field_ )
381
387
if val :
382
388
setattr (self , field_ , val )
0 commit comments