This commit is contained in:
2019-05-20 21:35:50 +00:00
parent dd2b227d88
commit 0aad951ab1
6 changed files with 18 additions and 19 deletions

View File

@@ -22,7 +22,7 @@ Remove OwnerId
- Event object uses it see eventlog above
- FormCustom uses it much like DataFilter does, could also be renamed to UserId and semantically be better
- UserOptions (rename to userID)
- OpsJob (might be removable?)
- OpsJob (might be removable, rename it CreatorID? Or, if it's already logged in the event log then maybe no creator ID is required at all.)
OwnerID is put on httpcontext in startup.cs, will it still be necessary?
Clean up owner ID and rules now that it's deprecated

View File

@@ -186,14 +186,16 @@ namespace AyaNova.Api.Controllers
if (!badRequest)
{
//check if object exists
// long attachToObjectOwnerId = attachToObject.OwnerId(ct);
// if (attachToObjectOwnerId == -1)
// {
// badRequest = true;
// errorMessage = "Invalid attach object";
// }
// else
// {
//Updated code: this used to check if the ownerId was -1 to see if it didn't exist, but since ownerId zapped this seems like the next best way to do it
//Not sure at all what the ownerid check was doing before that verified it's existance, the code is long gone now and I can't be arsed to look it up in the repo history
//If the tests pass then it's fine :)
if (!BizObjectExistsInDatabase.Exists(attachToObject))
{
badRequest = true;
errorMessage = "Invalid attach object";
}
else
{
// User needs modify rights to the object type in question
if (!Authorized.HasModifyRole(HttpContext.Items, attachToObject.ObjectType))
{
@@ -202,7 +204,7 @@ namespace AyaNova.Api.Controllers
return StatusCode(403, new ApiNotAuthorizedResponse());
}
//}
}
}
@@ -222,7 +224,7 @@ namespace AyaNova.Api.Controllers
{
foreach (UploadedFileInfo a in uploadFormData.UploadedFiles)
{
var v = FileUtil.storeFileAttachment(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, UserId, attachToObject, ct);
var v = FileUtil.storeFileAttachment(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, attachToObject, ct);
returnList.Add(new NameIdItem()
{
Name = v.DisplayFileName,

View File

@@ -62,7 +62,7 @@ namespace AyaNova.Biz
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
//Seeder sets user options in advance so no need to create them here in that case
if (inObj.UserOptions == null)
inObj.UserOptions = new UserOptions(UserId);
inObj.UserOptions = new UserOptions();
Validate(inObj, null);
@@ -103,7 +103,7 @@ namespace AyaNova.Biz
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
//Seeder sets user options in advance so no need to create them here in that case
if (inObj.UserOptions == null)
inObj.UserOptions = new UserOptions(UserId);
inObj.UserOptions = new UserOptions();
Validate(inObj, null);
if (HasErrors)

View File

@@ -10,8 +10,7 @@ namespace AyaNova.Models
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
[Required]
public long OwnerId { get; set; }
//-----------------------------------------
[Required]
public long AttachToObjectId { get; set; }

View File

@@ -228,7 +228,7 @@ namespace AyaNova.Util
{
LogUpdateMessage(log);
exec("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, ownerid bigint not null," +
exec("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, " +
"attachtoobjectid bigint not null, attachtoobjecttype integer not null, " +
"storedfilename text not null, displayfilename text not null, contenttype text, notes text)");

View File

@@ -256,11 +256,10 @@ namespace AyaNova.Util
/// <param name="tempFilePath"></param>
/// <param name="contentType"></param>
/// <param name="fileName"></param>
/// <param name="userId"></param>
/// <param name="attachToObject"></param>
/// <param name="ct"></param>
/// <returns></returns>
internal static FileAttachment storeFileAttachment(string tempFilePath, string contentType, string fileName, long userId, AyaTypeId attachToObject, AyContext ct)
internal static FileAttachment storeFileAttachment(string tempFilePath, string contentType, string fileName, AyaTypeId attachToObject, AyContext ct)
{
//calculate hash
var hash = FileHash.GetChecksum(tempFilePath);
@@ -286,7 +285,6 @@ namespace AyaNova.Util
//Build AyFileInfo
FileAttachment fi = new FileAttachment()
{
OwnerId = userId,
StoredFileName = hash,
DisplayFileName = fileName,
Notes = string.Empty,