From fee94a2b7d9420dc6fdb4a6ad35308b957569d3c Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 11 Nov 2024 15:00:15 +0100 Subject: [PATCH] add storeId for MatchScheduler --- PadelClub/Data/Gen/BaseMatchScheduler.swift | 13 ++++++++++--- PadelClub/Data/Gen/BaseMonthData.swift | 4 ++-- PadelClub/Data/Gen/MatchScheduler.json | 5 +++++ PadelClub/Data/MatchScheduler.swift | 2 +- PadelClub/Data/README.md | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/PadelClub/Data/Gen/BaseMatchScheduler.swift b/PadelClub/Data/Gen/BaseMatchScheduler.swift index cc962bb..2fbcda4 100644 --- a/PadelClub/Data/Gen/BaseMatchScheduler.swift +++ b/PadelClub/Data/Gen/BaseMatchScheduler.swift @@ -8,7 +8,7 @@ import SwiftUI @Observable class BaseMatchScheduler: ModelObject, Storable, Codable { - static func resourceName() -> String { return "match-schedulers" } + static func resourceName() -> String { return "match-scheduler" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } @@ -26,6 +26,7 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { var groupStageChunkCount: Int? = nil var overrideCourtsUnavailability: Bool = false var shouldTryToFillUpCourtsAvailable: Bool = false + var storeId: String? = nil init( id: String = Store.randomId(), @@ -41,7 +42,8 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { shouldEndRoundBeforeStartingNext: Bool = false, groupStageChunkCount: Int? = nil, overrideCourtsUnavailability: Bool = false, - shouldTryToFillUpCourtsAvailable: Bool = false + shouldTryToFillUpCourtsAvailable: Bool = false, + storeId: String? = nil ) { super.init() self.id = id @@ -58,6 +60,7 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { self.groupStageChunkCount = groupStageChunkCount self.overrideCourtsUnavailability = overrideCourtsUnavailability self.shouldTryToFillUpCourtsAvailable = shouldTryToFillUpCourtsAvailable + self.storeId = storeId } enum CodingKeys: String, CodingKey { @@ -75,6 +78,7 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { case _groupStageChunkCount = "groupStageChunkCount" case _overrideCourtsUnavailability = "overrideCourtsUnavailability" case _shouldTryToFillUpCourtsAvailable = "shouldTryToFillUpCourtsAvailable" + case _storeId = "storeId" } required init(from decoder: Decoder) throws { @@ -94,6 +98,7 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { self.groupStageChunkCount = try container.decodeIfPresent(Int.self, forKey: ._groupStageChunkCount) ?? nil self.overrideCourtsUnavailability = try container.decodeIfPresent(Bool.self, forKey: ._overrideCourtsUnavailability) ?? false self.shouldTryToFillUpCourtsAvailable = try container.decodeIfPresent(Bool.self, forKey: ._shouldTryToFillUpCourtsAvailable) ?? false + self.storeId = try container.decodeIfPresent(String.self, forKey: ._storeId) ?? nil } func encode(to encoder: Encoder) throws { @@ -112,6 +117,7 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { try container.encode(self.groupStageChunkCount, forKey: ._groupStageChunkCount) try container.encode(self.overrideCourtsUnavailability, forKey: ._overrideCourtsUnavailability) try container.encode(self.shouldTryToFillUpCourtsAvailable, forKey: ._shouldTryToFillUpCourtsAvailable) + try container.encode(self.storeId, forKey: ._storeId) } func tournamentValue() -> Tournament? { @@ -134,5 +140,6 @@ class BaseMatchScheduler: ModelObject, Storable, Codable { self.groupStageChunkCount = matchscheduler.groupStageChunkCount self.overrideCourtsUnavailability = matchscheduler.overrideCourtsUnavailability self.shouldTryToFillUpCourtsAvailable = matchscheduler.shouldTryToFillUpCourtsAvailable + self.storeId = matchscheduler.storeId } -} \ No newline at end of file +} diff --git a/PadelClub/Data/Gen/BaseMonthData.swift b/PadelClub/Data/Gen/BaseMonthData.swift index 691529a..5ee2df1 100644 --- a/PadelClub/Data/Gen/BaseMonthData.swift +++ b/PadelClub/Data/Gen/BaseMonthData.swift @@ -8,7 +8,7 @@ import SwiftUI @Observable class BaseMonthData: ModelObject, Storable, Codable { - static func resourceName() -> String { return "month-datas" } + static func resourceName() -> String { return "month-data" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } @@ -110,4 +110,4 @@ class BaseMonthData: ModelObject, Storable, Codable { self.dataModelIdentifier = monthdata.dataModelIdentifier self.fileModelIdentifier = monthdata.fileModelIdentifier } -} \ No newline at end of file +} diff --git a/PadelClub/Data/Gen/MatchScheduler.json b/PadelClub/Data/Gen/MatchScheduler.json index 500bc3d..a9611b1 100644 --- a/PadelClub/Data/Gen/MatchScheduler.json +++ b/PadelClub/Data/Gen/MatchScheduler.json @@ -68,6 +68,11 @@ "name": "shouldTryToFillUpCourtsAvailable", "type": "Bool", "defaultValue": "false" + }, + { + "name": "storeId", + "type": "String", + "optional": true } ] } diff --git a/PadelClub/Data/MatchScheduler.swift b/PadelClub/Data/MatchScheduler.swift index d603864..27ee626 100644 --- a/PadelClub/Data/MatchScheduler.swift +++ b/PadelClub/Data/MatchScheduler.swift @@ -10,7 +10,7 @@ import LeStorage import SwiftUI @Observable -final class MatchScheduler : BaseMatchScheduler { +final class MatchScheduler: BaseMatchScheduler, SideStorable { // static func resourceName() -> String { return "match-scheduler" } // static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/README.md b/PadelClub/Data/README.md index 48056ab..e63debb 100644 --- a/PadelClub/Data/README.md +++ b/PadelClub/Data/README.md @@ -10,6 +10,7 @@ Dans Swift: Dans Django: - Ajouter le champ dans la classe +- Si c'est une ForeignKey, toujours mettre un related_name sinon la synchro casse - S'il c'est un champ dans **CustomUser**: - Ajouter le champ à la méthode fields_for_update - Ajouter le champ dans UserSerializer > create > create_user dans serializers.py