Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #319 from sfan5/feature

Email fixes & a feature
Cette révision appartient à :
keo 2017-05-11 01:02:44 +03:00 révisé par GitHub
révision 8074922143
6 fichiers modifiés avec 20 ajouts et 9 suppressions

Voir le fichier

@ -78,6 +78,7 @@ type ApiResultJSON struct {
type CommentJSON struct {
Username string `json:"username"`
UserID int `json:"user_id"`
Content template.HTML `json:"content"`
Date time.Time `json:"date"`
}
@ -107,10 +108,10 @@ func (t *Torrent) ToJSON() TorrentJSON {
magnet := util.InfoHashToMagnet(strings.TrimSpace(t.Hash), t.Name, config.Trackers...)
commentsJSON := make([]CommentJSON, 0, len(t.OldComments)+len(t.Comments))
for _, c := range t.OldComments {
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, Content: template.HTML(c.Content), Date: c.Date})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date})
}
for _, c := range t.Comments {
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt})
}
uploader := ""
if t.Uploader != nil {

Voir le fichier

@ -140,6 +140,7 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
if len(r.PostFormValue("username")) > 0 {
_, err = form.ValidateUsername(r.PostFormValue("username"), err)
}
if len(err) == 0 {
modelHelper.BindValueForm(&b, r)
if (!userPermission.HasAdmin(currentUser)) {
@ -147,15 +148,16 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
}
err = modelHelper.ValidateForm(&b, err)
if len(err) == 0 {
if (b.Email != currentUser.Email) {
userService.SendVerificationToUser(*currentUser, b.Email)
infos["infos"] = append(infos["infos"], fmt.Sprintf(T("email_changed"), b.Email))
b.Email = currentUser.Email // reset, it will be set when user clicks verification
}
userProfile, _, errorUser = userService.UpdateUser(w, &b, currentUser, id)
if errorUser != nil {
err["errors"] = append(err["errors"], errorUser.Error())
}
if len(err) == 0 {
} else {
infos["infos"] = append(infos["infos"], T("profile_updated"))
if (b.Email != currentUser.Email) {
infos["infos"] = append(infos["infos"], fmt.Sprintf(T("email_changed"), b.Email))
}
}
}
}

Voir le fichier

@ -6,7 +6,7 @@
<a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}" class="dropdown-toggle profile-image" data-toggle="dropdown">
<img src="https://www.gravatar.com/avatar/{{ .MD5 }}?s=50" class="img-circle special-img"> {{ .Username }} <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}"><i class="fa fa-cog"></i> Profile</a></li>
<li><a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}"><i class="fa fa-cog"></i> {{T "profile"}}</a></li>
{{if HasAdmin . }}<li><a href="{{ genRoute "mod_index" }}"><i class="fa fa-cog"></i> {{T "moderation"}}</a></li>{{end}}
<li class="divider"></li>
<li><a href="{{ genRoute "user_logout" }}"><i class="fa fa-sign-out"></i> {{ T "sign_out"}}</a></li>

Voir le fichier

@ -1,4 +1,4 @@
{{define "title"}}{{ T "profile_page" .UserProfile.Username }}{{end}}
{{define "title"}}{{ T "profile_page" .UserProfile.Username }}{{end}}
{{define "contclass"}}cont-view{{end}}
{{define "content"}}
{{ range (index $.FormInfos "infos")}}

Voir le fichier

@ -68,7 +68,11 @@
{{ range $index, $element := .Comments }}
<div class="row comment-row" id="comment_{{$index}}">
<div class="col-md-4">
{{if eq .UserID -1}}
<a href="#comment_{{$index}}">{{$index}}</a> {{.Username}}
{{else}}
<a href="#comment_{{$index}}">{{$index}}</a> <a href="{{$.URL.Parse (printf "/user/%d/-" .UserID) }}">{{.Username}}</a>
{{end}}
</div>
<div class="col-md-8">
{{.Content}}

Voir le fichier

@ -570,5 +570,9 @@
{
"id": "mark_as_remake",
"translation": "Als Remake markieren"
},
{
"id": "email_changed",
"translation": "E-Mail erfolgreich geändert! Bitte bestätige die Änderung mit dem Bestätigungs-Link (an %s gesendet)"
}
]