Skip to content

Commit

Permalink
use organizatioid
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaetanbrl committed Dec 31, 2024
1 parent 441b463 commit ef3f926
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 9 deletions.
3 changes: 3 additions & 0 deletions console/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ public Org getOrgInfos(@PathVariable String cn) {
return this.orgDao.findByCommonName(cn);
}

/**
* Retreive full information about one org as JSON document from unique
* organization id number (e.g french SIRET number). Following keys will be
* available :
*
* * 'id' (not used) * 'name' * 'shortName' * 'cities' as json array ex:
* [654,865498,98364,9834534,984984,6978984,98498] * 'status' * 'orgType' *
* 'address' * 'members' as json array ex: ["testadmin", "testuser"]
*
*/
@RequestMapping(value = REQUEST_MAPPING
+ "/uoi/{uniqueOrganizationId:.+}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
@ResponseBody
public Org getOrgInfosFromUniqueOrgId(@PathVariable String uniqOrgId) {
Org orgInfos = this.orgDao.findByUniqueOrganizationId(uniqOrgId);
this.checkOrgAuthorization(orgInfos.getId());
return orgInfos;
}

/**
* Update information of one org
*
Expand Down Expand Up @@ -482,6 +501,7 @@ protected void updateFromRequest(Org org, JSONObject json) throws IOException {
org.setUrl(json.optString(Org.JSON_URL));
org.setLogo(json.optString(Org.JSON_LOGO));
org.setMail(json.optString(Org.JSON_MAIL));
org.setUniqueOrganizationId(json.optString(Org.JSON_UNIQUE_ORGANIZATION_ID));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
public class EditOrgDetailsFormController {
private OrgsDao orgsDao;
private Validation validation;
private static final String[] FIELDS = { "id", "url", "description", "logo", "name", "address", "mail" };
private static final String[] FIELDS = { "id", "url", "description", "logo", "name", "address", "mail",
"uniqueOrganizationId" };

private static final Log LOG = LogFactory.getLog(EditOrgDetailsFormController.class.getName());

Expand Down Expand Up @@ -94,6 +95,7 @@ public String setupForm(HttpServletRequest request, Model model) {
model.addAttribute("id", org.getId());
model.addAttribute("logo", org.getLogo());
model.addAttribute("mail", org.getMail());
model.addAttribute("uniqueOrganizationId", org.getUniqueOrganizationId());
HttpSession session = request.getSession();
for (String f : FIELDS) {
if (validation.isOrgFieldRequired(f)) {
Expand Down Expand Up @@ -156,6 +158,7 @@ private EditOrgDetailsFormBean createForm(Org org) {
formBean.setAddress(org.getAddress());
formBean.setOrgType(org.getOrgType());
formBean.setMail(org.getMail());
formBean.setUniqueOrganizationId(org.getUniqueOrganizationId());
return formBean;
}

Expand Down Expand Up @@ -194,6 +197,12 @@ protected void logOrgDetailsChanges(Org org, EditOrgDetailsFormBean formBean, Mu
if (StringUtils.isNotEmpty(org.getMail()) && !org.getMail().equals(formBean.getMail())) {
logUtils.createAndLogDetails(id, Org.JSON_MAIL, org.getMail(), formBean.getMail(), type);
}

if (StringUtils.isNotEmpty(org.getUniqueOrganizationId())
&& !org.getUniqueOrganizationId().equals(formBean.getUniqueOrganizationId())) {
logUtils.createAndLogDetails(id, Org.JSON_UNIQUE_ORGANIZATION_ID, org.getUniqueOrganizationId(),
formBean.getUniqueOrganizationId(), type);
}
}

}
3 changes: 3 additions & 0 deletions console/src/main/webapp/WEB-INF/views/editOrgDetailsForm.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<t:input path="mail" required="${mailRequired}">
<jsp:attribute name="label"><s:message code="mail.label"/></jsp:attribute>
</t:input>
<t:input path="uniqueOrganizationId" required="${uniqueOrganizationIdRequired}">
<jsp:attribute name="uniqueOrganizationId"><s:message code="uniqueOrganizationId.label"/></jsp:attribute>
</t:input>
<div class="form-group">
<label for="logo" class="control-label col-lg-4"><s:message
code="logo.label"/></label>
Expand Down
2 changes: 2 additions & 0 deletions console/src/main/webapp/manager/app/components/org/org.es6
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OrgController {
this.org = $injector.get('Orgs').get({
id: $routeParams.org
}, () => this.loadUsers())
console.log(this.org)
this.required = $injector.get('OrgsRequired').query()
this.orgTypeValues = $injector.get('OrgsType').query()

Expand All @@ -55,6 +56,7 @@ class OrgController {
save () {
const flash = this.$injector.get('Flash')
const $httpDefaultCache = this.$injector.get('$cacheFactory').get('$http')
console.log(this.org)
this.org.$update(() => {
$httpDefaultCache.removeAll()
flash.create('success', this.i18n.updated)
Expand Down
2 changes: 2 additions & 0 deletions console/src/main/webapp/manager/app/components/orgs/orgs.es6
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class OrgsController {
org.membersCount = org.members.length
delete org.members
})
console.log(this.orgs)
this.simplifiedOrgs = this.orgs.map((org) => {
return { id: org.id, name: org.name, shortName: org.shortName, membersCount: org.membersCount, pending: org.pending, status: org.status, uniqueOrganizationId: org.uniqueOrganizationId }
})
Expand Down Expand Up @@ -57,6 +58,7 @@ class OrgsController {
const $router = this.$injector.get('$router')
const $location = this.$injector.get('$location')
const $httpDefaultCache = this.$injector.get('$cacheFactory').get('$http')
console.log(this.newInstance)

this.newInstance.$save(
() => {
Expand Down
6 changes: 6 additions & 0 deletions console/src/main/webapp/manager/brunch-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module.exports = {
config: {
// Changer le port par défaut ici
server: {
port: 4000, // Changer 4000 par le port de votre choix
path: 'http://localhost:4000',
run: true
},
plugins: {
ng_templates: {
module: 'manager',
Expand Down
14 changes: 7 additions & 7 deletions console/src/main/webapp/manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class OrgsIT extends ConsoleIntegrationTest {
support.perform(get("/private/orgs/" + orgName.replace(" ", "_")))
.andExpect(jsonPath("$.id").value(orgName.replace(" ", "_").toLowerCase()))
.andExpect(jsonPath("$.shortName").value(orgName.toLowerCase()))
.andExpect(jsonPath("$.uniqueOrganizationId").value("80908401500035"))
.andExpect(jsonPath("$.name").value("camptocamp")).andExpect(jsonPath("$.cities").isEmpty())
.andExpect(jsonPath("$.members").isEmpty()).andExpect(jsonPath("$.address").value("1, rue du pont"))
.andExpect(jsonPath("$.orgType").value("Company")).andExpect(jsonPath("$.pending").value(false));
Expand Down
3 changes: 2 additions & 1 deletion console/src/test/resources/testData/createOrgPayload.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"address": "1, rue du pont",
"name": "camptocamp",
"orgType": "Company",
"shortName": "{shortName}"
"shortName": "{shortName}",
"uniqueOrganizationid": "80908401500035"
}

0 comments on commit ef3f926

Please sign in to comment.