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