Filter member directory by HereFor
This commit is contained in:
parent
f52fa47f3e
commit
6eb51cf545
|
@ -21,7 +21,9 @@ func Search() http.HandlerFunc {
|
|||
"last_login_at desc",
|
||||
"created_at desc",
|
||||
"username",
|
||||
"username desc",
|
||||
"lower(name)",
|
||||
"lower(name) desc",
|
||||
"distance",
|
||||
}
|
||||
|
||||
|
@ -33,6 +35,7 @@ func Search() http.HandlerFunc {
|
|||
gender = r.FormValue("gender")
|
||||
orientation = r.FormValue("orientation")
|
||||
maritalStatus = r.FormValue("marital_status")
|
||||
hereFor = r.FormValue("here_for")
|
||||
sort = r.FormValue("sort")
|
||||
sortOK bool
|
||||
ageMin int
|
||||
|
@ -87,6 +90,7 @@ func Search() http.HandlerFunc {
|
|||
Gender: gender,
|
||||
Orientation: orientation,
|
||||
MaritalStatus: maritalStatus,
|
||||
HereFor: hereFor,
|
||||
Certified: isCertified != "false",
|
||||
InnerCircle: isCertified == "circle",
|
||||
AgeMin: ageMin,
|
||||
|
@ -109,6 +113,7 @@ func Search() http.HandlerFunc {
|
|||
"Gender": gender,
|
||||
"Orientation": orientation,
|
||||
"MaritalStatus": maritalStatus,
|
||||
"HereFor": hereFor,
|
||||
"EmailOrUsername": username,
|
||||
"AgeMin": ageMin,
|
||||
"AgeMax": ageMax,
|
||||
|
|
|
@ -188,6 +188,7 @@ type UserSearch struct {
|
|||
Gender string
|
||||
Orientation string
|
||||
MaritalStatus string
|
||||
HereFor string
|
||||
Certified bool
|
||||
InnerCircle bool
|
||||
AgeMin int
|
||||
|
@ -278,6 +279,16 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er
|
|||
placeholders = append(placeholders, "marital_status", search.MaritalStatus)
|
||||
}
|
||||
|
||||
if search.HereFor != "" {
|
||||
wheres = append(wheres, `
|
||||
EXISTS (
|
||||
SELECT 1 FROM profile_fields
|
||||
WHERE user_id = users.id AND name = ? AND value = ?
|
||||
)
|
||||
`)
|
||||
placeholders = append(placeholders, "here_for", search.HereFor)
|
||||
}
|
||||
|
||||
if search.Certified {
|
||||
wheres = append(wheres, "certified = ?", "status = ?")
|
||||
placeholders = append(placeholders, search.Certified, UserStatusActive)
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
</button>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="columns is-multiline">
|
||||
<div class="columns">
|
||||
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
|
@ -100,9 +100,9 @@
|
|||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label">Age:</label>
|
||||
<div class="columns is-mobile">
|
||||
<div class="columns is-mobile is-gapless">
|
||||
<div class="column">
|
||||
<div class="select">
|
||||
<div class="select is-fullwidth">
|
||||
<select name="age_min">
|
||||
<option value="">Min</option>
|
||||
{{range IterRange 18 120}}
|
||||
|
@ -110,7 +110,9 @@
|
|||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="select">
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="select is-fullwidth">
|
||||
<select name="age_max">
|
||||
<option value="">Max</option>
|
||||
{{range IterRange 18 120}}
|
||||
|
@ -137,6 +139,9 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="columns is-centered">
|
||||
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="orientation">Orientation:</label>
|
||||
|
@ -165,23 +170,38 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="here_for">Here for:</label>
|
||||
<div class="select is-fullwidth">
|
||||
<select id="here_for" name="here_for">
|
||||
<option value=""></option>
|
||||
{{range .Enum.HereFor}}
|
||||
<option value="{{.}}"{{if eq $Root.HereFor .}} selected{{end}}>{{.}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-narrow pr-1">
|
||||
<strong>Sort by:</strong>
|
||||
</div>
|
||||
<div class="column is-narrow pl-1">
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="sort">Sort by:</label>
|
||||
<div class="select is-full-width">
|
||||
<select id="sort" name="sort">
|
||||
<option value="last_login_at desc"{{if eq .Sort "last_login_at desc"}} selected{{end}}>Last login</option>
|
||||
<option value="created_at desc"{{if eq .Sort "created_at desc"}} selected{{end}}>Signup date</option>
|
||||
<option value="username"{{if eq .Sort "username"}} selected{{end}}>Username (a-z)</option>
|
||||
<option value="username desc"{{if eq .Sort "username desc"}} selected{{end}}>Username (z-a)</option>
|
||||
<option value="lower(name)"{{if eq .Sort "lower(name)"}} selected{{end}}>Name (a-z)</option>
|
||||
<option value="lower(name) desc"{{if eq .Sort "lower(name) desc"}} selected{{end}}>Name (z-a)</option>
|
||||
<option value="distance"{{if eq .Sort "distance"}} selected{{end}}>Distance to me</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
</div>
|
||||
|
||||
<div class="column has-text-right">
|
||||
<a href="/members" class="button">Reset</a>
|
||||
<button type="submit" class="button is-success">
|
||||
<span>Search</span>
|
||||
|
|
Loading…
Reference in New Issue
Block a user