Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
d78b6ce4
Commit
d78b6ce4
authored
Nov 05, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New feature: Ability to leave project
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f9b66aec
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
app/controllers/projects/team_members_controller.rb
app/controllers/projects/team_members_controller.rb
+10
-1
app/models/project.rb
app/models/project.rb
+5
-1
app/models/user.rb
app/models/user.rb
+5
-0
app/views/dashboard/projects.html.haml
app/views/dashboard/projects.html.haml
+8
-1
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/controllers/projects/team_members_controller.rb
View file @
d78b6ce4
class
Projects::TeamMembersController
<
Projects
::
ApplicationController
# Authorize
before_filter
:authorize_admin_project!
before_filter
:authorize_admin_project!
,
except: :leave
layout
"project_settings"
...
...
@@ -45,6 +45,15 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
end
def
leave
project
.
users_projects
.
find_by_user_id
(
current_user
).
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
js
{
render
nothing:
true
}
end
end
def
apply_import
giver
=
Project
.
find
(
params
[
:source_project_id
])
status
=
@project
.
team
.
import
(
giver
)
...
...
app/models/project.rb
View file @
d78b6ce4
...
...
@@ -447,4 +447,8 @@ class Project < ActiveRecord::Base
order
(
'id DESC'
).
limit
(
100
).
update_all
(
updated_at:
Time
.
now
)
end
def
project_member
(
user
)
users_projects
.
where
(
user_id:
user
).
first
end
end
app/models/user.rb
View file @
d78b6ce4
...
...
@@ -394,4 +394,9 @@ class User < ActiveRecord::Base
self
end
def
can_leave_project?
(
project
)
project
.
namespace
!=
namespace
&&
project
.
project_member
(
self
)
end
end
app/views/dashboard/projects.html.haml
View file @
d78b6ce4
...
...
@@ -54,7 +54,7 @@
.span9
%ul
.bordered-list.my-projects.top-list
-
@projects
.
each
do
|
project
|
%li
%li
.my-project-row
%h4
.project-title
=
link_to
project_path
(
project
),
class:
dom_class
(
project
)
do
=
project
.
name_with_namespace
...
...
@@ -63,6 +63,12 @@
=
public_icon
Public
-
if
current_user
.
can_leave_project?
(
project
)
.pull-right
=
link_to
leave_project_team_members_path
(
project
),
confirm:
"Leave project?"
,
method: :delete
,
remote:
true
,
class:
"btn-tiny btn remove-row"
,
title:
'Leave project'
do
%i
.icon-signout
Leave
-
if
project
.
forked_from_project
%small
.pull-right
%i
.icon-code-fork
...
...
@@ -80,6 +86,7 @@
%span
.light
Last activity:
%span
.date
=
project_last_activity
(
project
)
-
if
@projects
.
blank?
%li
%h3
.nothing_here_message
There are no projects here.
...
...
config/routes.rb
View file @
d78b6ce4
...
...
@@ -288,6 +288,7 @@ Gitlab::Application.routes.draw do
resources
:team_members
,
except:
[
:index
,
:edit
],
constraints:
{
id:
/[a-zA-Z.\/0-9_\-#%+]+/
}
do
collection
do
delete
:leave
# Used for import team
# from another project
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment