summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb47
-rw-r--r--app/views/admin/groups/index.html.haml2
-rw-r--r--app/views/admin/teams/index.html.haml7
3 files changed, 41 insertions, 15 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index cd0754d7816..babf00e8052 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -46,10 +46,35 @@ class User < ActiveRecord::Base
attr_accessor :force_random_password
+ #
+ # Relations
+ #
+
# Namespace for personal projects
- has_one :namespace, dependent: :destroy, foreign_key: :owner_id, class_name: "Namespace", conditions: 'type IS NULL'
+ has_one :namespace,
+ dependent: :destroy,
+ foreign_key: :owner_id,
+ class_name: "Namespace",
+ conditions: 'type IS NULL'
+
+ # Profile
+ has_many :keys, dependent: :destroy
+
+ # Groups
+ has_many :groups, class_name: "Group", foreign_key: :owner_id
+
+ # Teams
+ has_many :own_teams,
+ class_name: "UserTeam",
+ foreign_key: :owner_id,
+ dependent: :destroy
+
+ has_many :user_team_user_relationships, dependent: :destroy
+ has_many :user_teams, through: :user_team_user_relationships
+ has_many :user_team_project_relationships, through: :user_teams
+ has_many :team_projects, through: :user_team_project_relationships
- has_many :keys, dependent: :destroy
+ # Projects
has_many :users_projects, dependent: :destroy
has_many :issues, dependent: :destroy, foreign_key: :author_id
has_many :notes, dependent: :destroy, foreign_key: :author_id
@@ -57,18 +82,16 @@ class User < ActiveRecord::Base
has_many :events, dependent: :destroy, foreign_key: :author_id, class_name: "Event"
has_many :assigned_issues, dependent: :destroy, foreign_key: :assignee_id, class_name: "Issue"
has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest"
+ has_many :projects, through: :users_projects
- has_many :groups, class_name: "Group", foreign_key: :owner_id
- has_many :recent_events, class_name: "Event", foreign_key: :author_id, order: "id DESC"
-
- has_many :projects, through: :users_projects
-
- has_many :user_team_user_relationships, dependent: :destroy
-
- has_many :user_teams, through: :user_team_user_relationships
- has_many :user_team_project_relationships, through: :user_teams
- has_many :team_projects, through: :user_team_project_relationships
+ has_many :recent_events,
+ class_name: "Event",
+ foreign_key: :author_id,
+ order: "id DESC"
+ #
+ # Validations
+ #
validates :name, presence: true
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ }
validates :bio, length: { within: 0..255 }
diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml
index 1b4ffcb6e02..b10a7394bd3 100644
--- a/app/views/admin/groups/index.html.haml
+++ b/app/views/admin/groups/index.html.haml
@@ -26,7 +26,7 @@
%tr
%td
%strong= link_to group.name, [:admin, group]
- %td= group.description
+ %td= truncate group.description
%td= group.path
%td= group.projects.count
%td
diff --git a/app/views/admin/teams/index.html.haml b/app/views/admin/teams/index.html.haml
index 62af4b50936..3690d6d9eb4 100644
--- a/app/views/admin/teams/index.html.haml
+++ b/app/views/admin/teams/index.html.haml
@@ -27,12 +27,15 @@
%tr
%td
%strong= link_to team.name, admin_team_path(team)
- %td= team.description
+ %td= truncate team.description
%td= team.path
%td= team.projects.count
%td= team.members.count
%td
- = link_to team.owner.name, admin_user_path(team.owner)
+ - if team.owner
+ = link_to team.owner.name, admin_user_path(team.owner)
+ - else
+ (deleted)
%td.bgred
= link_to 'Edit', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn btn-small"
= link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove"