]> source.dussan.org Git - gitea.git/commitdiff
Addition to (Add Location, Website and Description to API #15675) (#15690)
authorKN4CK3R <KN4CK3R@users.noreply.github.com>
Sun, 2 May 2021 19:03:15 +0000 (21:03 +0200)
committerGitHub <noreply@github.com>
Sun, 2 May 2021 19:03:15 +0000 (21:03 +0200)
* Use same name as other structs.

* Sync with normal forms.

* Edit description with API.

* Workaround for nil value.

modules/structs/admin_user.go
modules/structs/org.go
modules/structs/user.go
routers/api/v1/admin/user.go
templates/swagger/v1_json.tmpl

index ee1738579ab71a45d923447b8d786e9760145f68..5da4e9608bea762db0cdfa351648f37141b61815 100644 (file)
@@ -32,8 +32,9 @@ type EditUserOption struct {
        FullName                *string `json:"full_name" binding:"MaxSize(100)"`
        Password                string  `json:"password" binding:"MaxSize(255)"`
        MustChangePassword      *bool   `json:"must_change_password"`
-       Website                 *string `json:"website" binding:"MaxSize(50)"`
+       Website                 *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
        Location                *string `json:"location" binding:"MaxSize(50)"`
+       Description             *string `json:"description" binding:"MaxSize(255)"`
        Active                  *bool   `json:"active"`
        Admin                   *bool   `json:"admin"`
        AllowGitHook            *bool   `json:"allow_git_hook"`
index 4b79a4e70a0bf1fb1d34d3db9add6e016c6e5290..483f5044a8982bb8fe621a0d6efe902ce0eb1880 100644 (file)
@@ -22,9 +22,9 @@ type CreateOrgOption struct {
        // required: true
        UserName    string `json:"username" binding:"Required"`
        FullName    string `json:"full_name"`
-       Description string `json:"description"`
-       Website     string `json:"website"`
-       Location    string `json:"location"`
+       Description string `json:"description" binding:"MaxSize(255)"`
+       Website     string `json:"website" binding:"ValidUrl;MaxSize(255)"`
+       Location    string `json:"location" binding:"MaxSize(50)"`
        // possible values are `public` (default), `limited` or `private`
        // enum: public,limited,private
        Visibility                string `json:"visibility" binding:"In(,public,limited,private)"`
@@ -34,9 +34,9 @@ type CreateOrgOption struct {
 // EditOrgOption options for editing an organization
 type EditOrgOption struct {
        FullName    string `json:"full_name"`
-       Description string `json:"description"`
-       Website     string `json:"website"`
-       Location    string `json:"location"`
+       Description string `json:"description" binding:"MaxSize(255)"`
+       Website     string `json:"website" binding:"ValidUrl;MaxSize(255)"`
+       Location    string `json:"location" binding:"MaxSize(50)"`
        // possible values are `public`, `limited` or `private`
        // enum: public,limited,private
        Visibility                string `json:"visibility" binding:"In(,public,limited,private)"`
index efd246e566a8943df84689ab35541c6c44c5fd85..b5d5b9298ef011942eabb11d5f942a1b9e1453a4 100644 (file)
@@ -37,8 +37,8 @@ type User struct {
        Location string `json:"location"`
        // the user's website
        Website string `json:"website"`
-       // the user's biography
-       Description string `json:"bio"`
+       // the user's description
+       Description string `json:"description"`
 }
 
 // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
index 5a74c6ccd50811e17d4aa9b5ce1cdca8c1b5a246..2d4a3815f4ca4244898a61688a6d051eacb23098 100644 (file)
@@ -203,6 +203,9 @@ func EditUser(ctx *context.APIContext) {
        if form.Location != nil {
                u.Location = *form.Location
        }
+       if form.Description != nil {
+               u.Description = *form.Description
+       }
        if form.Active != nil {
                u.IsActive = *form.Active
        }
index 6d690ba275ad3ab6e703a8eebf5e6199e5c95034..8255ed6e6ea49b77080bfed8bf9f1f7c746b5f67 100644 (file)
           "type": "boolean",
           "x-go-name": "AllowImportLocal"
         },
+        "description": {
+          "type": "string",
+          "x-go-name": "Description"
+        },
         "email": {
           "type": "string",
           "format": "email",
           "type": "string",
           "x-go-name": "AvatarURL"
         },
-        "bio": {
-          "description": "the user's biography",
-          "type": "string",
-          "x-go-name": "Description"
-        },
         "created": {
           "type": "string",
           "format": "date-time",
           "x-go-name": "Created"
         },
+        "description": {
+          "description": "the user's description",
+          "type": "string",
+          "x-go-name": "Description"
+        },
         "email": {
           "type": "string",
           "format": "email",