mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add settings field on the user
This commit is contained in:
parent
656dc493b8
commit
e668cdd89c
@ -17,6 +17,7 @@
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Abstractions.Models.Attributes;
|
||||
@ -68,11 +69,10 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Image? Logo { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// The user's watch list.
|
||||
// /// </summary>
|
||||
// // [SerializeIgnore]
|
||||
// // public ICollection<WatchInfo>? Watchlist { get; set; }
|
||||
/// <summary>
|
||||
/// User settings
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Settings { get; set; } = new();
|
||||
|
||||
public User() { }
|
||||
|
||||
|
@ -315,6 +315,18 @@ namespace Kyoo.Postgresql
|
||||
_HasAddedDate<Episode>(modelBuilder);
|
||||
_HasAddedDate<User>(modelBuilder);
|
||||
|
||||
modelBuilder
|
||||
.Entity<User>()
|
||||
.Property(x => x.Settings)
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null),
|
||||
v =>
|
||||
JsonSerializer.Deserialize<Dictionary<string, string>>(
|
||||
v,
|
||||
(JsonSerializerOptions?)null
|
||||
)!
|
||||
)
|
||||
.HasColumnType("json");
|
||||
modelBuilder.Entity<User>().OwnsOne(x => x.Logo);
|
||||
|
||||
modelBuilder
|
||||
|
1304
back/src/Kyoo.Postgresql/Migrations/20231220093441_Settings.Designer.cs
generated
Normal file
1304
back/src/Kyoo.Postgresql/Migrations/20231220093441_Settings.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Kyoo.Postgresql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Settings : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "settings",
|
||||
table: "users",
|
||||
type: "json",
|
||||
nullable: false,
|
||||
defaultValue: "{}"
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(name: "settings", table: "users");
|
||||
}
|
||||
}
|
||||
}
|
@ -589,6 +589,11 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnType("text[]")
|
||||
.HasColumnName("permissions");
|
||||
|
||||
b.Property<string>("Settings")
|
||||
.IsRequired()
|
||||
.HasColumnType("json")
|
||||
.HasColumnName("settings");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
|
Loading…
x
Reference in New Issue
Block a user