diff options
Diffstat (limited to 'http_handle_group_index.go')
-rw-r--r-- | http_handle_group_index.go | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/http_handle_group_index.go b/http_handle_group_index.go index 3ed3a85..51e4773 100644 --- a/http_handle_group_index.go +++ b/http_handle_group_index.go @@ -12,15 +12,15 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) -func handle_group_index(w http.ResponseWriter, r *http.Request, params map[string]any) { - var group_path []string +func httpHandleGroupIndex(w http.ResponseWriter, r *http.Request, params map[string]any) { + var groupPath []string var repos []nameDesc var subgroups []nameDesc var err error - var group_id int - var group_description string + var groupID int + var groupDesc string - group_path = params["group_path"].([]string) + groupPath = params["group_path"].([]string) // The group itself err = database.QueryRow(r.Context(), ` @@ -51,8 +51,8 @@ func handle_group_index(w http.ResponseWriter, r *http.Request, params map[strin JOIN groups g ON g.id = c.id WHERE c.depth = cardinality($1::text[]) `, - pgtype.FlatArray[string](group_path), - ).Scan(&group_id, &group_description) + pgtype.FlatArray[string](groupPath), + ).Scan(&groupID, &groupDesc) if err == pgx.ErrNoRows { http.Error(w, "Group not found", http.StatusNotFound) @@ -69,64 +69,64 @@ func handle_group_index(w http.ResponseWriter, r *http.Request, params map[strin FROM user_group_roles WHERE user_id = $1 AND group_id = $2 - `, params["user_id"].(int), group_id).Scan(&count) + `, params["user_id"].(int), groupID).Scan(&count) if err != nil { http.Error(w, "Error checking access: "+err.Error(), http.StatusInternalServerError) return } - direct_access := (count > 0) + directAccess := (count > 0) if r.Method == "POST" { - if !direct_access { + if !directAccess { http.Error(w, "You do not have direct access to this group", http.StatusForbidden) return } - repo_name := r.FormValue("repo_name") - repo_description := r.FormValue("repo_desc") - contrib_requirements := r.FormValue("repo_contrib") - if repo_name == "" { + repoName := r.FormValue("repo_name") + repoDesc := r.FormValue("repo_desc") + contribReq := r.FormValue("repo_contrib") + if repoName == "" { http.Error(w, "Repo name is required", http.StatusBadRequest) return } - var new_repo_id int + var newRepoID int err := database.QueryRow( r.Context(), `INSERT INTO repos (name, description, group_id, contrib_requirements) VALUES ($1, $2, $3, $4) RETURNING id`, - repo_name, - repo_description, - group_id, - contrib_requirements, - ).Scan(&new_repo_id) + repoName, + repoDesc, + groupID, + contribReq, + ).Scan(&newRepoID) if err != nil { http.Error(w, "Error creating repo: "+err.Error(), http.StatusInternalServerError) return } - file_path := filepath.Join(config.Git.RepoDir, strconv.Itoa(new_repo_id)+".git") + filePath := filepath.Join(config.Git.RepoDir, strconv.Itoa(newRepoID)+".git") _, err = database.Exec( r.Context(), `UPDATE repos SET filesystem_path = $1 WHERE id = $2`, - file_path, - new_repo_id, + filePath, + newRepoID, ) if err != nil { http.Error(w, "Error updating repo path: "+err.Error(), http.StatusInternalServerError) return } - if err = gitInit(file_path); err != nil { + if err = gitInit(filePath); err != nil { http.Error(w, "Error initializing repo: "+err.Error(), http.StatusInternalServerError) return } - redirect_unconditionally(w, r) + redirectUnconditionally(w, r) return } @@ -136,7 +136,7 @@ func handle_group_index(w http.ResponseWriter, r *http.Request, params map[strin SELECT name, COALESCE(description, '') FROM repos WHERE group_id = $1 - `, group_id) + `, groupID) if err != nil { http.Error(w, "Error getting repos: "+err.Error(), http.StatusInternalServerError) return @@ -161,7 +161,7 @@ func handle_group_index(w http.ResponseWriter, r *http.Request, params map[strin SELECT name, COALESCE(description, '') FROM groups WHERE parent_group = $1 - `, group_id) + `, groupID) if err != nil { http.Error(w, "Error getting subgroups: "+err.Error(), http.StatusInternalServerError) return @@ -183,8 +183,8 @@ func handle_group_index(w http.ResponseWriter, r *http.Request, params map[strin params["repos"] = repos params["subgroups"] = subgroups - params["description"] = group_description - params["direct_access"] = direct_access + params["description"] = groupDesc + params["direct_access"] = directAccess - render_template(w, "group", params) + renderTemplate(w, "group", params) } |