Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fixing profile_edit

Cette révision appartient à :
akuma06 2017-07-03 02:16:39 +02:00
Parent 1ca1f364a0
révision 929bf0e71b
5 fichiers modifiés avec 15 ajouts et 13 suppressions

Voir le fichier

@ -130,13 +130,14 @@ func UserProfileFormHandler(c *gin.Context) {
userSettingsForm := userValidator.UserSettingsForm{}
if len(c.PostForm("email")) > 0 {
if userValidator.EmailValidation(c.PostForm("email")) {
messages.AddErrorf("email", "email_not_valid")
if !userValidator.EmailValidation(c.PostForm("email")) {
messages.AddErrorT("email", "email_not_valid")
}
}
if len(c.PostForm("username")) > 0 {
userValidator.ValidateUsername(c.PostForm("username"))
messages.AddErrorf("username", "username_illegal")
if !userValidator.ValidateUsername(c.PostForm("username")) {
messages.AddErrorT("username", "username_illegal")
}
}
if !messages.HasErrors() {
@ -170,6 +171,7 @@ func UserProfileFormHandler(c *gin.Context) {
}
}
}
fmt.Println(messages.GetAllErrors())
availableLanguages := publicSettings.GetAvailableLanguages()
userProfileEditTemplate(c, userProfile, userForm, availableLanguages)
}

Voir le fichier

@ -10,7 +10,7 @@
<a class="nav-btn" href="/user/{{ User.ID }}/{{ User.Username }}">{{ T("profile")}}</a>
<a class="nav-btn" href="/notifications">{{ T("my_notifications")}} <span class="badge">({{ User.GetUnreadNotifications() }})</span></a>
<a class="nav-btn" href="/user/{{ User.ID }}/{{ User.Username }}/edit">{{ T("settings")}}</a>
{{if User && User.HasAdmin}}<a class="nav-btn" href="/mod">{{ T("moderation")}}</a>{{end}}
{{if User.HasAdmin()}}<a class="nav-btn" href="/mod">{{ T("moderation")}}</a>{{end}}
<form action="/logout" method="POST">{{ yield csrf_field() }}<input class="nav-btn" type="submit" name="logout" value="{{ T("sign_out")}}"></form>
</div>
{{ else }}

Voir le fichier

@ -1,7 +1,7 @@
{{ extends "layouts/index_site" }}
{{ import "layouts/partials/helpers/search" }}
{{block title()}}{{ T("home")}}{{end}}
{{block contclass()}}{{if User && User.HasAdmin() }}content-admin{{end}}{{end}}
{{block contclass()}}{{if User.HasAdmin() }}content-admin{{end}}{{end}}
{{block additional_header()}}
<link rel="stylesheet" href="/css/flags/flags.min.css">
<link rel="stylesheet" href="/css/flags/custom_flags.css">
@ -15,7 +15,7 @@
<table>
<thead class="torrent-info">
<tr>
{{ if User && User.HasAdmin }}
{{ if User.HasAdmin() }}
<th class="tr-cb hide"><input type="checkbox" name="select_all" onchange="TorrentsMod.selectAll(this.checked)"></th>
{{end}}
<th class="tr-cat">{{ T("category")}}</th>
@ -42,7 +42,7 @@
<tbody id="torrentListResults">
{{ range Models}}
<tr id="torrent_{{ .ID }}" class="torrent-info {{if .Status == 2}}remake{{else if .Status == 3}}trusted{{else if .Status == 4}}aplus{{end}}" >
{{ if User && User.HasAdmin }}
{{ if User.HasAdmin() }}
<td class="tr-cb hide">
<input data-name="{{ .Name }}" type="checkbox" id="torrent_cb_{{ .ID }}" name="torrent_id" value="{{ .ID }}">
</td>
@ -96,7 +96,7 @@
</tbody>
</table>
</div>
{{ if User && User.HasAdmin }}
{{ if User.HasAdmin() }}
<div class="modtools">
<button id="show_actions" class="form-input" data-toggle-text="{{ T("hide_mod_tools")}}">{{ T("show_mod_tools")}}</button>
<span class="actions">
@ -159,7 +159,7 @@
<script type="text/javascript" src="{{ URL.Parse("/js/query.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/modal.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/torrents.js") }}"></script>
{{ if User && User.HasAdmin }}
{{ if User.HasAdmin() }}
<script type="text/javascript" src="{{ URL.Parse("/js/translation.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/torrentsMod.js") }}"></script>
<script type="text/javascript">
@ -228,7 +228,7 @@
<script type="text/javascript">
Templates.Add("torrents.item", function(torrent) {
return "<tr id=\"torrent_" + torrent.id + "\" class=\"torrent-info"+ ((torrent.status == 2) ? " remake" : ((torrent.status == 3) ? " trusted" : ((torrent.status == 3) ? " aplus" : "" )))+"\">"+
{{ if User && User.HasAdmin }}
{{ if User.HasAdmin() }}
"<td class=\"tr-cb\""+ ((TorrentsMod.enabled) ? "style=\"display:table-cell;\"" : "") +">"+
"<input data-name=\""+Templates.EncodeEntities(torrent.name)+"\" type=\"checkbox\" id=\"torrent_cb_"+torrent.id+"\" name=\"torrent_id\" value=\""+torrent.id+"\">"+
"</td>"+

Voir le fichier

@ -52,7 +52,7 @@
{{end}}
{{ if User.ID > 0}}
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
{{ if User && User.HasAdmin}}
{{ if User.HasAdmin()}}
<a href="/mod/torrent/delete?id={{ Torrent.ID }}" class="form-input btn-red" onclick="if (!confirm('{{ T("are_you_sure") }}')) return false;">{{ T("delete") }}</a>
<a href="/mod/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
{{ else if User.CurrentUserIdentical(Torrent.UploaderID) }}

Voir le fichier

@ -123,7 +123,7 @@
</select> <br>
{{ yield errors(name="followed_email")}}
{{end}}
{{ if User && User.HasAdmin}}
{{ if User.HasAdmin()}}
<h3>{{ T("moderation")}}</h3>
<label class="input-label">{{ T("username")}}:</label> <br>
<input class="form-input up-input" name="username" id="username" type="text" value="{{UserProfile.Username}}">