Added create new issue method
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
8bd99fe32e
commit
f3c40e8aea
|
|
@ -6,6 +6,7 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IssueDependency is connection request for receiving issue notification.
|
// IssueDependency is connection request for receiving issue notification.
|
||||||
|
|
@ -13,7 +14,7 @@ type IssueDependency struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
UserID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
UserID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
||||||
IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
||||||
DependencyID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
DependencyID int64 `xorm:"UNIQUE(watch) NOT NULL"`
|
||||||
Created time.Time `xorm:"-"`
|
Created time.Time `xorm:"-"`
|
||||||
CreatedUnix int64 `xorm:"NOT NULL"`
|
CreatedUnix int64 `xorm:"NOT NULL"`
|
||||||
Updated time.Time `xorm:"-"`
|
Updated time.Time `xorm:"-"`
|
||||||
|
|
@ -43,37 +44,38 @@ func (iw *IssueDependency) BeforeUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrUpdateIssueDependency sets or updates a dependency for an issue
|
// CreateOrUpdateIssueDependency sets or updates a dependency for an issue
|
||||||
func CreateOrUpdateIssueDependency(userID, issueID int64, dep int64) error {
|
func CreateOrUpdateIssueDependency(userID, issueID int64, depID int64) error {
|
||||||
id, exists, err := getIssueWatch(x, userID, issueID)
|
err := x.Sync(new(IssueDependency))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
exists, err := issueDepExists(x, issueID, depID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
id = &IssueWatch{
|
newId := new(IssueDependency)
|
||||||
UserID: userID,
|
newId.UserID = userID
|
||||||
IssueID: issueID,
|
newId.IssueID = issueID
|
||||||
IsWatching: isWatching,
|
newId.DependencyID = depID
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := x.Insert(iw); err != nil {
|
if _, err := x.Insert(newId); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iw.IsWatching = isWatching
|
fmt.Println("Dependency exists")
|
||||||
|
// TODO: Should display a message on issue page
|
||||||
if _, err := x.Id(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
func getIssueDep(e Engine, issueID int64) (Dependencies []*IssueDependency, err error) {
|
func issueDepExists(e Engine, issueID int64, depID int64) (exists bool, err error) {
|
||||||
id = new(IssueDependency)
|
var Dependencies = IssueDependency{IssueID: issueID, DependencyID: depID}
|
||||||
err = e.
|
|
||||||
Where("issue_id = ?", issueID).
|
//err = e.Where("issue_id = ?", issueID).Where("dependency_id = ?", depID).Find(&Dependencies)
|
||||||
Find(&Dependencies)
|
exists, err = e.Get(&Dependencies)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -639,7 +639,6 @@ function initRepository() {
|
||||||
if ($('.repository.compare.pull').length > 0) {
|
if ($('.repository.compare.pull').length > 0) {
|
||||||
initFilterSearchDropdown('.choose.branch .dropdown');
|
initFilterSearchDropdown('.choose.branch .dropdown');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Branches
|
// Branches
|
||||||
if ($('.repository.settings.branches').length > 0) {
|
if ($('.repository.settings.branches').length > 0) {
|
||||||
|
|
@ -1454,7 +1453,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
// Emojify
|
// Emojify
|
||||||
emojify.setConfig({
|
emojify.setConfig({
|
||||||
img_dir: suburl + '/img/emoji',
|
img_dir: suburl + '/plugins/emojify/images',
|
||||||
ignore_emoticons: true
|
ignore_emoticons: true
|
||||||
});
|
});
|
||||||
var hasEmoji = document.getElementsByClassName('has-emoji');
|
var hasEmoji = document.getElementsByClassName('has-emoji');
|
||||||
|
|
@ -1824,45 +1823,12 @@ function cancelStopwatch() {
|
||||||
$("#cancel_stopwatch_form").submit();
|
$("#cancel_stopwatch_form").submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeAddManual() {
|
|
||||||
$('.time-add-manual')
|
|
||||||
.modal({
|
|
||||||
duration: 200,
|
|
||||||
onApprove: function() {
|
|
||||||
$('#add_time_manual_form').submit();
|
|
||||||
}
|
|
||||||
}).modal('show')
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleStopwatch() {
|
|
||||||
$("#toggle_stopwatch_form").submit();
|
|
||||||
}
|
|
||||||
function cancelStopwatch() {
|
|
||||||
$("#cancel_stopwatch_form").submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteDependencyModal(id, type) {
|
|
||||||
$('.remove-dependency')
|
|
||||||
.modal({
|
|
||||||
closable: false,
|
|
||||||
duration: 200,
|
|
||||||
onApprove: function () {
|
|
||||||
$('#removeDependencyID').val(id);
|
|
||||||
$('#dependencyType').val(type);
|
|
||||||
$('#removeDependencyForm').submit();
|
|
||||||
}
|
|
||||||
}).modal('show')
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showAddDependencyModal() {
|
function showAddDependencyModal() {
|
||||||
$('.add-dependency')
|
$('.tiny.modal')
|
||||||
.modal({
|
.modal({
|
||||||
duration: 200,
|
duration: 200,
|
||||||
onApprove: function() {
|
onApprove: function() {
|
||||||
$('#addDependencyForm').submit();
|
$('#addDependencyForm').submit();
|
||||||
|
|
||||||
}
|
}
|
||||||
}).modal('show')
|
}).modal('show')
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
func AddDependency(c *context.Context) {
|
func AddDependency(c *context.Context) {
|
||||||
dep, err := strconv.ParseInt(c.Req.PostForm.Get("newDependency"), 10, 64)
|
dep, err := strconv.ParseInt(c.Req.PostForm.Get("newDependency"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Handle(http.StatusInternalServerError, "issue ID is not int", err)
|
c.Handle(http.StatusBadRequest, "issue ID is not int", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,7 +29,8 @@ func AddDependency(c *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.CreateOrUpdateIssueDependency(c.User.ID, issue.ID, dep); err != nil {
|
if err := models.CreateOrUpdateIssueDependency(c.User.ID, issue.ID, dep); err != nil {
|
||||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueWatch", err)
|
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||||
|
fmt.Println("updateerr")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -485,9 +485,6 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Post("/content", repo.UpdateIssueContent)
|
m.Post("/content", repo.UpdateIssueContent)
|
||||||
m.Post("/watch", repo.IssueWatch)
|
m.Post("/watch", repo.IssueWatch)
|
||||||
m.Post("/addDependency", repo.AddDependency)
|
m.Post("/addDependency", repo.AddDependency)
|
||||||
m.Post("/removeDependency", repo.RemoveDependency)
|
|
||||||
m.Combo("/comments").Post(bindIgnErr(auth.CreateCommentForm{}), repo.NewComment)
|
|
||||||
m.Post("/addDependency", repo.AddDependency)
|
|
||||||
m.Group("/times", func() {
|
m.Group("/times", func() {
|
||||||
m.Post("/add", bindIgnErr(auth.AddTimeManuallyForm{}), repo.AddTimeManually)
|
m.Post("/add", bindIgnErr(auth.AddTimeManuallyForm{}), repo.AddTimeManually)
|
||||||
m.Group("/stopwatch", func() {
|
m.Group("/stopwatch", func() {
|
||||||
|
|
@ -501,6 +498,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
m.Combo("/comments").Post(bindIgnErr(auth.CreateCommentForm{}), repo.NewComment)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Post("/labels", repo.UpdateIssueLabel, reqRepoWriter)
|
m.Post("/labels", repo.UpdateIssueLabel, reqRepoWriter)
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/addDependency" id="addDependencyForm">
|
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/addDependency" id="addDependencyForm">
|
||||||
|
{{$.CsrfTokenHtml}}
|
||||||
<div class="ui input">
|
<div class="ui input">
|
||||||
<input type="text" name="newDependency" id="newDependency" placeholder="Issuenumber...">
|
<input type="text" name="newDependency" id="newDependency" placeholder="Issuenumber...">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user