Commit Graph
14 Commits
Author SHA1 Message Date
Lunny XiaoandGitHub 99b2858e62 Move unit into models/unit/ (#17576)
* Move unit into models/unit/

* Rename unit.UnitType as unit.Type
2021-11-09 20:57:58 +01:00
zeripathandGitHub 9302eba971 DBContext is just a Context (#17100)
* DBContext is just a Context

This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.

Signed-off-by: Andrew Thornton <[email protected]>

* fix unit tests

Signed-off-by: Andrew Thornton <[email protected]>

* another place that needs to set the initial context

Signed-off-by: Andrew Thornton <[email protected]>

* avoid race

Signed-off-by: Andrew Thornton <[email protected]>

* change attachment error

Signed-off-by: Andrew Thornton <[email protected]>
2021-09-23 23:45:36 +08:00
a4bfef265d Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db

* Fix lint

* Fix lint

* Fix test

* Fix lint

* Fix lint

* revert unnecessary change

* Fix test

* Fix wrong replace string

* Use *Context

* Correct committer spelling and fix wrong replaced words

Co-authored-by: zeripath <[email protected]>
2021-09-19 19:49:59 +08:00
ddc709ff7f Add repo_id for attachment (#16958)
When create a new issue or comment and paste/upload an attachment/image, it will not assign an issue id before submit. So if user give up the creating, the attachments will lost key feature and become dirty content. We don't know if we need to delete the attachment even if the repository deleted.

This PR add a repo_id in attachment table so that even if a new upload attachment with no issue_id or release_id but should have repo_id. When deleting a repository, they could also be deleted.

Co-authored-by: 6543 <[email protected]>
2021-09-08 17:19:30 +02:00
KN4CK3RandGitHub 3607f79d78 Fixed assert statements. (#16089) 2021-06-07 07:27:09 +02:00
Lunny XiaoandGitHub 8567cba0d9 Implement delete release attachments and update release attachments' name (#14130)
* Implement delete release attachment

* Add attachments on release edit page

* Fix bug

* Finish del release attachments

* Fix frontend lint

* Fix tests

* Support edit release attachments

* Added tests

* Remove the unnecessary parameter isCreate from UpdateReleaseOrCreatReleaseFromTag

* Rename UpdateReleaseOrCreatReleaseFromTag to UpdateRelease

* Fix middle align
2021-03-23 00:09:51 +08:00
Bo-Yi WuandGitHub 167b0f46ef chore(models): rewrite code format. (#14754)
* chore: rewrite format.

* chore: update format

Signed-off-by: Bo-Yi Wu <[email protected]>

* chore: update format

Signed-off-by: Bo-Yi Wu <[email protected]>

* chore: Adjacent parameters with the same type should be grouped together

* chore: update format.
2021-03-14 19:52:12 +01:00
zeripathandGitHub 41294b53b3 Reading pull attachments should depend on read UnitTypePullRequests (#10346)
* Make pull attachments depend on read UnitTypePullRequests

Fixes #10336

* Fix test
2020-02-18 21:36:19 -03:00
Antoine GIRARDandLauris BH 8b24073713 Only serve attachments when linked to issue/release and if accessible by user (#9340)
* test: add current attachement responses

* refactor: check if attachement is linked and accessible by user

* chore: clean TODO

* fix: typo attachement -> attachment

* revert un-needed go.sum change

* refactor: move models logic to models

* fix TestCreateIssueAttachment which was wrongly successful

* fix unit tests with unittype added

* fix unit tests with changes

* use a valid uuid format for pgsql int. test

* test: add unit test TestLinkedRepository

* refactor: allow uploader to access unlinked attachement

* add missing blank line

* refactor: move to a separate function repo.GetAttachment

* typo

* test: remove err test return

* refactor: use repo perm for access checking generally + 404 for all reject
2020-01-05 01:20:08 +02:00
Antoine GIRARDandzeripath c3d31e5534 refactor(models/attachement): use getAttachmentsByUUIDs (#9317) 2019-12-11 00:01:52 +00:00
Lunny Xiaoandtechknowlogick 09fb036ad6 fix upload attachments (#6481)
* fix upload attachments

* add migration for new column uploader_id on table attachment

* fix imports sequence
2019-04-02 15:25:05 -04:00
Jonas FranzandBo-Yi Wu 9a5e628a7e Add Attachment API (#3478)
* Add Attachment API
* repos/:owner/:repo/releases (add attachments)
* repos/:owner/:repo/releases/:id (add attachments)
* repos/:owner/:repo/releases/:id/attachments
* repos/:owner/:repo/releases/:id/attachments/:attachment_id

Signed-off-by: Jonas Franz <[email protected]>

* Add unit tests for new attachment functions
Fix comments

Signed-off-by: Jonas Franz <[email protected]>

* fix lint

* Update vendor.json

Signed-off-by: Jonas Franz <[email protected]>

* remove version of sdk

Signed-off-by: Jonas Franz <[email protected]>

* Fix unit tests
Add missing license header

Signed-off-by: Jonas Franz <[email protected]>

* Add CreateReleaseAttachment
Add EditReleaseAttachment
Add DeleteReleaseAttachment

Signed-off-by: Jonas Franz <[email protected]>

* Add filename query parameter for choosing another name for an attachment

Signed-off-by: Jonas Franz <[email protected]>

* Fix order of imports

Signed-off-by: Jonas Franz <[email protected]>

* Restricting updatable attachment columns

Signed-off-by: Jonas Franz <[email protected]>

* gofmt

Signed-off-by: Jonas Franz <[email protected]>

* Update go-sdk
Replace Attachments with Assets

Signed-off-by: Jonas Franz <[email protected]>

* Update go-sdk

Signed-off-by: Jonas Franz <[email protected]>

* Updating go-sdk and regenerating swagger

Signed-off-by: Jonas Franz <[email protected]>

* Add missing file of go-sdk

Signed-off-by: Jonas Franz <[email protected]>

* Change origin of code.gitea.io/sdk to code.gitea.io/sdk
Update code.gitea.io/sdk

Signed-off-by: Jonas Franz <[email protected]>

* Update swagger

Signed-off-by: Jonas Franz <[email protected]>

* Update updateAttachment
2018-03-06 09:22:16 +08:00
Ethan KoenigandBo-Yi Wu 66c803fae2 MySQL, Postgres integration tests in drone (#1638)
* MySQL, Postgres integration tests in drone

* Fix .drone.yml

* sign drone

* resign drone
2017-04-30 14:30:12 +08:00
Bo-Yi WuandGitHub fa2a513c62 feat: add download count field and unit testing for attachment. (#1512)
* feat: add download count field and unit testing.

* fix: unit testing

* refactor: improve testing.

* fix: update comment

* add default value.

Signed-off-by: Bo-Yi Wu <[email protected]>
2017-04-20 10:31:31 +08:00