Ticket #804: openmrs-804.patch
| File openmrs-804.patch, 10.6 kB (added by bwolfe, 2 months ago) |
|---|
-
/home/ben/workspace/openmrs-trunk/metadata/api/hibernate/org/openmrs/api/db/hibernate/PersonAttributeType.hbm.xml
old new 45 45 column="retire_reason" length="255" /> 46 46 <property name="retired" type="boolean" column="retired" 47 47 length="1" not-null="true" /> 48 48 49 <property name="editPrivilege" type="java.lang.String" column="edit_privilege" 50 length="50" /> 49 51 </class> 50 52 51 53 </hibernate-mapping> -
/home/ben/workspace/openmrs-trunk/metadata/model/update-to-latest-db.mysqldiff.sql
old new 1213 1213 call diff_procedure('1.4.0.02'); 1214 1214 1215 1215 1216 #---------------------------------------- 1217 # OpenMRS Datamodel version 1.4.0.03 1218 # Upul Godage July 4, 2008 1219 # Adding edit_privilege column to PersonAttributeType 1220 #---------------------------------------- 1221 1222 DROP PROCEDURE IF EXISTS diff_procedure; 1223 1224 delimiter // 1225 1226 CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10)) 1227 BEGIN 1228 IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN 1229 SELECT CONCAT('Updating to ', new_db_version) AS 'Datamodel Update:' FROM dual; 1230 1231 ALTER TABLE `person_attribute_type` ADD COLUMN `edit_privilege` varchar(255) default NULL; 1232 1233 ALTER TABLE `person_attribute_type` ADD CONSTRAINT `privilege_which_can_edit` FOREIGN KEY (`edit_privilege`) REFERENCES `privilege` (`privilege`); 1234 1235 UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 1236 1237 END IF; 1238 END; 1239 // 1240 1241 delimiter ; 1242 call diff_procedure('1.4.0.03'); 1243 1216 1244 #----------------------------------- 1217 1245 # Clean up - Keep this section at the very bottom of diff script 1218 1246 #----------------------------------- -
/home/ben/workspace/openmrs-trunk/src/api/org/openmrs/PersonAttributeType.java
old new 46 46 private Date dateRetired; 47 47 private String retireReason; 48 48 49 private String editPrivilege; 50 49 51 /** default constructor */ 50 52 public PersonAttributeType() {} 51 53 … … 308 310 public String toString() { 309 311 return this.name; 310 312 } 313 314 public String getEditPrivilege() { 315 return editPrivilege; 316 } 317 318 public void setEditPrivilege(String editPrivilege) { 319 if("".equals(editPrivilege)) { 320 this.editPrivilege = null; 321 } else { 322 this.editPrivilege = editPrivilege; 323 } 324 } 311 325 312 326 } -
/home/ben/workspace/openmrs-trunk/src/web/org/openmrs/web/controller/person/PersonAttributeTypeFormController.java
old new 13 13 */ 14 14 package org.openmrs.web.controller.person; 15 15 16 import java.util.ArrayList; 17 import java.util.HashMap; 18 import java.util.List; 19 import java.util.Map; 20 16 21 import javax.servlet.ServletException; 17 22 import javax.servlet.http.HttpServletRequest; 18 23 import javax.servlet.http.HttpServletResponse; … … 21 26 import org.apache.commons.logging.Log; 22 27 import org.apache.commons.logging.LogFactory; 23 28 import org.openmrs.PersonAttributeType; 29 import org.openmrs.Privilege; 24 30 import org.openmrs.api.PersonService; 25 31 import org.openmrs.api.context.Context; 26 32 import org.openmrs.web.WebConstants; … … 26 32 import org.openmrs.web.WebConstants; 27 33 import org.springframework.beans.propertyeditors.CustomNumberEditor; 28 34 import org.springframework.validation.BindException; 35 import org.springframework.validation.Errors; 29 36 import org.springframework.web.bind.ServletRequestDataBinder; 30 37 import org.springframework.web.servlet.ModelAndView; 31 38 import org.springframework.web.servlet.mvc.SimpleFormController; … … 97 104 return attrType; 98 105 } 99 106 107 protected Map referenceData(HttpServletRequest request, Object obj, 108 Errors errors) throws Exception { 109 110 Map<String, Object> map = new HashMap<String, Object>(); 111 112 List<Privilege> privileges = new ArrayList<Privilege>(); 113 114 if (Context.isAuthenticated()) { 115 privileges = Context.getUserService().getAllPrivileges(); 116 } 117 118 map.put("privileges", privileges); 119 120 return map; 121 } 100 122 } -
/home/ben/workspace/openmrs-trunk/web/WEB-INF/messages.properties
old new 1150 1150 PersonAttributeType.user.listing.help=Attributes shown when users are displayed in a list 1151 1151 PersonAttributeType.user.viewing=User Viewing Attributes 1152 1152 PersonAttributeType.user.viewing.help=Attributes shown when viewing a user's metadata 1153 1154 1153 PersonAttributeType.editPrivilege=Edit privilege 1154 PersonAttributeType.editPrivilege.help=The privilege needed by a user to edit this person attribute 1155 1155 1156 1156 PersonAttributeType.Mother'sName=Mother's Name 1157 1157 PersonAttributeType.HealthCenter=Health Center -
/home/ben/workspace/openmrs-trunk/web/WEB-INF/view/admin/person/include/editPersonInfo.jsp
old new 166 166 </td> 167 167 </tr> 168 168 </c:if> 169 169 170 <openmrs:forEachDisplayAttributeType personType="" displayType="all" var="attrType"> 170 <tr> 171 <td><spring:message code="PersonAttributeType.${fn:replace(attrType.name, ' ', '')}" text="${attrType.name}"/></td> 172 <td> 173 <spring:bind path="attributeMap"> 174 <openmrs:fieldGen 175 type="${attrType.format}" 176 formFieldName="${attrType.personAttributeTypeId}" 177 val="${status.value[attrType.name].hydratedObject}" 178 parameters="optionHeader=[blank]|showAnswers=${attrType.foreignKey}" /> 179 </spring:bind> 180 </td> 181 </tr> 171 <c:set var="authorized" value="false" /> 172 <c:choose> 173 <c:when test="${not empty attrType.editPrivilege}"> 174 <openmrs:hasPrivilege privilege="${attrType.editPrivilege}"> 175 <c:set var="authorized" value="true" /> 176 </openmrs:hasPrivilege> 177 </c:when> 178 179 <c:otherwise> 180 <c:set var="authorized" value="true" /> 181 </c:otherwise> 182 </c:choose> 183 184 <c:choose> 185 <c:when test="${authorized == true}"> 186 <tr> 187 <td><spring:message code="PersonAttributeType.${fn:replace(attrType.name, ' ', '')}" text="${attrType.name}"/></td> 188 <td> 189 <spring:bind path="attributeMap"> 190 <openmrs:fieldGen 191 type="${attrType.format}" 192 formFieldName="${attrType.personAttributeTypeId}" 193 val="${status.value[attrType.name].hydratedObject}" 194 parameters="optionHeader=[blank]|showAnswers=${attrType.foreignKey}" /> 195 </spring:bind> 196 </td> 197 </tr> 198 </c:when> 199 200 <c:otherwise> 201 <td><spring:message code="PersonAttributeType.${fn:replace(attrType.name, ' ', '')}" text="${attrType.name}"/></td> 202 <td><spring:bind path="attributeMap">${status.value[attrType.name].hydratedObject}</spring:bind></td> 203 </c:otherwise> 204 </c:choose> 205 182 206 </openmrs:forEachDisplayAttributeType> 207 183 208 <tr> 184 209 <td><spring:message code="Person.dead"/></td> 185 210 <td> -
/home/ben/workspace/openmrs-trunk/web/WEB-INF/view/admin/person/personAttributeTypeForm.jsp
old new 60 60 </spring:bind> 61 61 </td> 62 62 </tr> 63 <tr> 64 <td><spring:message code="PersonAttributeType.editPrivilege"/></td> 65 <td> 66 <spring:bind path="personAttributeType.editPrivilege"> 67 <select name="editPrivilege"> 68 <option value=""></option> 69 <c:forEach items="${privileges}" var="privilege"> 70 <option value="${privilege.privilege}" <c:if test="${privilege.privilege == status.value}">selected</c:if>>${privilege.privilege}</option> 71 </c:forEach> 72 </select> 73 <c:if test="${status.errorMessage != ''}"><span class="error">${status.errorMessage}</span></c:if> 74 </spring:bind> 75 </td> 76 <td><i><spring:message code="PersonAttributeType.editPrivilege.help"/></i></td> 77 </tr> 63 78 <c:if test="${personAttributeType.creator != null}"> 64 79 <tr> 65 80 <td><spring:message code="general.createdBy" /></td> -
/home/ben/workspace/openmrs-trunk/web/WEB-INF/view/admin/person/personAttributeTypeList.jsp
old new 20 20 <th> <spring:message code="PersonAttributeType.format"/> </th> 21 21 <th> <spring:message code="PersonAttributeType.searchable"/> </th> 22 22 <th> <spring:message code="general.description"/> </th> 23 <th> <spring:message code="PersonAttributeType.editPrivilege"/> </th> 23 24 </tr> 24 25 <c:forEach var="personAttributeType" items="${personAttributeTypeList}"> 25 26 <tr> … … 31 32 <td valign="top">${personAttributeType.format}</td> 32 33 <td valign="top"><c:if test="${personAttributeType.searchable == true}"><spring:message code="general.yes"/></c:if></td> 33 34 <td valign="top">${personAttributeType.description}</td> 35 <td valign="top">${personAttributeType.editPrivilege}</td> 34 36 </tr> 35 37 </c:forEach> 36 38 </table>
Download in other formats:
Powered by Trac 0.10.5
By Edgewall Software.
Visit the Trac open source project at
http://trac.edgewall.com/