@@ -34,7 +34,7 @@ private class AnonymizedCuration
3434
3535 public AnonymizedCuration ( IEnumerable < CurationEntry > curationEntries , User user )
3636 {
37- bool userIsCurator = CurationEntry . GetCurationUserType ( user ) . Equals ( CurationUserType . Curator ) ;
37+ bool userIsCurator = CurationEntry . GetCurationUserType ( user , GetCurationGroupName ( ) ) . Equals ( CurationUserType . Curator ) ;
3838
3939 // requesting user gets added to the set of seen users
4040 var userSet = new HashSet < long > ( ) { user . Id } ;
@@ -88,7 +88,7 @@ public AnonymizedCuration(IEnumerable<CurationEntry> curationEntries, User user)
8888
8989 // convert the user list to new userIds from 1 to n
9090 var userMap = new Dictionary < long , CurationUserModel > ( ) ;
91- for ( var i = 0 ; i < sortedUsers . Count ; i ++ ) userMap . Add ( sortedUsers [ i ] . Id , new CurationUserModel ( sortedUsers [ i ] , i + 1 ) ) ;
91+ for ( var i = 0 ; i < sortedUsers . Count ; i ++ ) userMap . Add ( sortedUsers [ i ] . Id , new CurationUserModel ( sortedUsers [ i ] , i + 1 , GetCurationUserType ( sortedUsers [ i ] ) ) ) ;
9292
9393 // replace original userIds with the anonymized ones
9494 foreach ( var curationEntry in AnonymizedCurationEntries )
@@ -139,6 +139,26 @@ private static List<CurationLabel> GetCurationLabels()
139139 return curationLabels == null ? new List < CurationLabel > ( ) : curationLabels ;
140140 }
141141
142+ private static String GetCurationGroupName ( )
143+ {
144+ var groupName = ModuleManager . GetModuleSettings ( "DDM" ) . GetValueByKey < string > ( "curatorsGroupName" ) ;
145+ if ( string . IsNullOrEmpty ( groupName ) )
146+ {
147+ return "curator" ;
148+ }
149+ return groupName ;
150+ }
151+
152+ public static CurationUserType GetCurationUserType ( User user )
153+ {
154+ var curationGroupName = GetCurationGroupName ( ) ;
155+ if ( user . Groups . Any ( g => g . Name . Equals ( curationGroupName , StringComparison . CurrentCultureIgnoreCase ) ) )
156+ {
157+ return CurationUserType . Curator ;
158+ }
159+ return CurationUserType . User ;
160+ }
161+
142162 private static IEnumerable < CurationTemplateModel > GetGreetingTemplates ( )
143163 {
144164 // this should be replaced by a configuration or derived from other source in the future
@@ -216,7 +236,7 @@ public async Task<HttpResponseMessage> Get(long datasetid)
216236 var greetingTemplates = GetGreetingTemplates ( ) ;
217237 var taskListTemplates = GetTaskListTemplates ( ) ;
218238
219- bool userIsCurator = CurationEntry . GetCurationUserType ( userWithGroups ) . Equals ( CurationUserType . Curator ) ;
239+ bool userIsCurator = CurationEntry . GetCurationUserType ( userWithGroups , GetCurationGroupName ( ) ) . Equals ( CurationUserType . Curator ) ;
220240
221241 curationModel = new CurationModel (
222242 datasetid ,
@@ -337,6 +357,7 @@ public async Task<HttpResponseMessage> Put(CurationEntryModel curationEntryModel
337357 // check if user has rights to access the dataset
338358 //if (!(userRights(user.Id, c.Dataset.Id) > 0))
339359 // return Request.CreateErrorResponse(HttpStatusCode.PreconditionFailed, "User has no rights to access the dataset");
360+ bool userIsCurator = CurationEntry . GetCurationUserType ( userWithGroups , GetCurationGroupName ( ) ) . Equals ( CurationUserType . Curator ) ;
340361
341362 var newCurationEntry = curationManager . Update (
342363 curationEntryModel . Id ,
@@ -350,7 +371,8 @@ public async Task<HttpResponseMessage> Put(CurationEntryModel curationEntryModel
350371 notes ,
351372 curationEntryModel . UserIsDone ,
352373 curationEntryModel . IsApproved ,
353- userWithGroups
374+ userWithGroups ,
375+ userIsCurator
354376 ) ;
355377
356378 var response = AnonymizeCurationEntryModel ( curationEntryModel , newCurationEntry , userWithGroups ) ;
@@ -385,15 +407,18 @@ public async Task<HttpResponseMessage> Post(CurationEntryModel curationEntryMode
385407 . Where ( u => u . Id == user . Id )
386408 . Fetch ( u => u . Groups )
387409 . SingleOrDefault ( ) ;
410+
411+ var userIsCurator = CurationEntry . GetCurationUserType ( userWithGroups , GetCurationGroupName ( ) ) . Equals ( CurationUserType . Curator ) ;
388412
389- if ( ! CurationEntry . GetCurationUserType ( userWithGroups ) . Equals ( CurationUserType . Curator ) )
413+ if ( ! CurationEntry . GetCurationUserType ( userWithGroups , GetCurationGroupName ( ) ) . Equals ( CurationUserType . Curator ) )
390414 return Request . CreateErrorResponse ( HttpStatusCode . PreconditionFailed , "User not permitted to create curation entries" ) ;
391415
392416 List < CurationNote > notes ;
393417 if ( curationEntryModel . Notes == null || ! curationEntryModel . Notes . Any ( ) )
394418 notes = new List < CurationNote > ( ) ;
395419 else
396- notes = curationEntryModel . Notes . Select ( n => new CurationNote ( userWithGroups , n . Comment ) ) . ToList ( ) ; // all notes will be created for the current user
420+
421+ notes = curationEntryModel . Notes . Select ( n => new CurationNote ( userWithGroups , n . Comment , GetCurationUserType ( userWithGroups ) ) ) . ToList ( ) ; // all notes will be created for the current user
397422
398423 if ( curationEntryModel . Type == CurationEntryType . StatusEntryItem )
399424 {
@@ -419,7 +444,8 @@ public async Task<HttpResponseMessage> Post(CurationEntryModel curationEntryMode
419444 notes ,
420445 curationEntryModel . UserIsDone ,
421446 curationEntryModel . IsApproved ,
422- userWithGroups
447+ userWithGroups ,
448+ userIsCurator
423449 ) ;
424450
425451 var response = AnonymizeCurationEntryModel ( curationEntryModel , newCurationEntry , userWithGroups ) ;
0 commit comments