Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage User Badges in the interface #29798 #31262

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

HenriquerPimentel
Copy link
Contributor

Implemented #29798

This feature implements:

  • List all badges (screenshot)
  • Create new badges (screenshot)
  • View badge (screenshot)
  • Edit badge (screenshot)
  • Add user to badge (screenshot)

Implemented Badge Management in administration panel

  1. Updated badge model (models/user/badge.go)
  2. Added new type of errors ErrBadgeAlreadyExist and ErrBadgeNotExist (models/user/error.go)
  3. Implemented badge service methods (services/user/badge.go)
  4. Implemented new type of form AdminCreateBadgeForm (services/forms/admin.go)
  5. Implemented new binding rules to check if ImageURL is valid and if is Slug Pattern (modules/validation/binding.go) (modules/web/middleware.go) (modules/validation/helpers.go)
  6. Implemented badge search (routers/web/explore/badge.go) (routers/web/admin/badges.go)
  7. Implemented badges routing (routers/web/web.go)
  8. Implemented templates for create/list/edit/view badges (templates/admin/badge/*) (templates/admin/navbar.tmpl)
    9 Added new translation phrases (en-US): search.badge_kind, form.ImageURL, form.invalid_image_url_error, form.slug_been_taken, admin.badges, admin.badges.badges_manage_panel, admin.badges.details, admin.badges.new_badge, admin.badges.slug, admin.badges.description, admin.badges.image_url, admin.badges.slug.must_fill, admin.badges.new_success, admin.badges.update_success, admin.badges.deletion_success, admin.badges.edit_badge, admin.badges.update_badge, admin.badges.delete_badge, admin.badges.delete_badge_desc

Implemented User Badge Management Interface

  1. Implemented rule to verify if a user badge already exists before insert (models/user/badge.go).
  2. Implemented interface to manage user badge, within administration panel. (routers/web/web.go) (routers/web/explore/badge.go) (routers/web/admin/badges.go) (templates/admin/badge/users.tmpl).
  3. Small bug fixes (view.tmpl, list.tmpl)
  4. Added new translation phrases: admin.badges.users_with_badge, admin.badges.add_user, admin.badges.remove_user, admin.badges.delete_user_desc, admin.badges.not_found, admin.badges.user_add_success, admin.badges.user_remove_success, admin.badges.manage_users.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 5, 2024
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 5, 2024
@github-actions github-actions bot added modifies/translation modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jun 5, 2024
@HenriquerPimentel HenriquerPimentel marked this pull request as draft June 5, 2024 14:10
@HenriquerPimentel HenriquerPimentel marked this pull request as ready for review June 14, 2024 12:00
@lunny lunny added this to the 1.23.0 milestone Jun 14, 2024
Copy link
Member

@techknowlogick techknowlogick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The CI has a few linting reports that came up that I've reported in line :)

templates/admin/badge/users.tmpl Show resolved Hide resolved
templates/admin/badge/users.tmpl Outdated Show resolved Hide resolved
@HenriquerPimentel
Copy link
Contributor Author

Thanks for the PR! The CI has a few linting reports that came up that I've reported in line :)

Thank you so much!

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/web/explore"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

routers can't import other routers, as that can get cyclical

@techknowlogick
Copy link
Member

@HenriquerPimentel looks like some different CI steps are failing, also related to linting (some public go functions require comments to document their purpose, eg AdminCreateBadge), although with AdminCreateBadge as it is a wrapper for another function without any transformative properties or checks that one could probably be kept as just CreateBadge without the secondary function.

As a sidenote: force pushing erases some review history as GitHub sees some files as new (even if they remain the same). If you could reduce your force pushes, it'd be helpful to me as a reviewer so I can keep track of what I've seen already
disclaimer: most of the time we try to discourage force pushing to PRs for this reason, although depending on the reviewer of a certain PR they can "call an audible" depending on the situation and might be ok with it.

@techknowlogick
Copy link
Member

Could you split the "explore" badge part of this PR into another PR and focus this one on badge management in the admin dashboard? Smaller PRs are easier to review, merge, and possibly backport.

Thanks for your patience during this review, and feedback :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants