Commit d6e44e3a69a968edb8ec2e7b5029b471a4394a92

  • avatar
  • tomas-muller <muller @uni…me.org> (Committer)
  • Wed May 06 16:38:16 EEST 2015
  • avatar
  • tomas-muller <muller @uni…me.org> (Author)
  • Wed May 06 16:38:16 EEST 2015
Cancelled Classes: Make Not-Offered / Cross List

Make Not-Offered: it is allowed to make an offering not-offered only when at least one of the following conditions is met
Cross Lists: it is allowed to remove a cross-listed course from an offering only when at least one of the following conditions is met

- there are no students enrolled
- there is no committed solution
- the user has the Class Delete No Enrollment Check permission
Documentation/Database/MySQL/Changes/147 Delete From Cross List.sql
(31 / 0)
  
1/*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for
4 * additional information regarding copyright ownership.
5 *
6 * The Apereo Foundation licenses this file to you under the Apache License,
7 * Version 2.0 (the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 *
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19*/
20
21insert into rights (role_id, value)
22 select distinct r.role_id, 'CourseOfferingDeleteFromCrossList'
23 from roles r, rights g where g.role_id = r.role_id and g.value = 'InstructionalOfferingCrossLists';
24
25/*
26 * Update database version
27 */
28
29update application_config set value='147' where name='tmtbl.db.version';
30
31commit;
Documentation/Database/Oracle/Changes/147 Delete From Cross List.sql
(31 / 0)
  
1/*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for
4 * additional information regarding copyright ownership.
5 *
6 * The Apereo Foundation licenses this file to you under the Apache License,
7 * Version 2.0 (the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 *
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19*/
20
21insert into rights (role_id, value)
22 select distinct r.role_id, 'CourseOfferingDeleteFromCrossList'
23 from roles r, rights g where g.role_id = r.role_id and g.value = 'InstructionalOfferingCrossLists';
24
25/*
26 * Update database version
27 */
28
29update application_config set value='147' where name='tmtbl.db.version';
30
31commit;
JavaSource/dbupdate.xml
(7 / 0)
  
1008710087 from %SCHEMA%.roles r, %SCHEMA%.rights g where g.role_id = r.role_id and g.value in ('ClassEdit', 'MultipleClassSetupClass')
1008810088 </sql>
1008910089 </update>
10090 <update version="147" date="6-May-2015" comment="Delete From Cross List">
10091 <sql>
10092 insert into %SCHEMA%.rights (role_id, value)
10093 select distinct r.role_id, 'CourseOfferingDeleteFromCrossList'
10094 from %SCHEMA%.roles r, %SCHEMA%.rights g where g.role_id = r.role_id and g.value = 'InstructionalOfferingCrossLists'
10095 </sql>
10096 </update>
1009010097</dbupdate>
JavaSource/org/unitime/timetable/action/CrossListsModifyAction.java
(4 / 2)
  
159159 CourseOffering co = cdao.get(addedOffering);
160160
161161 // Check reservations limit
162 frm.addToCourseOfferings(co, sessionContext.getUser().getCurrentAuthority().hasRight(Right.DepartmentIndependent) || sessionContext.getUser().getCurrentAuthority().hasQualifier(co.getDepartment()));
162 frm.addToCourseOfferings(co, sessionContext.getUser().getCurrentAuthority().hasRight(Right.DepartmentIndependent) || sessionContext.getUser().getCurrentAuthority().hasQualifier(co.getDepartment()), true);
163163 frm.setAddCourseOfferingId(null);
164164 }
165165 else {
295295 InstructionalOffering io1 = new InstructionalOffering();
296296 CourseOffering co1 = cdao.get(new Long(origCrs.trim()));
297297
298 sessionContext.checkPermission(co1, Right.CourseOfferingDeleteFromCrossList);
299
298300 // Copy attributes of old instr offering - make not offered
299301 io1.setDemand(io.getDemand());
300302 io1.setLimit(io.getLimit());
608608
609609 for(Iterator i = offerings.iterator(); i.hasNext(); ) {
610610 CourseOffering co1 = ((CourseOffering) i.next());
611 frm.addToCourseOfferings(co1, sessionContext.getUser().getCurrentAuthority().hasRight(Right.DepartmentIndependent) || sessionContext.getUser().getCurrentAuthority().hasQualifier(co1.getDepartment()));
611 frm.addToCourseOfferings(co1, sessionContext.getUser().getCurrentAuthority().hasRight(Right.DepartmentIndependent) || sessionContext.getUser().getCurrentAuthority().hasQualifier(co1.getDepartment()), sessionContext.hasPermission(co1, Right.CourseOfferingDeleteFromCrossList));
612612 frm.addToOriginalCourseOfferings(co1);
613613 }
614614 }
JavaSource/org/unitime/timetable/form/CrossListsModifyForm.java
(18 / 1)
  
