mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 13:44:33 -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/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Abstractions.Models.Attributes;
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
@ -68,11 +69,10 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Image? Logo { get; set; }
|
public Image? Logo { get; set; }
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// The user's watch list.
|
/// User settings
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// // [SerializeIgnore]
|
public Dictionary<string, string> Settings { get; set; } = new();
|
||||||
// // public ICollection<WatchInfo>? Watchlist { get; set; }
|
|
||||||
|
|
||||||
public User() { }
|
public User() { }
|
||||||
|
|
||||||
|
@ -315,6 +315,18 @@ namespace Kyoo.Postgresql
|
|||||||
_HasAddedDate<Episode>(modelBuilder);
|
_HasAddedDate<Episode>(modelBuilder);
|
||||||
_HasAddedDate<User>(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.Entity<User>().OwnsOne(x => x.Logo);
|
||||||
|
|
||||||
modelBuilder
|
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[]")
|
.HasColumnType("text[]")
|
||||||
.HasColumnName("permissions");
|
.HasColumnName("permissions");
|
||||||
|
|
||||||
|
b.Property<string>("Settings")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("json")
|
||||||
|
.HasColumnName("settings");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user