From 84d499c63c4f225742ed058a8dc597de30e286e0 Mon Sep 17 00:00:00 2001 From: ciukstar Date: Tue, 17 Oct 2023 02:40:56 +0300 Subject: [PATCH] Add more demo data --- messages/en.msg | 2 + messages/fr.msg | 2 + messages/ro.msg | 2 + messages/ru.msg | 2 + package.yaml | 1 + src/Demo/DemoDataEN.hs | 9 +- src/Demo/DemoDataRU.hs | 120 ++++++- src/Handler/AboutUs.hs | 5 +- src/Handler/Book.hs | 5 +- src/Handler/Contacts.hs | 5 +- static/img/Salon-ERD.svg | 493 +++++++++++++++------------- templates/about/about.hamlet | 5 + templates/book/offers/banner.hamlet | 4 +- templates/book/offers/offers.hamlet | 15 +- templates/book/search/search.hamlet | 40 ++- templates/contacts/contact.hamlet | 5 + 16 files changed, 453 insertions(+), 262 deletions(-) diff --git a/messages/en.msg b/messages/en.msg index ef2f1eb..59bd617 100644 --- a/messages/en.msg +++ b/messages/en.msg @@ -1,3 +1,5 @@ +NoCategoriesFound: No categories found +NoOffersFound: No offers found Unassigned: Unassigned AreYouSureYouWantToTakeOnThisTask: Are you sure you want to take on this task? AssignToMe: Assign to Me diff --git a/messages/fr.msg b/messages/fr.msg index 7494f21..aa31cf9 100644 --- a/messages/fr.msg +++ b/messages/fr.msg @@ -1,3 +1,5 @@ +NoCategoriesFound: Aucune catégorie trouvée +NoOffersFound: Aucune offre trouvée Unassigned: Non attribué AreYouSureYouWantToTakeOnThisTask: Êtes-vous sûr de vouloir assumer cette tâche ? AssignToMe: Attribuez-moi diff --git a/messages/ro.msg b/messages/ro.msg index 0a1e843..86be0fa 100644 --- a/messages/ro.msg +++ b/messages/ro.msg @@ -1,3 +1,5 @@ +NoCategoriesFound: Nu a fost găsită nicio categorie +NoOffersFound: Nu au fost găsite oferte Unassigned: Nealocat AreYouSureYouWantToTakeOnThisTask: Sunteți sigur că doriți să vă ocupați de această sarcină? AssignToMe: Atribuie mie diff --git a/messages/ru.msg b/messages/ru.msg index b304f95..0891467 100644 --- a/messages/ru.msg +++ b/messages/ru.msg @@ -1,3 +1,5 @@ +NoCategoriesFound: Категории не найдены +NoOffersFound: Предложений не найдено Unassigned: Не назначена AreYouSureYouWantToTakeOnThisTask: Вы уверены, что хотите взять на себя эту задачу? AssignToMe: Назначить мне diff --git a/package.yaml b/package.yaml index 576bd9f..2f261e4 100644 --- a/package.yaml +++ b/package.yaml @@ -48,6 +48,7 @@ dependencies: - listsafe - base64-bytestring - transformers +- blaze-html # The library contains all of our application code. The executable # defined below is just a thin wrapper. diff --git a/src/Demo/DemoDataEN.hs b/src/Demo/DemoDataEN.hs index 2089336..70421c6 100644 --- a/src/Demo/DemoDataEN.hs +++ b/src/Demo/DemoDataEN.hs @@ -68,14 +68,7 @@ populateEN = do , businessEmail = Just "salon@mail.uk" } - insert_ $ Business { businessName = "Salon" - , businessAddr = "73 Parsons Green Ln Fulham London SW6 4JA" - , businessTzo = utc - , businessTz = "Europe/London" - , businessPhone = Just "020-7736-6600" - , businessMobile = Just "567-274-7469" - , businessEmail = Just "salon@mail.uk" - } + insert_ business insert_ $ Contents { contentsSection = "CONTACTS" , contentsContent = Textarea [st| diff --git a/src/Demo/DemoDataRU.hs b/src/Demo/DemoDataRU.hs index 8455bff..1d0da7e 100644 --- a/src/Demo/DemoDataRU.hs +++ b/src/Demo/DemoDataRU.hs @@ -1,18 +1,132 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} module Demo.DemoDataRU (populateRU) where +import Text.Blaze.Html.Renderer.Text (renderHtml) +import Text.Hamlet (shamlet, hamlet) +import Text.Shakespeare.Text (st) +import qualified Data.ByteString.Base64 as B64 (decode) import Data.Text.Encoding (decodeUtf8) +import Data.Text.Lazy (fromStrict, toStrict) +import Data.Time.Calendar (addDays) +import Data.Time.Clock (getCurrentTime, UTCTime (utctDay,utctDayTime), DiffTime) +import Data.Time.Format (parseTimeM, defaultTimeLocale) +import Data.Time.LocalTime (timeToTimeOfDay, utc, TimeZone (TimeZone)) import Control.Monad.IO.Class (MonadIO (liftIO)) import ClassyPrelude.Yesod (ReaderT) +import Yesod.Form.Fields (Textarea (Textarea)) +import Yesod.Auth.Util.PasswordStore (makePassword) import Database.Persist.Sql (SqlBackend) -import Database.Persist ( PersistStoreWrite(insert_) ) +import Database.Persist ( PersistStoreWrite(insert_, insert) ) + +import Model + ( User (User, userName, userPassword, userAdmin, userEmail, userFullName) + , UserPhoto (UserPhoto, userPhotoUser, userPhotoPhoto, userPhotoMime) + , Service + ( Service, serviceName, serviceDescr, serviceGroup, serviceOverview + , servicePublished, serviceDuration + ) + , Thumbnail (Thumbnail, thumbnailService, thumbnailPhoto, thumbnailMime, thumbnailAttribution) + , Offer + ( Offer, offerName, offerPrice, offerPrefix + , offerSuffix, offerDescr, offerService + ) + , EmplStatus (EmplStatusEmployed, EmplStatusDismissed) + , Staff (Staff, staffName, staffStatus, staffPhone, staffMobile, staffEmail, staffUser) + , StaffPhoto (StaffPhoto, staffPhotoPhoto, staffPhotoMime, staffPhotoStaff) + , Role (Role, roleStaff, roleService, roleName, roleRating) + , Contents (Contents, contentsSection, contentsContent) + , BookStatus (BookStatusRequest) + , Book + ( Book, bookCustomer, bookOffer, bookRole, bookDay, bookTime, bookTzo + , bookTz, bookStatus, bookAddr + ) + , Business + ( Business, businessName, businessAddr, businessTzo, businessTz + , businessPhone, businessMobile, businessEmail + ) + , Hist + ( Hist, histBook, histLogtime, histDay, histTime, histAddr, histTzo + , histStatus, histUser, histTz, histRoleName, histStaffName + ) + ) +import Data.FileEmbed (embedFile) +import Demo.DemoPhotos + ( man01, man02, man03, man04, man05, man06 + , woman01, woman02, woman03, woman04, woman05 + ) -import Model (User(User, userName, userPassword, userAdmin, userEmail, userFullName)) -import Yesod.Auth.Util.PasswordStore (makePassword) populateRU :: MonadIO m => ReaderT SqlBackend m () populateRU = do + + (now,today,time) <- liftIO $ getCurrentTime >>= \x -> return (x ,utctDay x,timeToTimeOfDay (utctDayTime x)) + + let business = Business { businessName = "Салон" + , businessAddr = "Россия, г. Москва, проезд Воскресенские Ворота, 1А, Москва, 109012" + , businessTzo = TimeZone 180 False "MSK" + , businessTz = "Europe/Moscow" + , businessPhone = Just "+7 (958) 759-52-25" + , businessMobile = Just "940(8537)418-74-67" + , businessEmail = Just "salon@mail.ru" + } + + insert_ business + + insert_ $ Contents { contentsSection = "CONTACTS" + , contentsContent = Textarea $ toStrict $ renderHtml [shamlet| +
+

Звоните нам +
+
+ телефон +
+ $maybe phone <- businessPhone business + #{phone} +
+ мобильный +
+ $maybe mobile <- businessMobile business + #{mobile} +
+

Напишите нам +
+
+ Электронная почта +
+ $maybe email <- businessEmail business + #{email} +
+

Приходите к нам +
+
+ Адрес +
+ #{businessAddr business} +

+