Minor fix for #2660

This commit is contained in:
Unknwon 2016-02-24 23:59:17 -05:00
parent 5418c2c5e4
commit baaf6046a1
11 changed files with 952 additions and 712 deletions

View File

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current version: 0.8.43 ##### Current version: 0.8.44
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

View File

@ -250,7 +250,7 @@ func runWeb(ctx *cli.Context) {
m.Group("/admin", func() { m.Group("/admin", func() {
m.Get("", adminReq, admin.Dashboard) m.Get("", adminReq, admin.Dashboard)
m.Get("/config", admin.Config) m.Get("/config", admin.Config)
m.Get("/config/testmailer", admin.TestMailer) m.Post("/config/test_mail", admin.SendTestMail)
m.Get("/monitor", admin.Monitor) m.Get("/monitor", admin.Monitor)
m.Group("/users", func() { m.Group("/users", func() {

View File

@ -989,7 +989,9 @@ config.mailer_disable_helo = Disable HELO
config.mailer_name = Name config.mailer_name = Name
config.mailer_host = Host config.mailer_host = Host
config.mailer_user = User config.mailer_user = User
config.mailer_test_email = Test Email Settings config.send_test_mail = Send Test Email
config.test_mail_failed = Fail to send test email to '%s': %v
config.test_mail_sent = Test email has been sent to '%s'.
config.oauth_config = OAuth Configuration config.oauth_config = OAuth Configuration
config.oauth_enabled = Enabled config.oauth_enabled = Enabled
config.cache_config = Cache Configuration config.cache_config = Cache Configuration

View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.8.43.0223" const APP_VER = "0.8.44.0224"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ import (
"path" "path"
"strings" "strings"
"gopkg.in/gomail.v2"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
@ -184,8 +185,6 @@ func SendCollaboratorMail(r macaron.Render, u, doer *models.User, repo *models.R
return nil return nil
} }
func SendTestMail(u *models.User) { func SendTestMail(email string) error {
msg := NewMessage([]string{u.Email}, "Gogs Test Email!", "Gogs Test Email!") return gomail.Send(&Sender{}, NewMessage([]string{email}, "Gogs Test Email!", "Gogs Test Email!").Message)
SendAsync(msg)
} }

View File

@ -2551,6 +2551,9 @@ footer .container .links > *:first-child {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.admin.config #test-mail-btn {
margin-left: 5px;
}
.explore { .explore {
padding-top: 15px; padding-top: 15px;
padding-bottom: 80px; padding-bottom: 80px;

View File

@ -44,7 +44,7 @@
padding: 20px; padding: 20px;
margin: 0; margin: 0;
dd{ dd {
margin-left: 240px; margin-left: 240px;
} }
dt { dt {
@ -57,4 +57,10 @@
white-space: nowrap; white-space: nowrap;
} }
} }
&.config {
#test-mail-btn {
margin-left: 5px;
}
}
} }

View File

@ -175,9 +175,14 @@ func Dashboard(ctx *middleware.Context) {
ctx.HTML(200, DASHBOARD) ctx.HTML(200, DASHBOARD)
} }
func TestMailer(ctx *middleware.Context) { func SendTestMail(ctx *middleware.Context) {
// send a test email to the user's email address and redirect back to Config email := ctx.Query("email")
mailer.SendTestMail(ctx.User) // Send a test email to the user's email address and redirect back to Config
if err := mailer.SendTestMail(email); err != nil {
ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err))
} else {
ctx.Flash.Info(ctx.Tr("admin.config.test_mail_sent", email))
}
ctx.Redirect(setting.AppSubUrl + "/admin/config") ctx.Redirect(setting.AppSubUrl + "/admin/config")
} }

View File

@ -1 +1 @@
0.8.43.0223 0.8.44.0224

View File

@ -1,5 +1,5 @@
{{template "base/head" .}} {{template "base/head" .}}
<div class="admin monitor"> <div class="admin config">
<div class="ui container"> <div class="ui container">
<div class="ui grid"> <div class="ui grid">
{{template "admin/navbar" .}} {{template "admin/navbar" .}}
@ -117,7 +117,16 @@
<dd>{{.Mailer.Host}}</dd> <dd>{{.Mailer.Host}}</dd>
<dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt>
<dd>{{.Mailer.User}}</dd><br> <dd>{{.Mailer.User}}</dd><br>
<a class="ui green button" tabindex="5" href="/admin/config/testmailer">{{.i18n.Tr "admin.config.mailer_test_email"}}</a>{{end}} <form class="ui form" action="{{AppSubUrl}}/admin/config/test_mail" method="post">
{{.CsrfTokenHtml}}
<div class="inline field ui left">
<div class="ui input">
<input type="email" name="email" required>
</div>
</div>
<button class="ui green button" id="test-mail-btn">{{.i18n.Tr "admin.config.send_test_mail"}}</button>
</form>
{{end}}
</dl> </dl>
</div> </div>