1. Luke Plant
  2. haskellblog

Commits

Luke Plant  committed 275e0a1

Added 'hidden' and 'response' fields to Comment schema

  • Participants
  • Parent commits c797d00
  • Branches default

Comments (0)

Files changed (5)

File schema/install.sql

View file
     email TEXT,
     text_raw TEXT,
     text_formatted TEXT,
-    format_id INTEGER REFERENCES format(id)
+    format_id INTEGER REFERENCES format(id),
+    hidden INTEGER,
+    response TEXT
   );
 
 CREATE TABLE users (

File src/Blog/Comment.hs

View file
     , text_raw :: String
     , text_formatted :: String
     , format :: Format
+    , hidden :: Bool
+    , response :: String
     } deriving (Show, Eq, Data, Typeable)

File src/Blog/Forms.hs

View file
                , text_raw = ""
                , text_formatted = undefined
                , format = Plaintext
+               , hidden = False
+               , response = ""
                }
 
 instance Param Format where
                     , text_raw = text
                     , text_formatted = getFormatter format $ text
                     , format = format
+                    , hidden = False
+                    , response = ""
                     }
              , Map.fromList errors
              , if test_ts > 0 then test_ts else ts

File src/Blog/Model.hs

View file
                    , "text_raw"
                    , "text_formatted"
                    , "format_id"
+                   , "hidden"
+                   , "response"
                    ] [
                     toSql $ Cm.post_id cm
                    , toSql $ Cm.timestamp cm
                    , toSql $ Cm.text_raw cm
                    , toSql $ Cm.text_formatted cm
                    , toSql $ fromEnum $ Cm.format cm
+                   , toSql $ Cm.hidden cm
+                   , toSql $ Cm.response cm
                    ]
   newid <- getDbId cn
   return cm { Cm.uid = newid }
 getCategoriesForPostQuery = "SELECT categories.id, categories.name, categories.slug FROM categories INNER JOIN post_categories ON categories.id = post_categories.category_id WHERE post_categories.post_id = ? ORDER BY categories.slug;"
 getCategoriesBulkQuery ids= "SELECT categories.id, categories.name, categories.slug, post_categories.post_id FROM categories INNER JOIN post_categories ON categories.id = post_categories.category_id WHERE post_categories.post_id IN " ++ sqlInIds ids ++ " ORDER BY categories.slug;"
 
-getCommentByIdQuery      = "SELECT id, post_id, timestamp, name, email, text_raw, text_formatted, format_id FROM comments WHERE id = ?;"
-getCommentsForPostQuery  = "SELECT id, '',      timestamp, name, email, '',       text_formatted, ''        FROM comments WHERE post_id = ? ORDER BY timestamp ASC;"
+getCommentByIdQuery      = "SELECT id, post_id, timestamp, name, email, text_raw, text_formatted, format_id, hidden, response FROM comments WHERE id = ?;"
+getCommentsForPostQuery  = "SELECT id, '',      timestamp, name, email, '',       text_formatted, '',        hidden, response FROM comments WHERE post_id = ? ORDER BY timestamp ASC;"
 
 getPasswordForUsernameQuery = "SELECT password FROM users WHERE username = ?;"
 setPasswordForUsernameQuery = "UPDATE users SET password = ? WHERE username = ?;"
                , Cm.text_raw = fromSql (row !! 5)
                , Cm.text_formatted = fromSql (row !! 6)
                , Cm.format = toEnum $ fromSql (row !! 7)
+               , Cm.hidden = fromSql (row !! 8)
+               , Cm.response = fromSql (row !! 9)
                }
 
 ---- Public API for queries ----

File src/Migrate.hs

View file
                                      , Cm.text_raw = row !! 5
                                      , Cm.text_formatted = row !! 5
                                      , Cm.format = Formats.Rawhtml
+                                     , Cm.hidden = False
+                                     , Cm.response = ""
                                      }
 -- Writing