6868 private List requested;
6969 private List projected;
7070 private List lastTerm;
71 private List canDelete;
7172
7273 private Integer ioLimit;
7374 private Boolean unlimited;
136136 requested = DynamicList.getInstance(new ArrayList(), factoryCourseOfferings);
137137 projected = DynamicList.getInstance(new ArrayList(), factoryCourseOfferings);
138138 lastTerm = DynamicList.getInstance(new ArrayList(), factoryCourseOfferings);
139 canDelete = DynamicList.getInstance(new ArrayList(), factoryCourseOfferings);
139140 originalOfferings = "";
140141 ioLimit = null;
141142 unlimited = null;
246246 public void setLastTerm(List lastTerm) {
247247 this.lastTerm = lastTerm;
248248 }
249
250 public List getCanDelete() {
251 return canDelete;
252 }
253 public Boolean getCanDelete(int key) {
254 return (Boolean)canDelete.get(key);
255 }
256 public void setCanDelete(int key, Boolean value) {
257 this.canDelete.set(key, value);
258 }
259 public void setCanDelete(List canDelete) {
260 this.canDelete = canDelete;
261 }
249262
250263 public Long getCtrlCrsOfferingId() {
251264 return ctrlCrsOfferingId;
349349 * @param resv
350350 * @param isOwner
351351 */
352 public void addToCourseOfferings(CourseOffering co, Boolean isOwner) {
352 public void addToCourseOfferings(CourseOffering co, Boolean isOwner, Boolean canDelete) {
353353 this.courseOfferingIds.add(co.getUniqueId().toString());
354354 this.courseOfferingNames.add((co.getCourseNameWithTitle()));
355355 this.ownedCourse.add(isOwner);
358358 this.requested.add("");
359359 this.projected.add(co.getProjectedDemand() == null ? "" : co.getProjectedDemand().toString());
360360 this.lastTerm.add(co.getDemand() == null ? "" : co.getDemand().toString());
361 this.canDelete.add(canDelete);
361362 }
362363
363364 /**
379379 this.requested.remove(ct);
380380 this.projected.remove(ct);
381381 this.lastTerm.remove(ct);
382 this.canDelete.remove(ct);
382383 break;
383384 }
384385 ++ct;
JavaSource/org/unitime/timetable/security/permissions/CoursePermissions.java
(31 / 0)
  
462462
463463 }
464464
465 @PermissionForRight(Right.CourseOfferingDeleteFromCrossList)
466 public static class CourseOfferingDeleteFromCrossList implements Permission<CourseOffering> {
467 @Autowired PermissionDepartment permissionDepartment;
468 @Autowired Permission<InstructionalOffering> permissionOfferingLockNeeded;
469
470 @Override
471 public boolean check(UserContext user, CourseOffering source) {
472 if (!user.getCurrentAuthority().hasRight(Right.ClassDeleteNoEnrollmentCheck)) {
473 // There is a committed solution -> course with enrollment cannot be edited
474 if (source.getDepartment() != null && source.getDepartment().getSolverGroup() != null && source.getDepartment().getSolverGroup().getCommittedSolution() != null) {
475 if (source.getEnrollment() > 0) return false;
476 }
477 }
478
479 if (permissionDepartment.check(user, source.getDepartment(), DepartmentStatusType.Status.OwnerEdit)) return true;
480
481 return false;
482 }
483
484 @Override
485 public Class<CourseOffering> type() { return CourseOffering.class; }
486
487 }
488
465489 @PermissionForRight(Right.MultipleClassSetupDepartment)
466490 public static class MultipleClassSetupDepartment extends InstrOfferingConfigEditDepartment {}
467491
517517
518518 @Override
519519 public boolean check(UserContext user, InstructionalOffering source) {
520 if (!user.getCurrentAuthority().hasRight(Right.ClassDeleteNoEnrollmentCheck)) {
521 // There is a committed solution -> course with enrollment cannot be edited
522 if (source.getDepartment() != null && source.getDepartment().getSolverGroup() != null && source.getDepartment().getSolverGroup().getCommittedSolution() != null) {
523 if (source.getEnrollment() > 0) return false;
524 }
525 }
526
520527 if (permissionOfferingLockNeeded.check(user, source)) return false;
521528
522529 if (source.isNotOffered()) return false;
JavaSource/org/unitime/timetable/security/rights/Right.java
(1 / 0)
  
112112 OfferingDelete(InstructionalOffering.class),
113113
114114 InstructionalOfferingCrossLists(InstructionalOffering.class),
115 CourseOfferingDeleteFromCrossList(CourseOffering.class),
115116
116117 InstrOfferingConfigAdd(InstructionalOffering.class),
117118 InstrOfferingConfigEdit(InstrOfferingConfig.class),
WebContent/help/Release-Notes.xml
(5 / 0)
  
8181 <line>Class Cancel: ability to cancel a class (there must be a committed solution)</line>
8282 <line>The Class Delete and Class Cancel permissions are by default given to all roles that have Multiple Class Setup Class and / or Class Edit permissions.</line>
8383 </line>
84 <line>Added a new permission (named Class Delete No Enrollment Check) that overrides the enrollment check from the Class Delete permission.
85 <line>No role is given this permission by default.</line>
86 </line>
87 <line>Make Not-Offered: It is allowed to make an offering not-offered only when there are no students enrolled, there is no committed solution, or the user has the Class Delete No Enrollment Check permission.</line>
88 <line>Cross Lists: it is allowed to remove a cross-listed course from an offering only when there are no students enrolled, there is no committed solution, or the user has the Class Delete No Enrollment Check permission.</line>
8489 </description>
8590 </item>
8691 <item>
WebContent/user/crossListsModify.jsp
(8 / 5)
  
204204 <TD align="right" class="WebTableHeader"><!-- I> Requested </I --></TD>
205205 <TD align="right" class="WebTableHeader"> <loc:message name="columnCrossListsProjected"/></TD>
206206 <TD align="right" class="WebTableHeader"> <loc:message name="columnCrossListsLastTerm"/></TD>
207 <TD>&nbsp;</TD>
207 <TD class="WebTableHeader">&nbsp;</TD>
208208 </TR>
209209
210210 <logic:iterate name="crossListsModifyForm" property="courseOfferingIds" id="co" indexId="ctr">
213213 <html:hidden property='<%= "courseOfferingIds[" + ctr + "]" %>'/>
214214 <html:hidden property='<%= "courseOfferingNames[" + ctr + "]" %>'/>
215215 <html:hidden property='<%= "ownedCourse[" + ctr + "]" %>'/>
216 <html:hidden property='<%= "canDelete[" + ctr + "]" %>'/>
216217 <bean:write name="crossListsModifyForm" property='<%= "courseOfferingNames[" + ctr + "]" %>'/> &nbsp;
217218 </TD>
218219 <TD align="center" class="BottomBorderGray">
273273 <TD align="center" nowrap class="BottomBorderGray">
274274 &nbsp;
275275 <logic:notEqual name="crossListsModifyForm" property="readOnlyCrsOfferingId" value="<%= co.toString() %>" >
276 <IMG border="0" src="images/action_delete.png" title="<%=MSG.titleRemoveCourseFromCrossList() %>"
277 onMouseOver="this.style.cursor='hand';this.style.cursor='pointer';"
278 onClick="document.forms[0].elements['hdnOp'].value='delete';document.forms[0].elements['deletedCourseOfferingId'].value='<%= co.toString() %>';document.forms[0].submit();">
276 <logic:equal name="crossListsModifyForm" property='<%= "canDelete[" + ctr + "]" %>' value="true" >
277 <IMG border="0" src="images/action_delete.png" title="<%=MSG.titleRemoveCourseFromCrossList() %>"
278 onMouseOver="this.style.cursor='hand';this.style.cursor='pointer';"
279 onClick="document.forms[0].elements['hdnOp'].value='delete';document.forms[0].elements['deletedCourseOfferingId'].value='<%= co.toString() %>';document.forms[0].submit();">
280 </logic:equal>
279281 </logic:notEqual>
280282 &nbsp;
281283 </TD>
292292 <TD align="right" class='rowTotal'>&nbsp;<!-- I> Requested </I --></TD>
293293 <TD class='rowTotal' align='right'><%= projTotal>=0 ? projTotal : "" %>&nbsp; </TD>
294294 <TD class='rowTotal' align='right'><%= lastTermTotal>=0 ? lastTermTotal : "" %>&nbsp; </TD>
295 <TD>&nbsp;</TD>
295 <TD class='rowTotal'>&nbsp;</TD>
296296 </TR>
297297 <% } %>
298298