You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue.go 42 kB

11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
9 years ago
9 years ago
9 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
10 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Shows total tracked time in issue and milestone list (#3341) * Show total tracked time in issue and milestone list Show total tracked time at issue page Signed-off-by: Jonas Franz <info@jonasfranz.software> * Optimizing TotalTimes by using SumInt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fixing wrong total times for milestones caused by a missing JOIN Adding unit tests for total times Signed-off-by: Jonas Franz <info@jonasfranz.software> * Logging error instead of ignoring it Signed-off-by: Jonas Franz <info@jonasfranz.software> * Correcting spelling mistakes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change error message to a short version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add error handling to TotalTimes Add variable for totalTimes Signed-off-by: Jonas Franz <info@jonasfranz.de> * Introduce TotalTrackedTimes as variable of issue Load TotalTrackedTimes by loading attributes of IssueList Load TotalTrackedTimes by loading attributes of single issue Add Sec2Time as helper to use it in templates Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fixed test + gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Load TotalTrackedTimes via MilestoneList instead of single requests Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add documentation for MilestoneList Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add documentation for MilestoneList Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change comment from SQL query to description Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit test by using int64 instead of int Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit test by using int64 instead of int Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if timetracker is enabled Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by enabling timetracking Signed-off-by: Jonas Franz <info@jonasfranz.de>
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "bytes"
  7. "errors"
  8. "fmt"
  9. "io"
  10. "io/ioutil"
  11. "net/http"
  12. "strconv"
  13. "strings"
  14. "time"
  15. "github.com/Unknwon/com"
  16. "github.com/Unknwon/paginater"
  17. "code.gitea.io/git"
  18. "code.gitea.io/gitea/models"
  19. "code.gitea.io/gitea/modules/auth"
  20. "code.gitea.io/gitea/modules/base"
  21. "code.gitea.io/gitea/modules/context"
  22. "code.gitea.io/gitea/modules/indexer"
  23. "code.gitea.io/gitea/modules/log"
  24. "code.gitea.io/gitea/modules/markup/markdown"
  25. "code.gitea.io/gitea/modules/notification"
  26. "code.gitea.io/gitea/modules/setting"
  27. "code.gitea.io/gitea/modules/util"
  28. )
  29. const (
  30. tplIssues base.TplName = "repo/issue/list"
  31. tplIssueNew base.TplName = "repo/issue/new"
  32. tplIssueView base.TplName = "repo/issue/view"
  33. tplMilestone base.TplName = "repo/issue/milestones"
  34. tplMilestoneNew base.TplName = "repo/issue/milestone_new"
  35. tplMilestoneEdit base.TplName = "repo/issue/milestone_edit"
  36. tplReactions base.TplName = "repo/issue/view_content/reactions"
  37. issueTemplateKey = "IssueTemplate"
  38. )
  39. var (
  40. // ErrFileTypeForbidden not allowed file type error
  41. ErrFileTypeForbidden = errors.New("File type is not allowed")
  42. // ErrTooManyFiles upload too many files
  43. ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
  44. // IssueTemplateCandidates issue templates
  45. IssueTemplateCandidates = []string{
  46. "ISSUE_TEMPLATE.md",
  47. "issue_template.md",
  48. ".gitea/ISSUE_TEMPLATE.md",
  49. ".gitea/issue_template.md",
  50. ".github/ISSUE_TEMPLATE.md",
  51. ".github/issue_template.md",
  52. }
  53. )
  54. // MustEnableIssues check if repository enable internal issues
  55. func MustEnableIssues(ctx *context.Context) {
  56. if !ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) &&
  57. !ctx.Repo.Repository.UnitEnabled(models.UnitTypeExternalTracker) {
  58. ctx.NotFound("MustEnableIssues", nil)
  59. return
  60. }
  61. unit, err := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker)
  62. if err == nil {
  63. ctx.Redirect(unit.ExternalTrackerConfig().ExternalTrackerURL)
  64. return
  65. }
  66. }
  67. // MustAllowPulls check if repository enable pull requests
  68. func MustAllowPulls(ctx *context.Context) {
  69. if !ctx.Repo.Repository.AllowsPulls() {
  70. ctx.NotFound("MustAllowPulls", nil)
  71. return
  72. }
  73. // User can send pull request if owns a forked repository.
  74. if ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) {
  75. ctx.Repo.PullRequest.Allowed = true
  76. ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName
  77. }
  78. }
  79. // Issues render issues page
  80. func Issues(ctx *context.Context) {
  81. isPullList := ctx.Params(":type") == "pulls"
  82. if isPullList {
  83. MustAllowPulls(ctx)
  84. if ctx.Written() {
  85. return
  86. }
  87. ctx.Data["Title"] = ctx.Tr("repo.pulls")
  88. ctx.Data["PageIsPullList"] = true
  89. } else {
  90. MustEnableIssues(ctx)
  91. if ctx.Written() {
  92. return
  93. }
  94. ctx.Data["Title"] = ctx.Tr("repo.issues")
  95. ctx.Data["PageIsIssueList"] = true
  96. }
  97. viewType := ctx.Query("type")
  98. sortType := ctx.Query("sort")
  99. types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"}
  100. if !com.IsSliceContainsStr(types, viewType) {
  101. viewType = "all"
  102. }
  103. var (
  104. assigneeID = ctx.QueryInt64("assignee")
  105. posterID int64
  106. mentionedID int64
  107. forceEmpty bool
  108. )
  109. if ctx.IsSigned {
  110. switch viewType {
  111. case "created_by":
  112. posterID = ctx.User.ID
  113. case "mentioned":
  114. mentionedID = ctx.User.ID
  115. }
  116. }
  117. repo := ctx.Repo.Repository
  118. selectLabels := ctx.Query("labels")
  119. milestoneID := ctx.QueryInt64("milestone")
  120. isShowClosed := ctx.Query("state") == "closed"
  121. keyword := strings.Trim(ctx.Query("q"), " ")
  122. if bytes.Contains([]byte(keyword), []byte{0x00}) {
  123. keyword = ""
  124. }
  125. var issueIDs []int64
  126. var err error
  127. if len(keyword) > 0 {
  128. issueIDs, err = indexer.SearchIssuesByKeyword(repo.ID, keyword)
  129. if len(issueIDs) == 0 {
  130. forceEmpty = true
  131. }
  132. }
  133. var issueStats *models.IssueStats
  134. if forceEmpty {
  135. issueStats = &models.IssueStats{}
  136. } else {
  137. var err error
  138. issueStats, err = models.GetIssueStats(&models.IssueStatsOptions{
  139. RepoID: repo.ID,
  140. Labels: selectLabels,
  141. MilestoneID: milestoneID,
  142. AssigneeID: assigneeID,
  143. MentionedID: mentionedID,
  144. PosterID: posterID,
  145. IsPull: isPullList,
  146. IssueIDs: issueIDs,
  147. })
  148. if err != nil {
  149. ctx.ServerError("GetIssueStats", err)
  150. return
  151. }
  152. }
  153. page := ctx.QueryInt("page")
  154. if page <= 1 {
  155. page = 1
  156. }
  157. var total int
  158. if !isShowClosed {
  159. total = int(issueStats.OpenCount)
  160. } else {
  161. total = int(issueStats.ClosedCount)
  162. }
  163. pager := paginater.New(total, setting.UI.IssuePagingNum, page, 5)
  164. ctx.Data["Page"] = pager
  165. var issues []*models.Issue
  166. if forceEmpty {
  167. issues = []*models.Issue{}
  168. } else {
  169. issues, err = models.Issues(&models.IssuesOptions{
  170. RepoIDs: []int64{repo.ID},
  171. AssigneeID: assigneeID,
  172. PosterID: posterID,
  173. MentionedID: mentionedID,
  174. MilestoneID: milestoneID,
  175. Page: pager.Current(),
  176. PageSize: setting.UI.IssuePagingNum,
  177. IsClosed: util.OptionalBoolOf(isShowClosed),
  178. IsPull: util.OptionalBoolOf(isPullList),
  179. Labels: selectLabels,
  180. SortType: sortType,
  181. IssueIDs: issueIDs,
  182. })
  183. if err != nil {
  184. ctx.ServerError("Issues", err)
  185. return
  186. }
  187. }
  188. // Get posters.
  189. for i := range issues {
  190. // Check read status
  191. if !ctx.IsSigned {
  192. issues[i].IsRead = true
  193. } else if err = issues[i].GetIsRead(ctx.User.ID); err != nil {
  194. ctx.ServerError("GetIsRead", err)
  195. return
  196. }
  197. }
  198. ctx.Data["Issues"] = issues
  199. // Get milestones.
  200. ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(repo.ID)
  201. if err != nil {
  202. ctx.ServerError("GetAllRepoMilestones", err)
  203. return
  204. }
  205. // Get assignees.
  206. ctx.Data["Assignees"], err = repo.GetAssignees()
  207. if err != nil {
  208. ctx.ServerError("GetAssignees", err)
  209. return
  210. }
  211. if ctx.QueryInt64("assignee") == 0 {
  212. assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
  213. }
  214. ctx.Data["IssueStats"] = issueStats
  215. ctx.Data["SelectLabels"] = com.StrTo(selectLabels).MustInt64()
  216. ctx.Data["ViewType"] = viewType
  217. ctx.Data["SortType"] = sortType
  218. ctx.Data["MilestoneID"] = milestoneID
  219. ctx.Data["AssigneeID"] = assigneeID
  220. ctx.Data["IsShowClosed"] = isShowClosed
  221. ctx.Data["Keyword"] = keyword
  222. if isShowClosed {
  223. ctx.Data["State"] = "closed"
  224. } else {
  225. ctx.Data["State"] = "open"
  226. }
  227. ctx.HTML(200, tplIssues)
  228. }
  229. // RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
  230. func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
  231. var err error
  232. ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false, "")
  233. if err != nil {
  234. ctx.ServerError("GetMilestones", err)
  235. return
  236. }
  237. ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true, "")
  238. if err != nil {
  239. ctx.ServerError("GetMilestones", err)
  240. return
  241. }
  242. ctx.Data["Assignees"], err = repo.GetAssignees()
  243. if err != nil {
  244. ctx.ServerError("GetAssignees", err)
  245. return
  246. }
  247. }
  248. // RetrieveRepoMetas find all the meta information of a repository
  249. func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label {
  250. if !ctx.Repo.IsWriter() {
  251. return nil
  252. }
  253. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  254. if err != nil {
  255. ctx.ServerError("GetLabelsByRepoID", err)
  256. return nil
  257. }
  258. ctx.Data["Labels"] = labels
  259. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  260. if ctx.Written() {
  261. return nil
  262. }
  263. brs, err := ctx.Repo.GitRepo.GetBranches()
  264. if err != nil {
  265. ctx.ServerError("GetBranches", err)
  266. return nil
  267. }
  268. ctx.Data["Branches"] = brs
  269. // Contains true if the user can create issue dependencies
  270. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  271. return labels
  272. }
  273. func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) {
  274. var r io.Reader
  275. var bytes []byte
  276. if ctx.Repo.Commit == nil {
  277. var err error
  278. ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
  279. if err != nil {
  280. return "", false
  281. }
  282. }
  283. entry, err := ctx.Repo.Commit.GetTreeEntryByPath(filename)
  284. if err != nil {
  285. return "", false
  286. }
  287. if entry.Blob().Size() >= setting.UI.MaxDisplayFileSize {
  288. return "", false
  289. }
  290. r, err = entry.Blob().Data()
  291. if err != nil {
  292. return "", false
  293. }
  294. bytes, err = ioutil.ReadAll(r)
  295. if err != nil {
  296. return "", false
  297. }
  298. return string(bytes), true
  299. }
  300. func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) {
  301. for _, filename := range possibleFiles {
  302. content, found := getFileContentFromDefaultBranch(ctx, filename)
  303. if found {
  304. ctx.Data[ctxDataKey] = content
  305. return
  306. }
  307. }
  308. }
  309. // NewIssue render createing issue page
  310. func NewIssue(ctx *context.Context) {
  311. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  312. ctx.Data["PageIsIssueList"] = true
  313. ctx.Data["RequireHighlightJS"] = true
  314. ctx.Data["RequireSimpleMDE"] = true
  315. ctx.Data["RequireTribute"] = true
  316. setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
  317. renderAttachmentSettings(ctx)
  318. RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  319. if ctx.Written() {
  320. return
  321. }
  322. ctx.HTML(200, tplIssueNew)
  323. }
  324. // ValidateRepoMetas check and returns repository's meta informations
  325. func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64, []int64, int64) {
  326. var (
  327. repo = ctx.Repo.Repository
  328. err error
  329. )
  330. labels := RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  331. if ctx.Written() {
  332. return nil, nil, 0
  333. }
  334. if !ctx.Repo.IsWriter() {
  335. return nil, nil, 0
  336. }
  337. var labelIDs []int64
  338. hasSelected := false
  339. // Check labels.
  340. if len(form.LabelIDs) > 0 {
  341. labelIDs, err = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
  342. if err != nil {
  343. return nil, nil, 0
  344. }
  345. labelIDMark := base.Int64sToMap(labelIDs)
  346. for i := range labels {
  347. if labelIDMark[labels[i].ID] {
  348. labels[i].IsChecked = true
  349. hasSelected = true
  350. }
  351. }
  352. }
  353. ctx.Data["Labels"] = labels
  354. ctx.Data["HasSelectedLabel"] = hasSelected
  355. ctx.Data["label_ids"] = form.LabelIDs
  356. // Check milestone.
  357. milestoneID := form.MilestoneID
  358. if milestoneID > 0 {
  359. ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
  360. if err != nil {
  361. ctx.ServerError("GetMilestoneByID", err)
  362. return nil, nil, 0
  363. }
  364. ctx.Data["milestone_id"] = milestoneID
  365. }
  366. // Check assignees
  367. var assigneeIDs []int64
  368. if len(form.AssigneeIDs) > 0 {
  369. assigneeIDs, err = base.StringsToInt64s(strings.Split(form.AssigneeIDs, ","))
  370. if err != nil {
  371. return nil, nil, 0
  372. }
  373. // Check if the passed assignees actually exists and has write access to the repo
  374. for _, aID := range assigneeIDs {
  375. _, err = repo.GetUserIfHasWriteAccess(aID)
  376. if err != nil {
  377. ctx.ServerError("GetUserIfHasWriteAccess", err)
  378. return nil, nil, 0
  379. }
  380. }
  381. }
  382. // Keep the old assignee id thingy for compatibility reasons
  383. if form.AssigneeID > 0 {
  384. assigneeIDs = append(assigneeIDs, form.AssigneeID)
  385. }
  386. return labelIDs, assigneeIDs, milestoneID
  387. }
  388. // NewIssuePost response for creating new issue
  389. func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
  390. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  391. ctx.Data["PageIsIssueList"] = true
  392. ctx.Data["RequireHighlightJS"] = true
  393. ctx.Data["RequireSimpleMDE"] = true
  394. ctx.Data["ReadOnly"] = false
  395. renderAttachmentSettings(ctx)
  396. var (
  397. repo = ctx.Repo.Repository
  398. attachments []string
  399. )
  400. labelIDs, assigneeIDs, milestoneID := ValidateRepoMetas(ctx, form)
  401. if ctx.Written() {
  402. return
  403. }
  404. if setting.AttachmentEnabled {
  405. attachments = form.Files
  406. }
  407. if ctx.HasError() {
  408. ctx.HTML(200, tplIssueNew)
  409. return
  410. }
  411. issue := &models.Issue{
  412. RepoID: repo.ID,
  413. Title: form.Title,
  414. PosterID: ctx.User.ID,
  415. Poster: ctx.User,
  416. MilestoneID: milestoneID,
  417. Content: form.Content,
  418. Ref: form.Ref,
  419. }
  420. if err := models.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
  421. if models.IsErrUserDoesNotHaveAccessToRepo(err) {
  422. ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
  423. return
  424. }
  425. ctx.ServerError("NewIssue", err)
  426. return
  427. }
  428. notification.Service.NotifyIssue(issue, ctx.User.ID)
  429. log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
  430. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  431. }
  432. // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue
  433. func commentTag(repo *models.Repository, poster *models.User, issue *models.Issue) (models.CommentTag, error) {
  434. if repo.IsOwnedBy(poster.ID) {
  435. return models.CommentTagOwner, nil
  436. } else if repo.Owner.IsOrganization() {
  437. isOwner, err := repo.Owner.IsOwnedBy(poster.ID)
  438. if err != nil {
  439. return models.CommentTagNone, err
  440. } else if isOwner {
  441. return models.CommentTagOwner, nil
  442. }
  443. }
  444. if poster.IsWriterOfRepo(repo) {
  445. return models.CommentTagWriter, nil
  446. } else if poster.ID == issue.PosterID {
  447. return models.CommentTagPoster, nil
  448. }
  449. return models.CommentTagNone, nil
  450. }
  451. // ViewIssue render issue view page
  452. func ViewIssue(ctx *context.Context) {
  453. ctx.Data["RequireHighlightJS"] = true
  454. ctx.Data["RequireDropzone"] = true
  455. ctx.Data["RequireTribute"] = true
  456. renderAttachmentSettings(ctx)
  457. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  458. if err != nil {
  459. if models.IsErrIssueNotExist(err) {
  460. ctx.NotFound("GetIssueByIndex", err)
  461. } else {
  462. ctx.ServerError("GetIssueByIndex", err)
  463. }
  464. return
  465. }
  466. ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
  467. var iw *models.IssueWatch
  468. var exists bool
  469. if ctx.User != nil {
  470. iw, exists, err = models.GetIssueWatch(ctx.User.ID, issue.ID)
  471. if err != nil {
  472. ctx.ServerError("GetIssueWatch", err)
  473. return
  474. }
  475. if !exists {
  476. iw = &models.IssueWatch{
  477. UserID: ctx.User.ID,
  478. IssueID: issue.ID,
  479. IsWatching: models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID),
  480. }
  481. }
  482. }
  483. ctx.Data["IssueWatch"] = iw
  484. // Make sure type and URL matches.
  485. if ctx.Params(":type") == "issues" && issue.IsPull {
  486. ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
  487. return
  488. } else if ctx.Params(":type") == "pulls" && !issue.IsPull {
  489. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  490. return
  491. }
  492. if issue.IsPull {
  493. MustAllowPulls(ctx)
  494. if ctx.Written() {
  495. return
  496. }
  497. ctx.Data["PageIsPullList"] = true
  498. ctx.Data["PageIsPullConversation"] = true
  499. } else {
  500. MustEnableIssues(ctx)
  501. if ctx.Written() {
  502. return
  503. }
  504. ctx.Data["PageIsIssueList"] = true
  505. }
  506. issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
  507. ctx.Repo.Repository.ComposeMetas()))
  508. repo := ctx.Repo.Repository
  509. // Get more information if it's a pull request.
  510. if issue.IsPull {
  511. if issue.PullRequest.HasMerged {
  512. ctx.Data["DisableStatusChange"] = issue.PullRequest.HasMerged
  513. PrepareMergedViewPullInfo(ctx, issue)
  514. } else {
  515. PrepareViewPullInfo(ctx, issue)
  516. }
  517. if ctx.Written() {
  518. return
  519. }
  520. }
  521. // Metas.
  522. // Check labels.
  523. labelIDMark := make(map[int64]bool)
  524. for i := range issue.Labels {
  525. labelIDMark[issue.Labels[i].ID] = true
  526. }
  527. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  528. if err != nil {
  529. ctx.ServerError("GetLabelsByRepoID", err)
  530. return
  531. }
  532. hasSelected := false
  533. for i := range labels {
  534. if labelIDMark[labels[i].ID] {
  535. labels[i].IsChecked = true
  536. hasSelected = true
  537. }
  538. }
  539. ctx.Data["HasSelectedLabel"] = hasSelected
  540. ctx.Data["Labels"] = labels
  541. // Check milestone and assignee.
  542. if ctx.Repo.IsWriter() {
  543. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  544. if ctx.Written() {
  545. return
  546. }
  547. }
  548. if ctx.IsSigned {
  549. // Update issue-user.
  550. if err = issue.ReadBy(ctx.User.ID); err != nil {
  551. ctx.ServerError("ReadBy", err)
  552. return
  553. }
  554. }
  555. var (
  556. tag models.CommentTag
  557. ok bool
  558. marked = make(map[int64]models.CommentTag)
  559. comment *models.Comment
  560. participants = make([]*models.User, 1, 10)
  561. )
  562. if ctx.Repo.Repository.IsTimetrackerEnabled() {
  563. if ctx.IsSigned {
  564. // Deal with the stopwatch
  565. ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID)
  566. if !ctx.Data["IsStopwatchRunning"].(bool) {
  567. var exists bool
  568. var sw *models.Stopwatch
  569. if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil {
  570. ctx.ServerError("HasUserStopwatch", err)
  571. return
  572. }
  573. ctx.Data["HasUserStopwatch"] = exists
  574. if exists {
  575. // Add warning if the user has already a stopwatch
  576. var otherIssue *models.Issue
  577. if otherIssue, err = models.GetIssueByID(sw.IssueID); err != nil {
  578. ctx.ServerError("GetIssueByID", err)
  579. return
  580. }
  581. // Add link to the issue of the already running stopwatch
  582. ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL()
  583. }
  584. }
  585. ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User)
  586. } else {
  587. ctx.Data["CanUseTimetracker"] = false
  588. }
  589. if ctx.Data["WorkingUsers"], err = models.TotalTimes(models.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil {
  590. ctx.ServerError("TotalTimes", err)
  591. return
  592. }
  593. }
  594. // Check if the user can use the dependencies
  595. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  596. // Render comments and and fetch participants.
  597. participants[0] = issue.Poster
  598. for _, comment = range issue.Comments {
  599. if comment.Type == models.CommentTypeComment {
  600. comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink,
  601. ctx.Repo.Repository.ComposeMetas()))
  602. // Check tag.
  603. tag, ok = marked[comment.PosterID]
  604. if ok {
  605. comment.ShowTag = tag
  606. continue
  607. }
  608. comment.ShowTag, err = commentTag(repo, comment.Poster, issue)
  609. if err != nil {
  610. ctx.ServerError("commentTag", err)
  611. return
  612. }
  613. marked[comment.PosterID] = comment.ShowTag
  614. isAdded := false
  615. for j := range participants {
  616. if comment.Poster == participants[j] {
  617. isAdded = true
  618. break
  619. }
  620. }
  621. if !isAdded && !issue.IsPoster(comment.Poster.ID) {
  622. participants = append(participants, comment.Poster)
  623. }
  624. } else if comment.Type == models.CommentTypeLabel {
  625. if err = comment.LoadLabel(); err != nil {
  626. ctx.ServerError("LoadLabel", err)
  627. return
  628. }
  629. } else if comment.Type == models.CommentTypeMilestone {
  630. if err = comment.LoadMilestone(); err != nil {
  631. ctx.ServerError("LoadMilestone", err)
  632. return
  633. }
  634. ghostMilestone := &models.Milestone{
  635. ID: -1,
  636. Name: ctx.Tr("repo.issues.deleted_milestone"),
  637. }
  638. if comment.OldMilestoneID > 0 && comment.OldMilestone == nil {
  639. comment.OldMilestone = ghostMilestone
  640. }
  641. if comment.MilestoneID > 0 && comment.Milestone == nil {
  642. comment.Milestone = ghostMilestone
  643. }
  644. } else if comment.Type == models.CommentTypeAssignees {
  645. if err = comment.LoadAssigneeUser(); err != nil {
  646. ctx.ServerError("LoadAssigneeUser", err)
  647. return
  648. }
  649. } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
  650. if err = comment.LoadDepIssueDetails(); err != nil {
  651. ctx.ServerError("LoadDepIssueDetails", err)
  652. return
  653. }
  654. } else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview {
  655. if err = comment.LoadReview(); err != nil && !models.IsErrReviewNotExist(err) {
  656. ctx.ServerError("LoadReview", err)
  657. return
  658. }
  659. if comment.Review == nil {
  660. continue
  661. }
  662. if err = comment.Review.LoadAttributes(); err != nil {
  663. ctx.ServerError("Review.LoadAttributes", err)
  664. return
  665. }
  666. if err = comment.Review.LoadCodeComments(); err != nil {
  667. ctx.ServerError("Review.LoadCodeComments", err)
  668. return
  669. }
  670. }
  671. }
  672. if issue.IsPull {
  673. pull := issue.PullRequest
  674. canDelete := false
  675. if ctx.IsSigned {
  676. if err := pull.GetHeadRepo(); err != nil {
  677. log.Error(4, "GetHeadRepo: %v", err)
  678. } else if pull.HeadRepo != nil && pull.HeadBranch != pull.HeadRepo.DefaultBranch && ctx.User.IsWriterOfRepo(pull.HeadRepo) {
  679. // Check if branch is not protected
  680. if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch, ctx.User); err != nil {
  681. log.Error(4, "IsProtectedBranch: %v", err)
  682. } else if !protected {
  683. canDelete = true
  684. ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index) + "/cleanup"
  685. }
  686. }
  687. }
  688. prUnit, err := repo.GetUnit(models.UnitTypePullRequests)
  689. if err != nil {
  690. ctx.ServerError("GetUnit", err)
  691. return
  692. }
  693. prConfig := prUnit.PullRequestsConfig()
  694. ctx.Data["AllowMerge"] = ctx.Data["IsRepositoryWriter"]
  695. if err := pull.CheckUserAllowedToMerge(ctx.User); err != nil {
  696. if !models.IsErrNotAllowedToMerge(err) {
  697. ctx.ServerError("CheckUserAllowedToMerge", err)
  698. return
  699. }
  700. ctx.Data["AllowMerge"] = false
  701. }
  702. // Check correct values and select default
  703. if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
  704. !prConfig.IsMergeStyleAllowed(ms) {
  705. if prConfig.AllowMerge {
  706. ctx.Data["MergeStyle"] = models.MergeStyleMerge
  707. } else if prConfig.AllowRebase {
  708. ctx.Data["MergeStyle"] = models.MergeStyleRebase
  709. } else if prConfig.AllowSquash {
  710. ctx.Data["MergeStyle"] = models.MergeStyleSquash
  711. } else {
  712. ctx.Data["MergeStyle"] = ""
  713. }
  714. }
  715. ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch)
  716. }
  717. // Get Dependencies
  718. ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies()
  719. ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies()
  720. ctx.Data["Participants"] = participants
  721. ctx.Data["NumParticipants"] = len(participants)
  722. ctx.Data["Issue"] = issue
  723. ctx.Data["ReadOnly"] = true
  724. ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))
  725. ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
  726. ctx.HTML(200, tplIssueView)
  727. }
  728. // GetActionIssue will return the issue which is used in the context.
  729. func GetActionIssue(ctx *context.Context) *models.Issue {
  730. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  731. if err != nil {
  732. ctx.NotFoundOrServerError("GetIssueByIndex", models.IsErrIssueNotExist, err)
  733. return nil
  734. }
  735. checkIssueRights(ctx, issue)
  736. if ctx.Written() {
  737. return nil
  738. }
  739. if err = issue.LoadAttributes(); err != nil {
  740. ctx.ServerError("LoadAttributes", nil)
  741. return nil
  742. }
  743. return issue
  744. }
  745. func checkIssueRights(ctx *context.Context, issue *models.Issue) {
  746. if issue.IsPull && !ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests) ||
  747. !issue.IsPull && !ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) {
  748. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  749. }
  750. }
  751. func getActionIssues(ctx *context.Context) []*models.Issue {
  752. commaSeparatedIssueIDs := ctx.Query("issue_ids")
  753. if len(commaSeparatedIssueIDs) == 0 {
  754. return nil
  755. }
  756. issueIDs := make([]int64, 0, 10)
  757. for _, stringIssueID := range strings.Split(commaSeparatedIssueIDs, ",") {
  758. issueID, err := strconv.ParseInt(stringIssueID, 10, 64)
  759. if err != nil {
  760. ctx.ServerError("ParseInt", err)
  761. return nil
  762. }
  763. issueIDs = append(issueIDs, issueID)
  764. }
  765. issues, err := models.GetIssuesByIDs(issueIDs)
  766. if err != nil {
  767. ctx.ServerError("GetIssuesByIDs", err)
  768. return nil
  769. }
  770. // Check access rights for all issues
  771. issueUnitEnabled := ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues)
  772. prUnitEnabled := ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests)
  773. for _, issue := range issues {
  774. if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {
  775. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  776. return nil
  777. }
  778. if err = issue.LoadAttributes(); err != nil {
  779. ctx.ServerError("LoadAttributes", err)
  780. return nil
  781. }
  782. }
  783. return issues
  784. }
  785. // UpdateIssueTitle change issue's title
  786. func UpdateIssueTitle(ctx *context.Context) {
  787. issue := GetActionIssue(ctx)
  788. if ctx.Written() {
  789. return
  790. }
  791. if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.IsWriter()) {
  792. ctx.Error(403)
  793. return
  794. }
  795. title := ctx.QueryTrim("title")
  796. if len(title) == 0 {
  797. ctx.Error(204)
  798. return
  799. }
  800. if err := issue.ChangeTitle(ctx.User, title); err != nil {
  801. ctx.ServerError("ChangeTitle", err)
  802. return
  803. }
  804. ctx.JSON(200, map[string]interface{}{
  805. "title": issue.Title,
  806. })
  807. }
  808. // UpdateIssueContent change issue's content
  809. func UpdateIssueContent(ctx *context.Context) {
  810. issue := GetActionIssue(ctx)
  811. if ctx.Written() {
  812. return
  813. }
  814. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.IsWriter()) {
  815. ctx.Error(403)
  816. return
  817. }
  818. content := ctx.Query("content")
  819. if err := issue.ChangeContent(ctx.User, content); err != nil {
  820. ctx.ServerError("ChangeContent", err)
  821. return
  822. }
  823. ctx.JSON(200, map[string]interface{}{
  824. "content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  825. })
  826. }
  827. // UpdateIssueMilestone change issue's milestone
  828. func UpdateIssueMilestone(ctx *context.Context) {
  829. issues := getActionIssues(ctx)
  830. if ctx.Written() {
  831. return
  832. }
  833. milestoneID := ctx.QueryInt64("id")
  834. for _, issue := range issues {
  835. oldMilestoneID := issue.MilestoneID
  836. if oldMilestoneID == milestoneID {
  837. continue
  838. }
  839. issue.MilestoneID = milestoneID
  840. if err := models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
  841. ctx.ServerError("ChangeMilestoneAssign", err)
  842. return
  843. }
  844. }
  845. ctx.JSON(200, map[string]interface{}{
  846. "ok": true,
  847. })
  848. }
  849. // UpdateIssueAssignee change issue's assignee
  850. func UpdateIssueAssignee(ctx *context.Context) {
  851. issues := getActionIssues(ctx)
  852. if ctx.Written() {
  853. return
  854. }
  855. assigneeID := ctx.QueryInt64("id")
  856. action := ctx.Query("action")
  857. for _, issue := range issues {
  858. switch action {
  859. case "clear":
  860. if err := models.DeleteNotPassedAssignee(issue, ctx.User, []*models.User{}); err != nil {
  861. ctx.ServerError("ClearAssignees", err)
  862. return
  863. }
  864. default:
  865. if err := issue.ChangeAssignee(ctx.User, assigneeID); err != nil {
  866. ctx.ServerError("ChangeAssignee", err)
  867. return
  868. }
  869. }
  870. }
  871. ctx.JSON(200, map[string]interface{}{
  872. "ok": true,
  873. })
  874. }
  875. // UpdateIssueStatus change issue's status
  876. func UpdateIssueStatus(ctx *context.Context) {
  877. issues := getActionIssues(ctx)
  878. if ctx.Written() {
  879. return
  880. }
  881. var isClosed bool
  882. switch action := ctx.Query("action"); action {
  883. case "open":
  884. isClosed = false
  885. case "close":
  886. isClosed = true
  887. default:
  888. log.Warn("Unrecognized action: %s", action)
  889. }
  890. if _, err := models.IssueList(issues).LoadRepositories(); err != nil {
  891. ctx.ServerError("LoadRepositories", err)
  892. return
  893. }
  894. for _, issue := range issues {
  895. if err := issue.ChangeStatus(ctx.User, issue.Repo, isClosed); err != nil {
  896. if models.IsErrDependenciesLeft(err) {
  897. ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
  898. "error": "cannot close this issue because it still has open dependencies",
  899. })
  900. return
  901. }
  902. ctx.ServerError("ChangeStatus", err)
  903. return
  904. }
  905. }
  906. ctx.JSON(200, map[string]interface{}{
  907. "ok": true,
  908. })
  909. }
  910. // NewComment create a comment for issue
  911. func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
  912. issue := GetActionIssue(ctx)
  913. if ctx.Written() {
  914. return
  915. }
  916. var attachments []string
  917. if setting.AttachmentEnabled {
  918. attachments = form.Files
  919. }
  920. if ctx.HasError() {
  921. ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
  922. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
  923. return
  924. }
  925. var comment *models.Comment
  926. defer func() {
  927. // Check if issue admin/poster changes the status of issue.
  928. if (ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
  929. (form.Status == "reopen" || form.Status == "close") &&
  930. !(issue.IsPull && issue.PullRequest.HasMerged) {
  931. // Duplication and conflict check should apply to reopen pull request.
  932. var pr *models.PullRequest
  933. if form.Status == "reopen" && issue.IsPull {
  934. pull := issue.PullRequest
  935. pr, err := models.GetUnmergedPullRequest(pull.HeadRepoID, pull.BaseRepoID, pull.HeadBranch, pull.BaseBranch)
  936. if err != nil {
  937. if !models.IsErrPullRequestNotExist(err) {
  938. ctx.ServerError("GetUnmergedPullRequest", err)
  939. return
  940. }
  941. }
  942. // Regenerate patch and test conflict.
  943. if pr == nil {
  944. if err = issue.PullRequest.UpdatePatch(); err != nil {
  945. ctx.ServerError("UpdatePatch", err)
  946. return
  947. }
  948. issue.PullRequest.AddToTaskQueue()
  949. }
  950. }
  951. if pr != nil {
  952. ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
  953. } else {
  954. if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, form.Status == "close"); err != nil {
  955. log.Error(4, "ChangeStatus: %v", err)
  956. if models.IsErrDependenciesLeft(err) {
  957. if issue.IsPull {
  958. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked"))
  959. ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  960. } else {
  961. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.issue_close_blocked"))
  962. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  963. }
  964. return
  965. }
  966. } else {
  967. log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
  968. notification.Service.NotifyIssue(issue, ctx.User.ID)
  969. }
  970. }
  971. }
  972. // Redirect to comment hashtag if there is any actual content.
  973. typeName := "issues"
  974. if issue.IsPull {
  975. typeName = "pulls"
  976. }
  977. if comment != nil {
  978. ctx.Redirect(fmt.Sprintf("%s/%s/%d#%s", ctx.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
  979. } else {
  980. ctx.Redirect(fmt.Sprintf("%s/%s/%d", ctx.Repo.RepoLink, typeName, issue.Index))
  981. }
  982. }()
  983. // Fix #321: Allow empty comments, as long as we have attachments.
  984. if len(form.Content) == 0 && len(attachments) == 0 {
  985. return
  986. }
  987. comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments)
  988. if err != nil {
  989. ctx.ServerError("CreateIssueComment", err)
  990. return
  991. }
  992. notification.Service.NotifyIssue(issue, ctx.User.ID)
  993. log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
  994. }
  995. // UpdateCommentContent change comment of issue's content
  996. func UpdateCommentContent(ctx *context.Context) {
  997. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  998. if err != nil {
  999. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1000. return
  1001. }
  1002. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) {
  1003. ctx.Error(403)
  1004. return
  1005. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1006. ctx.Error(204)
  1007. return
  1008. }
  1009. oldContent := comment.Content
  1010. comment.Content = ctx.Query("content")
  1011. if len(comment.Content) == 0 {
  1012. ctx.JSON(200, map[string]interface{}{
  1013. "content": "",
  1014. })
  1015. return
  1016. }
  1017. if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil {
  1018. ctx.ServerError("UpdateComment", err)
  1019. return
  1020. }
  1021. ctx.JSON(200, map[string]interface{}{
  1022. "content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  1023. })
  1024. }
  1025. // DeleteComment delete comment of issue
  1026. func DeleteComment(ctx *context.Context) {
  1027. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1028. if err != nil {
  1029. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1030. return
  1031. }
  1032. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) {
  1033. ctx.Error(403)
  1034. return
  1035. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1036. ctx.Error(204)
  1037. return
  1038. }
  1039. if err = models.DeleteComment(ctx.User, comment); err != nil {
  1040. ctx.ServerError("DeleteCommentByID", err)
  1041. return
  1042. }
  1043. ctx.Status(200)
  1044. }
  1045. // Milestones render milestones page
  1046. func Milestones(ctx *context.Context) {
  1047. ctx.Data["Title"] = ctx.Tr("repo.milestones")
  1048. ctx.Data["PageIsIssueList"] = true
  1049. ctx.Data["PageIsMilestones"] = true
  1050. isShowClosed := ctx.Query("state") == "closed"
  1051. openCount, closedCount, err := models.MilestoneStats(ctx.Repo.Repository.ID)
  1052. if err != nil {
  1053. ctx.ServerError("MilestoneStats", err)
  1054. return
  1055. }
  1056. ctx.Data["OpenCount"] = openCount
  1057. ctx.Data["ClosedCount"] = closedCount
  1058. sortType := ctx.Query("sort")
  1059. page := ctx.QueryInt("page")
  1060. if page <= 1 {
  1061. page = 1
  1062. }
  1063. var total int
  1064. if !isShowClosed {
  1065. total = int(openCount)
  1066. } else {
  1067. total = int(closedCount)
  1068. }
  1069. ctx.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
  1070. miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed, sortType)
  1071. if err != nil {
  1072. ctx.ServerError("GetMilestones", err)
  1073. return
  1074. }
  1075. if ctx.Repo.Repository.IsTimetrackerEnabled() {
  1076. if miles.LoadTotalTrackedTimes(); err != nil {
  1077. ctx.ServerError("LoadTotalTrackedTimes", err)
  1078. return
  1079. }
  1080. }
  1081. for _, m := range miles {
  1082. m.RenderedContent = string(markdown.Render([]byte(m.Content), ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()))
  1083. }
  1084. ctx.Data["Milestones"] = miles
  1085. if isShowClosed {
  1086. ctx.Data["State"] = "closed"
  1087. } else {
  1088. ctx.Data["State"] = "open"
  1089. }
  1090. ctx.Data["SortType"] = sortType
  1091. ctx.Data["IsShowClosed"] = isShowClosed
  1092. ctx.HTML(200, tplMilestone)
  1093. }
  1094. // NewMilestone render creating milestone page
  1095. func NewMilestone(ctx *context.Context) {
  1096. ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
  1097. ctx.Data["PageIsIssueList"] = true
  1098. ctx.Data["PageIsMilestones"] = true
  1099. ctx.Data["RequireDatetimepicker"] = true
  1100. ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
  1101. ctx.HTML(200, tplMilestoneNew)
  1102. }
  1103. // NewMilestonePost response for creating milestone
  1104. func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
  1105. ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
  1106. ctx.Data["PageIsIssueList"] = true
  1107. ctx.Data["PageIsMilestones"] = true
  1108. ctx.Data["RequireDatetimepicker"] = true
  1109. ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
  1110. if ctx.HasError() {
  1111. ctx.HTML(200, tplMilestoneNew)
  1112. return
  1113. }
  1114. if len(form.Deadline) == 0 {
  1115. form.Deadline = "9999-12-31"
  1116. }
  1117. deadline, err := time.ParseInLocation("2006-01-02", form.Deadline, time.Local)
  1118. if err != nil {
  1119. ctx.Data["Err_Deadline"] = true
  1120. ctx.RenderWithErr(ctx.Tr("repo.milestones.invalid_due_date_format"), tplMilestoneNew, &form)
  1121. return
  1122. }
  1123. if err = models.NewMilestone(&models.Milestone{
  1124. RepoID: ctx.Repo.Repository.ID,
  1125. Name: form.Title,
  1126. Content: form.Content,
  1127. DeadlineUnix: util.TimeStamp(deadline.Unix()),
  1128. }); err != nil {
  1129. ctx.ServerError("NewMilestone", err)
  1130. return
  1131. }
  1132. ctx.Flash.Success(ctx.Tr("repo.milestones.create_success", form.Title))
  1133. ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
  1134. }
  1135. // EditMilestone render edting milestone page
  1136. func EditMilestone(ctx *context.Context) {
  1137. ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
  1138. ctx.Data["PageIsMilestones"] = true
  1139. ctx.Data["PageIsEditMilestone"] = true
  1140. ctx.Data["RequireDatetimepicker"] = true
  1141. ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
  1142. m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
  1143. if err != nil {
  1144. if models.IsErrMilestoneNotExist(err) {
  1145. ctx.NotFound("", nil)
  1146. } else {
  1147. ctx.ServerError("GetMilestoneByRepoID", err)
  1148. }
  1149. return
  1150. }
  1151. ctx.Data["title"] = m.Name
  1152. ctx.Data["content"] = m.Content
  1153. if len(m.DeadlineString) > 0 {
  1154. ctx.Data["deadline"] = m.DeadlineString
  1155. }
  1156. ctx.HTML(200, tplMilestoneNew)
  1157. }
  1158. // EditMilestonePost response for edting milestone
  1159. func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
  1160. ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
  1161. ctx.Data["PageIsMilestones"] = true
  1162. ctx.Data["PageIsEditMilestone"] = true
  1163. ctx.Data["RequireDatetimepicker"] = true
  1164. ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
  1165. if ctx.HasError() {
  1166. ctx.HTML(200, tplMilestoneNew)
  1167. return
  1168. }
  1169. if len(form.Deadline) == 0 {
  1170. form.Deadline = "9999-12-31"
  1171. }
  1172. deadline, err := time.ParseInLocation("2006-01-02", form.Deadline, time.Local)
  1173. if err != nil {
  1174. ctx.Data["Err_Deadline"] = true
  1175. ctx.RenderWithErr(ctx.Tr("repo.milestones.invalid_due_date_format"), tplMilestoneNew, &form)
  1176. return
  1177. }
  1178. m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
  1179. if err != nil {
  1180. if models.IsErrMilestoneNotExist(err) {
  1181. ctx.NotFound("", nil)
  1182. } else {
  1183. ctx.ServerError("GetMilestoneByRepoID", err)
  1184. }
  1185. return
  1186. }
  1187. m.Name = form.Title
  1188. m.Content = form.Content
  1189. m.DeadlineUnix = util.TimeStamp(deadline.Unix())
  1190. if err = models.UpdateMilestone(m); err != nil {
  1191. ctx.ServerError("UpdateMilestone", err)
  1192. return
  1193. }
  1194. ctx.Flash.Success(ctx.Tr("repo.milestones.edit_success", m.Name))
  1195. ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
  1196. }
  1197. // ChangeMilestonStatus response for change a milestone's status
  1198. func ChangeMilestonStatus(ctx *context.Context) {
  1199. m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
  1200. if err != nil {
  1201. if models.IsErrMilestoneNotExist(err) {
  1202. ctx.NotFound("", err)
  1203. } else {
  1204. ctx.ServerError("GetMilestoneByRepoID", err)
  1205. }
  1206. return
  1207. }
  1208. switch ctx.Params(":action") {
  1209. case "open":
  1210. if m.IsClosed {
  1211. if err = models.ChangeMilestoneStatus(m, false); err != nil {
  1212. ctx.ServerError("ChangeMilestoneStatus", err)
  1213. return
  1214. }
  1215. }
  1216. ctx.Redirect(ctx.Repo.RepoLink + "/milestones?state=open")
  1217. case "close":
  1218. if !m.IsClosed {
  1219. m.ClosedDateUnix = util.TimeStampNow()
  1220. if err = models.ChangeMilestoneStatus(m, true); err != nil {
  1221. ctx.ServerError("ChangeMilestoneStatus", err)
  1222. return
  1223. }
  1224. }
  1225. ctx.Redirect(ctx.Repo.RepoLink + "/milestones?state=closed")
  1226. default:
  1227. ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
  1228. }
  1229. }
  1230. // DeleteMilestone delete a milestone
  1231. func DeleteMilestone(ctx *context.Context) {
  1232. if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
  1233. ctx.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
  1234. } else {
  1235. ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
  1236. }
  1237. ctx.JSON(200, map[string]interface{}{
  1238. "redirect": ctx.Repo.RepoLink + "/milestones",
  1239. })
  1240. }
  1241. // ChangeIssueReaction create a reaction for issue
  1242. func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
  1243. issue := GetActionIssue(ctx)
  1244. if ctx.Written() {
  1245. return
  1246. }
  1247. if ctx.HasError() {
  1248. ctx.ServerError("ChangeIssueReaction", errors.New(ctx.GetErrMsg()))
  1249. return
  1250. }
  1251. switch ctx.Params(":action") {
  1252. case "react":
  1253. reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
  1254. if err != nil {
  1255. log.Info("CreateIssueReaction: %s", err)
  1256. break
  1257. }
  1258. // Reload new reactions
  1259. issue.Reactions = nil
  1260. if err = issue.LoadAttributes(); err != nil {
  1261. log.Info("issue.LoadAttributes: %s", err)
  1262. break
  1263. }
  1264. log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
  1265. case "unreact":
  1266. if err := models.DeleteIssueReaction(ctx.User, issue, form.Content); err != nil {
  1267. ctx.ServerError("DeleteIssueReaction", err)
  1268. return
  1269. }
  1270. // Reload new reactions
  1271. issue.Reactions = nil
  1272. if err := issue.LoadAttributes(); err != nil {
  1273. log.Info("issue.LoadAttributes: %s", err)
  1274. break
  1275. }
  1276. log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
  1277. default:
  1278. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1279. return
  1280. }
  1281. if len(issue.Reactions) == 0 {
  1282. ctx.JSON(200, map[string]interface{}{
  1283. "empty": true,
  1284. "html": "",
  1285. })
  1286. return
  1287. }
  1288. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1289. "ctx": ctx.Data,
  1290. "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
  1291. "Reactions": issue.Reactions.GroupByType(),
  1292. })
  1293. if err != nil {
  1294. ctx.ServerError("ChangeIssueReaction.HTMLString", err)
  1295. return
  1296. }
  1297. ctx.JSON(200, map[string]interface{}{
  1298. "html": html,
  1299. })
  1300. }
  1301. // ChangeCommentReaction create a reaction for comment
  1302. func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
  1303. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1304. if err != nil {
  1305. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1306. return
  1307. }
  1308. issue, err := models.GetIssueByID(comment.IssueID)
  1309. checkIssueRights(ctx, issue)
  1310. if ctx.Written() {
  1311. return
  1312. }
  1313. if ctx.HasError() {
  1314. ctx.ServerError("ChangeCommentReaction", errors.New(ctx.GetErrMsg()))
  1315. return
  1316. }
  1317. switch ctx.Params(":action") {
  1318. case "react":
  1319. reaction, err := models.CreateCommentReaction(ctx.User, issue, comment, form.Content)
  1320. if err != nil {
  1321. log.Info("CreateCommentReaction: %s", err)
  1322. break
  1323. }
  1324. // Reload new reactions
  1325. comment.Reactions = nil
  1326. if err = comment.LoadReactions(); err != nil {
  1327. log.Info("comment.LoadReactions: %s", err)
  1328. break
  1329. }
  1330. log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID, reaction.ID)
  1331. case "unreact":
  1332. if err := models.DeleteCommentReaction(ctx.User, issue, comment, form.Content); err != nil {
  1333. ctx.ServerError("DeleteCommentReaction", err)
  1334. return
  1335. }
  1336. // Reload new reactions
  1337. comment.Reactions = nil
  1338. if err = comment.LoadReactions(); err != nil {
  1339. log.Info("comment.LoadReactions: %s", err)
  1340. break
  1341. }
  1342. log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
  1343. default:
  1344. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1345. return
  1346. }
  1347. if len(comment.Reactions) == 0 {
  1348. ctx.JSON(200, map[string]interface{}{
  1349. "empty": true,
  1350. "html": "",
  1351. })
  1352. return
  1353. }
  1354. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1355. "ctx": ctx.Data,
  1356. "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
  1357. "Reactions": comment.Reactions.GroupByType(),
  1358. })
  1359. if err != nil {
  1360. ctx.ServerError("ChangeCommentReaction.HTMLString", err)
  1361. return
  1362. }
  1363. ctx.JSON(200, map[string]interface{}{
  1364. "html": html,
  1365. })
  1366. }