Commit 3dc0bce9474ac52046f5c3efb2532af6334a7aae
1 parent
ab094e67
Exists in
spb-stable
and in
2 other branches
Add users to /:id route
So now when you type site/:username it redirects you to users page. And if you type site/:groupname it redirects you to group page Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
19 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +class NamespacesController < ApplicationController | ||
2 | + skip_before_filter :authenticate_user! | ||
3 | + | ||
4 | + def show | ||
5 | + namespace = Namespace.find_by(path: params[:id]) | ||
6 | + | ||
7 | + unless namespace | ||
8 | + return render_404 | ||
9 | + end | ||
10 | + | ||
11 | + if namespace.type == "Group" | ||
12 | + redirect_to group_path(namespace) | ||
13 | + else | ||
14 | + redirect_to user_path(namespace.owner) | ||
15 | + end | ||
16 | + end | ||
17 | +end | ||
18 | + |
config/routes.rb
@@ -315,7 +315,7 @@ Gitlab::Application.routes.draw do | @@ -315,7 +315,7 @@ Gitlab::Application.routes.draw do | ||
315 | end | 315 | end |
316 | end | 316 | end |
317 | 317 | ||
318 | - get ':id' => "groups#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} | 318 | + get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} |
319 | 319 | ||
320 | root to: "dashboard#show" | 320 | root to: "dashboard#show" |
321 | end | 321 | end |