Skip to content

Commit

Permalink
Add more demo data
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Oct 16, 2023
1 parent 0aaaa25 commit 84d499c
Show file tree
Hide file tree
Showing 16 changed files with 453 additions and 262 deletions.
2 changes: 2 additions & 0 deletions messages/en.msg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions messages/fr.msg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions messages/ro.msg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions messages/ru.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
NoCategoriesFound: Категории не найдены
NoOffersFound: Предложений не найдено
Unassigned: Не назначена
AreYouSureYouWantToTakeOnThisTask: Вы уверены, что хотите взять на себя эту задачу?
AssignToMe: Назначить мне
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 1 addition & 8 deletions src/Demo/DemoDataEN.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ populateEN = do
, businessEmail = Just "[email protected]"
}

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 "[email protected]"
}
insert_ business

insert_ $ Contents { contentsSection = "CONTACTS"
, contentsContent = Textarea [st|
Expand Down
120 changes: 117 additions & 3 deletions src/Demo/DemoDataRU.hs
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
}

insert_ business

insert_ $ Contents { contentsSection = "CONTACTS"
, contentsContent = Textarea $ toStrict $ renderHtml [shamlet|
<section style="margin:0 1rem">
<h3 style="color:gray">Звоните нам
<dl>
<dt>
<i>телефон
<dd>
$maybe phone <- businessPhone business
#{phone}
<dt>
<i>мобильный
<dd>
$maybe mobile <- businessMobile business
#{mobile}
<section style="margin:0 1rem">
<h3 style="color:gray">Напишите нам
<dl>
<dt>
<i>Электронная почта
<dd>
$maybe email <- businessEmail business
#{email}
<section style="margin:0 1rem">
<h3 style="color:gray">Приходите к нам
<dl>
<dt>
<i>Адрес
<dd>
#{businessAddr business}
<p>
<iframe width="100%" height="400px" loding="lazy" title="Salon" style="border:none" src="https://api.mapbox.com/styles/v1/mapbox/streets-v12.html?title=false&zoomwheel=false&access_token=pk.eyJ1IjoiY2l1a3N0YXIiLCJhIjoiY2o1enNibDNsMGNrNDJ3dDhxeTJuc3luMiJ9.Jgc5GdYUMbYwGq-zRWtzfw#15/55.751244/37.618423">
|]
}


insert_ $ Contents { contentsSection = "ABOUT_US"
, contentsContent = Textarea [st|
<h2 style="color:gray">Наша миссия</h2>
<p>
Миссия <i>Салона</i> проста: предложить каждому человеку, входящему в его двери, особую среду, где он может ухаживать и баловать себя, одновременно улучшая свой личный имидж и привнося ощущение благополучия в свою жизнь.
</p>
<h2 style="color:gray">Наш этос</h2>
<p>
Любой человек, пришедший в наш салон, уникален. Мы относимся к каждому уникальному клиенту с учетом его личных потребностей. Мы гордимся тем, что предлагаем услуги, которые ожидает клиент, и лечение, которое ему требуется, и мы будем постоянно переоценивать их требования в зависимости от их образа жизни и тела. Мы никогда не будем предлагать ненужные процедуры и ставим каждого клиента в приоритет. Именно поэтому мы можем с гордостью сказать, что за эти годы у нас накопилась лояльная клиентская база. Мы учимся у них, заботясь о них, и стараемся идти в ногу с последними тенденциями и доступными методами лечения, чтобы всегда удовлетворять потребности наших уважаемых клиентов и любых будущих посетителей.
</p>
<h2 style="color:gray">Наши цели</h2>
<p>
Мы продолжим предлагать новейшие методы лечения, самые инновационные методы, используя лучшие продукты на рынке. И все это в элегантной, чистой и гостеприимной обстановке под руководством обученных, профессиональных и дружелюбных терапевтов. Мы постараемся донести нашу идею о том, что каждый имеет право чувствовать себя хорошо!
</p>
|]
}

pass <- liftIO $ makePassword "root" 17
insert_ $ User { userName = "root"
, userPassword = decodeUtf8 pass
Expand Down
5 changes: 4 additions & 1 deletion src/Handler/AboutUs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import Settings (widgetFile)
import Foundation
( Handler
, Route (ProfileR, AuthR, PhotoPlaceholderR, AccountPhotoR)
, AppMessage (MsgAboutUs, MsgPhoto, MsgUserProfile, MsgLogin, MsgNavigationMenu)
, AppMessage
( MsgAboutUs, MsgPhoto, MsgUserProfile, MsgLogin, MsgNavigationMenu
, MsgNoContentYet
)
)

import Yesod.Persist.Core (YesodPersist(runDB))
Expand Down
5 changes: 4 additions & 1 deletion src/Handler/Book.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ import Foundation
, MsgMinutes, MsgSearch, MsgAddress, MsgCategory, MsgSelect, MsgCancel
, MsgCategories, MsgNoServicesFound, MsgLocation, MsgInvalidBusinessAddress
, MsgInvalidBusinessTimeZoneOffset, MsgInvalidBusinessTimeZone
, MsgUserProfile, MsgNavigationMenu
, MsgUserProfile, MsgNavigationMenu, MsgNoOffersYet, MsgNoOffersFound
, MsgNoCategoriesFound
)
)

Expand Down Expand Up @@ -364,6 +365,7 @@ postBookOffersR = do
_ -> do
msgs <- getMessages
let items = ioffers
formPostOffers <- newIdent
defaultLayout $ do
setTitleI MsgOffers
$(widgetFile "book/offers/banner")
Expand All @@ -379,6 +381,7 @@ getBookOffersR = do
(fw,et) <- generateFormPost $ formOffers items offers
msgs <- getMessages
setUltDestCurrent
formPostOffers <- newIdent
defaultLayout $ do
setTitleI MsgOffers
$(widgetFile "book/offers/offers")
Expand Down
5 changes: 3 additions & 2 deletions src/Handler/Contacts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module Handler.Contacts (getContactR, section) where

import Text.Hamlet (Html)
import Yesod.Auth (maybeAuth, Route (LoginR))
import Yesod.Core (Yesod(defaultLayout), preEscapedToMarkup, setUltDestCurrent, getMessages)
import Yesod.Core
( Yesod(defaultLayout), preEscapedToMarkup, setUltDestCurrent, getMessages)
import Yesod.Core.Widget (setTitleI)
import Yesod.Form.Fields (unTextarea)
import Settings (widgetFile)
Expand All @@ -24,7 +25,7 @@ import Foundation
, Route (ProfileR, AuthR, PhotoPlaceholderR, AccountPhotoR)
, AppMessage
( MsgContactUs, MsgContact, MsgPhoto, MsgNavigationMenu, MsgUserProfile
, MsgLogin
, MsgLogin, MsgNoContentYet
)
)

Expand Down
Loading

0 comments on commit 84d499c

Please sign in to comment.