Commit cc54d22f authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge remote-tracking branch 'remotes/origin/Sprint/2020-20' into Product/704-basicReporting

parents 78dfb608 a7a491c5
......@@ -132,7 +132,7 @@ namespace Coscine.Database.Models
});
}
public Project StoreFromObject(ProjectObject projectObject, User user)
public Project StoreFromObject(ProjectObject projectObject, User user, bool isRWTHMember = false)
{
if (projectObject.Disciplines.Count() == 0 || projectObject.Organizations.Count() == 0)
{
......@@ -159,7 +159,7 @@ namespace Coscine.Database.Models
{
SetDisciplines(project, projectObject.Disciplines);
SetOrganizations(project, projectObject.Organizations);
SetQuotas(project);
SetQuotas(project, isRWTHMember);
}
catch (Exception e)
{
......@@ -253,17 +253,22 @@ namespace Coscine.Database.Models
}
}
private void SetQuotas(Project project)
private void SetQuotas(Project project, bool IsRWTHMember = false)
{
ProjectQuotaModel projectQuotaModel = new ProjectQuotaModel();
ResourceTypeModel resourceTypeModel = new ResourceTypeModel();
foreach (var resourceType in resourceTypeModel.GetAll())
{
var quota = 25;
if (resourceType.DisplayName.Equals("rds") && !IsRWTHMember)
{
quota = 0;
}
projectQuotaModel.Insert(new ProjectQuota
{
ProjectId = project.Id,
ResourceTypeId = resourceType.Id,
Quota = 25
Quota = quota
});
}
}
......
......@@ -207,13 +207,13 @@ namespace Coscine.Database.Models
public bool HasAccess(User user, Resource resource, params string[] allowedAccess)
{
var projectId = new ProjectResourceModel().GetProjectForResource(resource.Id);
IEnumerable<string> allowedAccessLabels = allowedAccess.Select(x => x.ToLower().Trim()).ToList();
return DatabaseConnection.ConnectToDatabase((db) => (from relation in db.ProjectRoles
where relation.Project.ProjectResourceProjectIdIds != null && relation.Project.ProjectResourceProjectIdIds
.Any((projectResource) => projectResource.Resource.Id == resource.Id)
&& relation.User.Id == user.Id
&& allowedAccessLabels.Contains(relation.Role.DisplayName.ToLower())
select relation).Any());
where relation.ProjectId == projectId
&& relation.User.Id == user.Id
&& allowedAccessLabels.Contains(relation.Role.DisplayName.ToLower())
select relation).Any());
}
public int UpdateByObject(Resource resource, ResourceObject resourceObject)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment