Skip to content

Commit

Permalink
Merge branch 'main' into update-test-seeding
Browse files Browse the repository at this point in the history
  • Loading branch information
danjov authored Jan 11, 2024
2 parents 0731556 + c07cff0 commit c6e9c8b
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 302 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Changed

- Updated layer management to use the .NET API.
- Update stratigraphy management to use the .NET API.
- Hide outer ring for disabled radio buttons.

## v2.0.506 - 2023-12-21

Expand Down
1 change: 0 additions & 1 deletion src/api-legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

# Profiles's ACTION Handlers
from bms.v1.borehole.profile.viewer import ProfileViewerHandler
from bms.v1.borehole.profile.producer import ProfileProducerHandler

# Profiles layers's ACTION Handlers
from bms.v1.borehole.profile.layer.viewer import ProfileLayerViewerHandler
Expand Down
3 changes: 0 additions & 3 deletions src/api-legacy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ async def close(application):

# Profile handlers
ProfileViewerHandler,
ProfileProducerHandler,

# Layer handlers
ProfileLayerViewerHandler,
Expand Down Expand Up @@ -221,11 +220,9 @@ async def close(application):

# Profile handlers
(r'/api/v1/borehole/profile', ProfileViewerHandler),
(r'/api/v1/borehole/profile/edit', ProfileProducerHandler),

# Profile Layer handlers
(r'/api/v1/borehole/profile/layer', ProfileLayerViewerHandler),
(r'/api/v1/borehole/profile/layer/edit', ProfileProducerHandler),

# Other handlers
(r'/api/v1/borehole/codes', CodeListHandler),
Expand Down
190 changes: 0 additions & 190 deletions src/api-legacy/v1/borehole/profile/patch.py

This file was deleted.

49 changes: 0 additions & 49 deletions src/api-legacy/v1/borehole/profile/producer.py

This file was deleted.

7 changes: 3 additions & 4 deletions src/api/BoreholeFileUploadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Amazon.S3.Model;
using BDMS.Models;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
using System.Security.Cryptography;

namespace BDMS;
Expand Down Expand Up @@ -52,7 +51,7 @@ public async Task UploadFileAndLinkToBorehole(IFormFile file, int boreholeId)
using var transaction = context.Database.CurrentTransaction == null ? await context.Database.BeginTransactionAsync().ConfigureAwait(false) : null;
try
{
var userName = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value;
var userName = httpContextAccessor.HttpContext?.GetUserName();

var user = await context.Users
.AsNoTracking()
Expand All @@ -70,7 +69,7 @@ public async Task UploadFileAndLinkToBorehole(IFormFile file, int boreholeId)
var bdmsFile = new Models.File { Name = file.FileName, NameUuid = fileNameGuid, Hash = base64Hash, Type = file.ContentType };

await context.Files.AddAsync(bdmsFile).ConfigureAwait(false);
await context.UpdateChangeInformationAndSaveChangesAsync(httpContextAccessor.HttpContext).ConfigureAwait(false);
await context.UpdateChangeInformationAndSaveChangesAsync(httpContextAccessor.HttpContext!).ConfigureAwait(false);

fileId = bdmsFile.Id;

Expand All @@ -85,7 +84,7 @@ public async Task UploadFileAndLinkToBorehole(IFormFile file, int boreholeId)
var boreholeFile = new BoreholeFile { FileId = (int)fileId, BoreholeId = boreholeId, UserId = user.Id, Attached = DateTime.UtcNow };

await context.BoreholeFiles.AddAsync(boreholeFile).ConfigureAwait(false);
await context.UpdateChangeInformationAndSaveChangesAsync(httpContextAccessor.HttpContext).ConfigureAwait(false);
await context.UpdateChangeInformationAndSaveChangesAsync(httpContextAccessor.HttpContext!).ConfigureAwait(false);

if (transaction != null) await transaction.CommitAsync().ConfigureAwait(false);
}
Expand Down
3 changes: 1 addition & 2 deletions src/api/Controllers/BoreholeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;

namespace BDMS.Controllers;

Expand Down Expand Up @@ -36,7 +35,7 @@ public async Task<ActionResult<int>> CopyAsync([Required] int id, [Required] int
var user = await context.Users
.Include(u => u.WorkgroupRoles)
.AsNoTracking()
.SingleOrDefaultAsync(u => u.Name == HttpContext.User.FindFirst(ClaimTypes.Name).Value)
.SingleOrDefaultAsync(u => u.Name == HttpContext.GetUserName())
.ConfigureAwait(false);

if (user == null || !user.WorkgroupRoles.Any(w => w.WorkgroupId == workgroupId && w.Role == Role.Editor))
Expand Down
Loading

0 comments on commit c6e9c8b

Please sign in to comment.