mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
wip
This commit is contained in:
parent
ce98428cbe
commit
aba8e48a0e
@ -262,6 +262,10 @@ func UpdateThread(c *fiber.Ctx) error {
|
|||||||
CaptchaID: captchaID,
|
CaptchaID: captchaID,
|
||||||
IsCaptchaActive: config.App.IsCaptchaActive,
|
IsCaptchaActive: config.App.IsCaptchaActive,
|
||||||
Errors: *validationErrors,
|
Errors: *validationErrors,
|
||||||
|
Inputs: repositories.Inputs{
|
||||||
|
Text: text,
|
||||||
|
Files: filesInRequest,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package repositories
|
package repositories
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"mime/multipart"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// DB Structs
|
// DB Structs
|
||||||
// DB Structs
|
// DB Structs
|
||||||
@ -40,18 +43,23 @@ type File struct {
|
|||||||
// HTML Templates Structs
|
// HTML Templates Structs
|
||||||
|
|
||||||
// post-form.html
|
// post-form.html
|
||||||
type Inputs struct {
|
type Errors struct {
|
||||||
Title string
|
Title string
|
||||||
Text string
|
Text string
|
||||||
Files string
|
Files string
|
||||||
}
|
}
|
||||||
|
type Inputs struct {
|
||||||
|
Title string
|
||||||
|
Text string
|
||||||
|
Files []*multipart.FileHeader
|
||||||
|
}
|
||||||
|
|
||||||
// post-form.html
|
// post-form.html
|
||||||
type HtmlFormData struct {
|
type HtmlFormData struct {
|
||||||
FirstPostID int
|
FirstPostID int
|
||||||
CaptchaID string
|
CaptchaID string
|
||||||
IsCaptchaActive bool
|
IsCaptchaActive bool
|
||||||
Errors Inputs
|
Errors
|
||||||
Inputs
|
Inputs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
{{ if eq .FirstPostID 0 }}
|
{{ if eq .FirstPostID 0 }}
|
||||||
<label class="form-error-label" for="title">{{ .Errors.Title }}</label>
|
<label class="form-error-label" for="title">{{ .Errors.Title }}</label>
|
||||||
<input class="form-control" id="postTitle" placeholder="Title" name="title">
|
<input class="form-control" id="postTitle" placeholder="Title" name="title" value={{ .Inputs.Title }}>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<label class="form-error-label" for="text">{{ .Errors.Text }}</label>
|
<label class="form-error-label" for="text">{{ .Errors.Text }}</label>
|
||||||
<textarea class="form-control" id="postText" rows="5" placeholder="Text" name="text"></textarea>
|
<textarea class="form-control" id="postText" rows="5" placeholder="Text" name="text">{{ .Inputs.Text }}</textarea>
|
||||||
<label class="form-error-label" for="files">{{ .Errors.Files }}</label>
|
<label class="form-error-label" for="files">{{ .Errors.Files }}</label>
|
||||||
<input class="form-control" type="file" id="postFiles" multiple name="files">
|
<input class="form-control" type="file" id="postFiles" multiple name="files" accept="image/jpeg, image/png"}>
|
||||||
|
|
||||||
{{ if .IsCaptchaActive }}
|
{{ if .IsCaptchaActive }}
|
||||||
{{ template "captcha" .CaptchaID }}
|
{{ template "captcha" .CaptchaID }}
|
||||||
|
@ -101,8 +101,8 @@ func ValidatePost(title, text string, files []*multipart.FileHeader) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Inputs {
|
func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Errors {
|
||||||
validationErrors := new(repositories.Inputs)
|
validationErrors := repositories.Errors{}
|
||||||
hasErrors := false
|
hasErrors := false
|
||||||
|
|
||||||
if text == "" && len(files) == 0 {
|
if text == "" && len(files) == 0 {
|
||||||
@ -139,7 +139,7 @@ func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if hasErrors {
|
if hasErrors {
|
||||||
return validationErrors
|
return &validationErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user