Description:
fix bug with duplicate logins are given also increase dropdown size on group view
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r809:e8c8ed4696af - - 3 files changed: 7 inserted, 3 deleted

@@ -1,20 +1,20
1 1 class Group < ActiveRecord::Base
2 2 has_many :groups_problems, class_name: 'GroupProblem'
3 3 has_many :problems, :through => :groups_problems
4 4
5 5 has_many :groups_users, class_name: 'GroupUser'
6 6 has_many :users, :through => :groups_users
7 7
8 8 #has_and_belongs_to_many :problems
9 9 #has_and_belongs_to_many :users
10 10
11 11 def add_users_skip_existing(users_list)
12 12 new_list = []
13 - users_list.each do |u|
13 + users_list.uniq.each do |u|
14 14 new_list << u unless users.include? u
15 15 end
16 16 users << new_list
17 17 end
18 18
19 19 end
20 20
@@ -73,24 +73,28
73 73 return user if user.authenticated?(password)
74 74 end
75 75 end
76 76
77 77 def authenticated?(password)
78 78 if self.activated
79 79 hashed_password == User.encrypt(password,self.salt)
80 80 else
81 81 false
82 82 end
83 83 end
84 84
85 + def login_with_name
86 + "[#{login}] #{full_name}"
87 + end
88 +
85 89 def admin?
86 90 has_role?('admin')
87 91 end
88 92
89 93 def has_role?(role)
90 94 self.roles.where(name: role).count > 0
91 95 end
92 96
93 97 def email_for_editing
94 98 if self.email==nil
95 99 "(unknown)"
96 100 elsif self.email==''
@@ -18,25 +18,25
18 18 .panel-title Users in this group
19 19 .panel-body
20 20 %ul
21 21 %li
22 22 If you want to add several users to a group, it may be easier to just re-import those users in
23 23 = link_to 'New list of users', new_list_user_admin_index_path
24 24 page. You can also use
25 25 = link_to 'Bulk Manage User', bulk_manage_user_admin_index_path
26 26 page.
27 27 =form_tag add_user_group_path(@group), class: 'form-inline' do
28 28 .form-group
29 29 =label_tag :user_id, "User"
30 - =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2', style: 'width: 10em';
30 + =select_tag :user_id, options_from_collection_for_select(User.all,'id','login_with_name'), class: 'select2', style: 'width: 25em';
31 31 =submit_tag "Add",class: 'btn btn-primary'
32 32
33 33
34 34 %table.table.table-hover
35 35 %thead
36 36 %tr
37 37 %th Login
38 38 %th Full name
39 39 %th Remark
40 40 %th= link_to 'Remove All', remove_all_user_group_path(@group), method: :delete, :data => { :confirm => "Remove ALL USERS from group?" }, class: 'btn btn-danger btn-sm'
41 41
42 42 %tbody
@@ -50,25 +50,25
50 50 .panel.panel-default
51 51 .panel-heading
52 52 .panel-title Problems
53 53 .panel-body
54 54 %ul
55 55 %li
56 56 If you want to add several problem to a group, it may be easier to bulk manage them in the
57 57 = link_to 'Bulk Manage Problems', manage_problems_path
58 58 page
59 59 =form_tag add_problem_group_path(@group), class: 'form-inline' do
60 60 .form-group
61 61 =label_tag :problem_id, "Problem"
62 - =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2', style: 'width: 10em';
62 + =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','long_name'), class: 'select2', style: 'width: 25em';
63 63 =submit_tag "Add",class: 'btn btn-primary'
64 64
65 65
66 66 %table.table.table-hover
67 67 %thead
68 68 %tr
69 69 %th name
70 70 %th Full name
71 71 %th Full score
72 72 %th= link_to 'Remove All', remove_all_problem_group_path(@group), method: :delete, :data => { :confirm => "Remove ALL PROBLEMS from group?" }, class: 'btn btn-danger btn-sm'
73 73
74 74 %tbody
You need to be logged in to leave comments. Login now