Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
EIP
Project Forum
Project Forum
Commits
3121e4ab
Commit
3121e4ab
authored
Aug 24, 2022
by
Taico Aerts
Browse files
Merge branch 'development' into 'master'
Project Forum Release v2.8.5 - 24-08-2022 See merge request
!837
parents
2364e80a
7553469a
Changes
41
Hide whitespace changes
Inline
Side-by-side
app/assets/stylesheets/normal/helpers.scss
View file @
3121e4ab
...
...
@@ -222,6 +222,7 @@
.txt-strong
,
.txt-bold
{
font-weight
:bold
;
}
.txt-italic
{
font-style
:
italic
;
}
.txt-underline
{
text-decoration
:
underline
;
}
.txt-normal
{
font-weight
:
normal
;
}
.txt-uppercase
{
text-transform
:
uppercase
;
}
.txt-lowercase
{
text-transform
:
lowercase
;
}
...
...
@@ -266,6 +267,18 @@
}
.show-on-parent-hover-parent
.show-on-parent-hover
{
visibility
:
hidden
;
opacity
:
0
;
transition
:opacity
300ms
;
}
.show-on-parent-hover-parent
:hover
.show-on-parent-hover
{
visibility
:
visible
;
opacity
:
1
;
transition
:opacity
300ms
;
}
/* --------------
CENTER
-------------- */
...
...
app/controllers/admin/course_editions/project_imports_controller.rb
View file @
3121e4ab
...
...
@@ -76,7 +76,6 @@ module Admin
# Actually send notification if no failures occurred
event
.
notify
(
User
.
with_role
(
:client
,
project
),
as: :client
)
.
notify
(
User
.
with_role
(
:registrar
,
project
.
offerer
.
actable
)
-
User
.
with_role
(
:client
,
project
),
as: :registrar
)
.
notify
(
User
.
with_role
(
:employee
,
project
.
offerer
.
actable
)
-
User
.
with_role
(
:client
,
project
),
as: :employee
)
new_project
...
...
app/controllers/admin/groups_controller.rb
View file @
3121e4ab
...
...
@@ -62,13 +62,35 @@ module Admin
authorize!
:update
,
@group
csr
=
@group
.
project
.
course_edition
.
course_specific_roles
.
find_by
id:
params
[
:csr_id
]
user
=
User
.
find_by
id:
params
[
:user_id
]
if
csr
.
nil?
||
user
.
nil?
raise
ActionController
::
BadRequest
,
'Role or user not found'
end
if
params
[
:user_id
]
# add registered user
user
=
User
.
find_by
id:
params
[
:user_id
]
if
user
.
nil?
raise
ActionController
::
BadRequest
,
'User not found'
end
UserCourseSpecificRole
.
create
(
user:
user
,
resource:
@group
,
course_specific_role:
csr
)
UserCourseSpecificRole
.
create!
(
user:
user
,
resource:
@group
,
course_specific_role:
csr
)
else
# add unregistered user
unless
params
[
:name
]
&&
params
[
:email
]
raise
ActionController
::
BadRequest
,
'Name or user not specified'
end
user
=
User
.
find_by
email:
params
[
:email
]
if
user
# user actually exists
UserCourseSpecificRole
.
create!
(
user:
user
,
resource:
@group
,
course_specific_role:
csr
)
return
end
UserCourseSpecificRole
.
create!
(
resource:
@group
,
course_specific_role:
csr
,
unregistered_name:
params
[
:name
],
unregistered_email:
params
[
:email
]
)
end
redirect_to
admin_group_path
(
@group
)
end
...
...
app/controllers/admin/projects_controller.rb
View file @
3121e4ab
...
...
@@ -112,13 +112,39 @@ module Admin
authorize!
:update
,
@project
csr
=
@project
.
course_edition
.
course_specific_roles
.
find_by
id:
params
[
:csr_id
]
user
=
User
.
find_by
id:
params
[
:user_id
]
if
csr
.
nil?
||
user
.
nil?
raise
ActionController
::
BadRequest
,
'Role
or user
not found'
if
csr
.
nil?
raise
ActionController
::
BadRequest
,
'Role not found'
end
UserCourseSpecificRole
.
create
(
user:
user
,
resource:
@project
,
course_specific_role:
csr
)
if
params
[
:user_id
]
# add registered user
user
=
User
.
find_by
id:
params
[
:user_id
]
if
user
.
nil?
raise
ActionController
::
BadRequest
,
'User not found'
end
UserCourseSpecificRole
.
create!
(
user:
user
,
resource:
@project
,
course_specific_role:
csr
)
else
# add unregistered user
unless
params
[
:name
]
&&
params
[
:email
]
raise
ActionController
::
BadRequest
,
'Name or user not specified'
end
user
=
User
.
find_by
email:
params
[
:email
]
if
user
# user actually exists
UserCourseSpecificRole
.
create!
(
user:
user
,
resource:
@project
,
course_specific_role:
csr
)
return
end
UserCourseSpecificRole
.
create!
(
resource:
@project
,
course_specific_role:
csr
,
unregistered_name:
params
[
:name
],
unregistered_email:
params
[
:email
]
)
end
end
def
handle_user_csr_removal
...
...
app/controllers/companies/role_invitations_controller.rb
View file @
3121e4ab
...
...
@@ -62,7 +62,7 @@ module Companies
end
# do not create a new invitation if the user is already an employee
if
user
.
has_role?
(
:employee
,
@company
)
||
user
.
has_role?
(
:registrar
,
@company
)
if
user
.
has_role?
(
:employee
,
@company
)
flash
[
:danger
]
=
'This user is already an employee.'
return
end
...
...
app/controllers/companies/roles_controller.rb
View file @
3121e4ab
...
...
@@ -15,16 +15,14 @@ module Companies
protected
# Removes the current users employee
/registrar
role, checks whether there are enough employees on the company
# Removes the current users employee role, checks whether there are enough employees on the company
# before removing the role.
def
remove_current_role
if
@company
.
confirmed_involved_users
.
count
>
1
if
current_user
.
remove_role
(
:employee
,
@company
)
flash
[
:success
]
=
'Successfully left as employee'
elsif
current_user
.
remove_role
(
:registrar
,
@company
)
flash
[
:success
]
=
'Successfully left as registrar'
flash
[
:success
]
=
'Successfully left the company'
else
flash
[
:danger
]
=
'Failed to leave
as
company'
flash
[
:danger
]
=
'Failed to leave company'
end
else
flash
[
:danger
]
=
'Cannot leave company. The company must have at least one employee.'
...
...
app/controllers/companies_controller.rb
View file @
3121e4ab
...
...
@@ -21,7 +21,7 @@ class CompaniesController < OfferersController
##
# Action to view an index of all of the user's involved companies.
def
index
@companies
=
current_user
.
involved_companies
(
%i[employee
registrar
unconfirmed_employee]
)
@companies
=
current_user
.
involved_companies
(
%i[employee unconfirmed_employee]
)
@involved_in_companies
=
@companies
.
any?
@company_invitations
=
current_user
.
invited_by_which_companies
@has_company_invitations
=
@company_invitations
.
any?
...
...
@@ -50,7 +50,7 @@ class CompaniesController < OfferersController
extra_checks:
{
Image
.
model_name
.
human
=>
->
{
save_image
},
Role
.
model_name
.
human
=>
lambda
do
current_user
.
add_role
(
:
registrar
,
@company
).
persisted?
current_user
.
add_role
(
:
employee
,
@company
).
persisted?
rescue
StandardError
false
end
...
...
app/controllers/course_editions/projects/project_interests_controller.rb
View file @
3121e4ab
...
...
@@ -25,7 +25,7 @@ module CourseEditions
def
destroy
authorize!
:destroy
,
@project_interest
if
@project_interest
.
present?
flash
[
:success
]
=
'You have been removed from the interest list.'
flash
[
:success
]
=
'You have been removed from the interest list.'
unless
request
.
xhr?
@project_interest
.
destroy
else
flash
[
:danger
]
=
"You were not found in the interest list. If this
...
...
@@ -48,7 +48,7 @@ module CourseEditions
flash
[
:danger
]
=
'You cannot join the interest list for this project
when you are already in a group for this project.'
else
flash
[
:success
]
=
'You have been placed in the interest list.'
flash
[
:success
]
=
'You have been placed in the interest list.'
unless
request
.
xhr?
@project
.
interested_users
<<
current_user
end
end
...
...
app/controllers/dashboards_controller.rb
View file @
3121e4ab
...
...
@@ -17,7 +17,7 @@ class DashboardsController < ApplicationController
@coached_groups
=
current_user
.
coached_groups
(
CourseEdition
.
active
)
@groups_awaiting_approval
=
Group
.
where
(
project_id:
current_user
.
updatable_offerer_projects
.
ids
).
awaiting_client_approval
@companies
=
current_user
.
involved_companies
(
%i[employee
registrar
unconfirmed_employee]
)
@companies
=
current_user
.
involved_companies
(
%i[employee unconfirmed_employee]
)
@research_groups
=
current_user
.
involved_research_groups
end
end
app/helpers/translate_helper.rb
View file @
3121e4ab
...
...
@@ -7,7 +7,9 @@ module TranslateHelper
groups_name:
groups_name
,
project_name:
project_name
,
projects_name:
projects_name
,
company_name:
current_user
.
nil?
?
'company'
:
current_user
.
company_name
company_name:
current_user
.
nil?
?
'company'
:
current_user
.
company_name
,
company_name_capitalized:
current_user
.
nil?
?
'Company'
:
current_user
.
company_name
.
capitalize
,
companies_name:
current_user
.
nil?
?
'companies'
:
current_user
.
companies_name
}
translate
(
path
,
**
default_params
.
merge
(
custom_params
))
end
...
...
app/models/company.rb
View file @
3121e4ab
class
Company
<
ApplicationRecord
include
ElasticSearchable
ROLES
=
%i[
registrar
employee unconfirmed_employee]
.
freeze
ROLES
=
%i[employee unconfirmed_employee]
.
freeze
resourcify
acts_as
:offerer
...
...
@@ -20,11 +20,8 @@ class Company < ApplicationRecord
# @return [ActiveRecord::Relation] all the employees of this company
relate_users_role
:employees
,
:employee
# @return [ActiveRecord::Relation] all the registrars of this company
relate_users_role
:registrars
,
:registrar
# @return [ActiveRecord::Relation] all the employees and registrars of this company
relate_users_role
:confirmed_involved_users
,
%i[employee registrar]
# @return [ActiveRecord::Relation] all the employees of this company
relate_users_role
:confirmed_involved_users
,
:employee
# @return [ActiveRecord::Relation] all the unconfirmed employees of this company
relate_users_role
:unconfirmed_employees
,
:unconfirmed_employee
...
...
@@ -32,11 +29,6 @@ class Company < ApplicationRecord
# @return [ActiveRecord::Relation] all the (unique) users which are directly involved with this company
relate_users_role
:involved_users
,
->
{
distinct
}
# @return [User] The registrar of this company
def
registrar
registrars
.
first
end
# @param user [User] the user
# @return [Boolean] whether the given user is involved in ((unconfirmed) employee of) this company
def
involved?
(
user
)
...
...
app/models/concerns/user_concerns/associatable.rb
View file @
3121e4ab
...
...
@@ -250,7 +250,7 @@ module UserConcerns
end
def
involved_companies
(
roles
=
nil
)
roles
||=
%i[
registrar
employee]
roles
||=
%i[employee]
Company
.
with_role
(
roles
,
self
)
end
...
...
@@ -278,7 +278,7 @@ module UserConcerns
# Companies eligible to offer projects within the specified course edition
def
eligible_companies
(
course_edition
=
nil
)
roles
||=
%i[
registrar
employee unconfirmed_employee]
roles
||=
%i[employee unconfirmed_employee]
if
course_edition
.
nil?
Company
.
with_role
(
roles
,
self
)
elsif
course_edition
.
configuration
.
allow_company_offerers
...
...
@@ -338,7 +338,7 @@ module UserConcerns
||
involved_projects
.
generic_projects
.
any?
\
||
invited_groups
(
'GenericProject'
).
present?
\
||
coached_groups
(
nil
,
'GenericProject'
).
present?
\
||
involved_companies
(
%i[
registrar
employee unconfirmed_employee]
).
any?
||
involved_companies
(
%i[employee unconfirmed_employee]
).
any?
end
def
offerer_groups
...
...
app/views/admin/companies/_form.html.erb
View file @
3121e4ab
...
...
@@ -11,13 +11,6 @@
<tr>
<td>
<%=
f
.
text_area
:description
,
rows:
20
%>
</td>
</tr>
<%
if
f
.
object
.
persisted?
&&
f
.
object
.
registrar
.
present?
%>
<tr><td>
<%=
f
.
form_group
:registrar
,
label:
{
text:
Company
.
human_attribute_name
(
:registrar
)
}
do
%>
<%=
f
.
object
.
registrar
.
full_name
if
f
.
object
.
registrar
.
present?
%>
<%
end
%>
</td></tr>
<%
end
%>
<tr>
<td>
<%=
f
.
text_field
:email
%>
</td>
</tr>
...
...
app/views/admin/companies/index.csv.erb
View file @
3121e4ab
<%-
headers
=
[
Company
.
human_attribute_name
(
:id
),
Company
.
human_attribute_name
(
:name
),
Company
.
human_attribute_name
(
:
registrar
),
Company
.
human_attribute_name
(
:
employees
),
Company
.
human_attribute_name
(
:full_street_name
),
Company
.
human_attribute_name
(
:website_url
)
]
-%>
...
...
@@ -10,7 +10,7 @@
<%=
CSV
.
generate_line
([
company
.
id
,
company
.
name
,
company
.
registrar
.
nam
e
,
company
.
employees
.
map
(
&
:full_name
).
to_sentenc
e
,
company
.
full_street_name
,
company
.
website_url
])
-%>
...
...
app/views/admin/companies/index.xlsx.axlsx
View file @
3121e4ab
...
...
@@ -5,7 +5,7 @@ wb.add_worksheet(name: 'companies') do |sheet|
sheet.add_row [
Company.human_attribute_name(:id),
Company.human_attribute_name(:name),
Company.human_attribute_name(:
registrar
),
Company.human_attribute_name(:
employees
),
Company.human_attribute_name(:full_street_name),
Company.human_attribute_name(:website_url)
], style: styles[:legend]
...
...
@@ -14,7 +14,7 @@ wb.add_worksheet(name: 'companies') do |sheet|
sheet.add_row [
company.id,
company.name,
company.
registrar.nam
e,
company.
employees.map(&:full_name).to_sentenc
e,
company.full_street_name,
company.website_url
]
...
...
app/views/admin/companies/index/_table.html.erb
View file @
3121e4ab
...
...
@@ -4,7 +4,7 @@
<tr>
<th>
<%=
sort_link
@q
,
:id
%>
</th>
<th>
<%=
sort_link
@q
,
:name
%>
</th>
<th>
<%=
Company
.
human_attribute_name
:
registrar
%>
</th>
<th>
<%=
Company
.
human_attribute_name
:
employees
%>
</th>
<th>
<%=
sort_link
@q
,
:city
%>
</th>
<th>
<%=
sort_link
@q
,
:projects_count
%>
</th>
</tr>
...
...
@@ -19,9 +19,7 @@
<%=
company
.
name
%>
</td>
<td>
<%
if
company
.
registrar
.
present?
%>
<%=
company
.
registrar
.
full_name
%>
<%
end
%>
<%=
company
.
employees
.
map
(
&
:full_name
).
to_sentence
%>
</td>
<td>
<%=
company
.
city
%>
...
...
app/views/admin/course_specific_roles/component/_course_specific_role_assignments.erb
View file @
3121e4ab
...
...
@@ -88,14 +88,41 @@
<%
if
can?
:edit
,
resource
%>
<div
class=
"collapse"
id=
"add-course-specific-role-assignment-
<%=
csr
.
id
%>
"
>
<div
class=
"list-group-item"
>
<%=
bootstrap_form_with
url:
addition_path
,
method:
'post'
do
|
form
|
%>
<%=
render
'admin/users/user_selection_dropdown'
,
form:
form
,
field_id: :user_id
,
staff:
other_staff
,
students:
students
,
external:
external
%>
<%=
form
.
submit
"Add"
,
class:
'btn btn-primary'
%>
<%=
form
.
hidden_field
:csr_id
,
value:
csr
.
id
%>
<ul
class=
"nav nav-tabs nav-justified mbm mtm"
role=
"tablist"
>
<li
role=
"presentation"
class=
"active"
>
<a
href=
"#add-course-specific-role-assignment-registered-
<%=
csr
.
id
%>
"
aria-controls=
"add-course-specific-role-assignment-registered-
<%=
csr
.
id
%>
"
role=
"tab"
data-toggle=
"tab"
>
Add TU Delft User or Registered External User
</a>
</li>
<li
role=
"presentation"
>
<a
href=
"#add-course-specific-role-assignment-unregistered-
<%=
csr
.
id
%>
"
aria-controls=
"add-course-specific-role-assignment-unregistered-
<%=
csr
.
id
%>
"
role=
"tab"
data-toggle=
"tab"
>
Add Unregistered External User
</a>
</li>
</ul>
<div
class=
"tab-content"
>
<div
role=
"tabpanel"
class=
"tab-pane active fade in"
id=
"add-course-specific-role-assignment-registered-
<%=
csr
.
id
%>
"
>
<%=
bootstrap_form_with
url:
addition_path
,
method:
'post'
do
|
form
|
%>
<%=
render
'admin/users/user_selection_dropdown'
,
form:
form
,
field_id: :user_id
,
staff:
other_staff
,
students:
students
,
external:
external
%>
<%=
form
.
submit
"Add"
,
class:
'btn btn-primary'
%>
<%=
form
.
hidden_field
:csr_id
,
value:
csr
.
id
%>
<%
end
%>
</div>
<div
role=
"tabpanel"
class=
"tab-pane fade"
id=
"add-course-specific-role-assignment-unregistered-
<%=
csr
.
id
%>
"
>
<%=
bootstrap_form_with
url:
addition_path
,
method:
'post'
do
|
form
|
%>
<%=
form
.
text_field
:name
,
placeholder:
"Full name"
,
required:
true
,
value:
''
%>
<%=
form
.
email_field
:email
,
placeholder:
"someone@example.com"
,
required:
true
,
value:
''
%>
<%=
form
.
submit
"Add"
,
class:
'btn btn-primary'
%>
<%=
form
.
hidden_field
:csr_id
,
value:
csr
.
id
%>
<%
end
%>
</div>
</div>
<%
end
%>
</div>
</div>
<a
class=
"list-group-item list-group-item--button"
data-toggle=
"collapse"
...
...
app/views/companies/index.html.erb
View file @
3121e4ab
...
...
@@ -16,7 +16,7 @@
<%
end
%>
<form
action=
"
<%=
new_company_path
%>
"
>
<%=
button_tag
glyphicon_text
(
:pencil
,
"Create
#{
@company_name
.
capitalize
}
"
),
class:
'btn btn-warning'
,
disabled:
!
can_create_company
%>
<%
if
!
current_user
.
role_student?
||
current_user
.
involved_companies
(
%i[employee
registrar
unconfirmed_employee]
).
any?
%>
<%
if
!
current_user
.
role_student?
||
current_user
.
involved_companies
(
%i[employee unconfirmed_employee]
).
any?
%>
<%=
modal_button
"Join
#{
@company_name
.
capitalize
}
"
,
'join-company'
,
class:
'btn btn-primary'
%>
<%
end
%>
</form>
...
...
@@ -35,6 +35,6 @@
<%=
render
'companies/index/research_groups_list'
%>
<%
end
%>
<%
if
!
current_user
.
role_student?
||
current_user
.
involved_companies
(
%i[employee
registrar
unconfirmed_employee]
).
any?
%>
<%
if
!
current_user
.
role_student?
||
current_user
.
involved_companies
(
%i[employee unconfirmed_employee]
).
any?
%>
<%=
render
'companies/modals/modal_join_company'
%>
<%
end
%>
\ No newline at end of file
app/views/companies/modals/_modal_join_company.html.erb
View file @
3121e4ab
...
...
@@ -28,13 +28,13 @@
<%=
bootstrap_form_tag
url:
join_companies_url
,
method: :post
do
|
f
|
%>
<div
class=
"col-md-6 no-padding"
id=
"form-div"
>
<%=
f
.
collection_select
:company
,
Company
.
without_role
(
%i[
registrar
employee unconfirmed_employee]
,
current_user
),
Company
.
without_role
(
%i[employee unconfirmed_employee]
,
current_user
),
:id
,
:name
,
{
prompt:
true
,
placeholder:
"Select Company"
,
skip_label:
true
},
{
required:
true
,
id:
'company-select'
}
%>
</div>
<%=
f
.
hidden_field
"disabled_options"
,
value:
Company
.
without_role
(
%i[
registrar
employee unconfirmed_employee]
,
current_user
).
where
(
allow_to_join:
false
).
ids
%>
<%=
f
.
hidden_field
"disabled_options"
,
value:
Company
.
without_role
(
%i[employee unconfirmed_employee]
,
current_user
).
where
(
allow_to_join:
false
).
ids
%>
<div
class=
"col-md-6"
>
<%=
f
.
submit
"Join
#{
current_user
.
company_name
.
capitalize
}
"
,
class:
'btn btn-primary'
%>
</div>
...
...
app/views/course_editions/preferences/_preferences_logic.html.erb
View file @
3121e4ab
...
...
@@ -96,5 +96,39 @@
update
:
markDirty
});
<%
end
%>
$
(
'
.toggle-interest-list
'
).
click
(
function
()
{
let
btn
=
$
(
this
);
let
icon
=
btn
.
find
(
'
i
'
);
icon
.
addClass
(
'
fa-beat
'
);
btn
.
removeClass
(
'
show-on-parent-hover
'
);
let
interested
=
btn
.
data
(
'
interested
'
);
let
url
=
btn
.
data
(
'
url
'
);
$
.
ajax
({
type
:
interested
?
'
DELETE
'
:
'
POST
'
,
url
:
url
,
data
:
{
authenticity_token
:
window
.
_token
},
dataType
:
'
text
'
}).
done
(
function
()
{
if
(
interested
)
{
icon
.
removeClass
(
'
fa-solid
'
);
icon
.
addClass
(
'
fa-regular
'
);
btn
.
addClass
(
'
show-on-parent-hover
'
);
}
else
{
icon
.
removeClass
(
'
fa-regular
'
);
icon
.
addClass
(
'
fa-solid
'
);
}
btn
.
data
(
'
interested
'
,
!
interested
);
icon
.
removeClass
(
'
fa-beat
'
);
}).
fail
(
function
(
e
)
{
console
.
log
(
e
);
showResultMsg
(
'
Unable to
'
+
(
interested
?
'
leave
'
:
'
join
'
)
+
'
interest list
'
,
'
red
'
);
icon
.
removeClass
(
'
fa-beat
'
);
});
});
});
</script>
\ No newline at end of file
Prev
1
2
3
Next
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