... |
... |
@@ -1,7 +1,4 @@ |
1 |
1 |
{{groovy}} |
2 |
|
- if(!hasAdmin){ |
3 |
|
- |
4 |
|
- } |
5 |
5 |
// Nom de l'image en pièce jointe |
6 |
6 |
def attachmentName = 'NGIZero_logo.png' |
7 |
7 |
|
... |
... |
@@ -8,28 +8,6 @@ |
8 |
8 |
// Récupérer l'image en pièce jointe |
9 |
9 |
def img = doc.getAttachment(attachmentName) |
10 |
10 |
|
11 |
|
-// Accéder à l'objet et à la propriété 'count' |
12 |
|
-def obj = doc.getObject(doc.toString()) |
13 |
|
-def countProperty = obj.getProperty('count') |
14 |
|
-def countValue = countProperty.value |
15 |
|
- |
16 |
|
-// Initialiser un compteur pour la date du jour |
17 |
|
-def currentDate = new Date().format('yyyy-MM-dd') |
18 |
|
-def jsonSlurper = new groovy.json.JsonSlurper() |
19 |
|
-def json = countValue ? jsonSlurper.parseText(countValue) : [:] |
20 |
|
- |
21 |
|
-// Incrémenter le compteur pour la date actuelle |
22 |
|
-if (json.containsKey(currentDate)) { |
23 |
|
- json[currentDate] += 1 |
24 |
|
-} else { |
25 |
|
- json[currentDate] = 1 |
26 |
|
-} |
27 |
|
- |
28 |
|
-// Mettre à jour la propriété 'count' avec le nouveau JSON |
29 |
|
-def jsonOutput = new groovy.json.JsonBuilder(json).toPrettyString() |
30 |
|
-obj.set('count',jsonOutput) |
31 |
|
-doc.save() |
32 |
|
- |
33 |
33 |
if (img != null) { |
34 |
34 |
def outs = response.outputStream |
35 |
35 |
response.setContentType("image/png") |
... |
... |
@@ -43,6 +43,5 @@ |
43 |
43 |
} else { |
44 |
44 |
response.sendError(404, "L'image n'existe pas.") |
45 |
45 |
} |
46 |
|
- |
47 |
47 |
{{/groovy}} |
48 |
48 |
|