Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

New User status (#957)

Status for scrapped user
They can't log in and an explicit error message is shown when they try
explaining that they need to contact the moderators
They are displayed as simple members on the front-end however
Cette révision appartient à :
akuma06 2017-06-07 02:59:46 +02:00 révisé par ewhal
Parent fdce17d52c
révision 752544a52c
5 fichiers modifiés avec 17 ajouts et 0 suppressions

Voir le fichier

@ -17,6 +17,8 @@ const (
UserStatusTrusted = 1
// UserStatusModerator : Int for User status moderator
UserStatusModerator = 2
// UserStatusScrapped : Int for User status scrapped
UserStatusScrapped = 3
)
// User model
@ -93,6 +95,11 @@ func (u *User) IsModerator() bool {
return u.Status == UserStatusModerator
}
// IsScrapped : Return true if user is a scrapped user
func (u *User) IsScrapped() bool {
return u.Status == UserStatusScrapped
}
// GetUnreadNotifications : Get unread notifications from a user
func (u *User) GetUnreadNotifications() int {
if u.UnreadNotifications == 0 {

Voir le fichier

@ -106,6 +106,9 @@ func SetCookieHandler(w http.ResponseWriter, r *http.Request, email string, pass
if user.IsBanned() {
return http.StatusUnauthorized, errors.New("Account banned")
}
if user.IsScrapped() {
return http.StatusUnauthorized, errors.New("Account need activation from Moderators, please contact us")
}
maxAge := getMaxAge()
validUntil := timeHelper.FewDurationLater(time.Duration(maxAge) * time.Second)

Voir le fichier

@ -36,6 +36,8 @@ func GetRole(user *model.User) string {
return "Banned"
case model.UserStatusMember:
return "Member"
case model.UserStatusScrapped:
return "Member"
case model.UserStatusTrusted:
return "Trusted Member"
case model.UserStatusModerator:

Voir le fichier

@ -173,6 +173,7 @@
{{ if eq .Status 2 }} <!-- just so that it shows correctly -->
<option value="2" selected>{{ call $.T "moderator"}}</option>
{{end}}
<option value="3" {{ if eq .Status 3 }}selected{{end}}>{{ call $.T "scrapped_user"}}</option>
</select>
{{ range (index $.FormErrors "status")}}
<p class="error-text">{{ . }}</p>

Voir le fichier

@ -551,6 +551,10 @@
"id": "trusted_member",
"translation": "Trusted member"
},
{
"id": "scrapped_user",
"translation": "Scrapped user"
},
{
"id": "moderator",
"translation": "Moderator"