">+ 353
+#: recycle_core/models.py
354
+msgid "Invoicing & Payouts"
355
+msgstr "請求と支払い"
356
+
357
+#: recycle_core/models.py
358
+msgid "Reporting & Analytics"
359
+msgstr "レポートと分析"
360
+
361
+#: recycle_core/models.py
362
+msgid "Marketplace & Bidding"
363
+msgstr "マーケットプレイスと入札"
364
+
365
+#: recycle_core/models.py
366
+msgid "Compliance & Audits"
367
+msgstr "コンプライアンスと監査"
368
+
369
+#: recycle_core/models.py
370
+msgid "Consulting & Training"
371
+msgstr "コンサルティングとトレーニング"

二进制
locale/th/LC_MESSAGES/django.mo


+ 370 - 0
locale/th/LC_MESSAGES/django.po

@@ -0,0 +1,370 @@
1
+# SOME DESCRIPTIVE TITLE.
2
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+# This file is distributed under the same license as the PACKAGE package.
4
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+#
6
+msgid ""
7
+msgstr ""
8
+"Project-Id-Version: PACKAGE VERSION\n"
9
+"Report-Msgid-Bugs-To: \n"
10
+"POT-Creation-Date: 2025-09-25 22:51+0700\n"
11
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+"Language-Team: LANGUAGE <LL@li.org>\n"
14
+"Language: th\n"
15
+"MIME-Version: 1.0\n"
16
+"Content-Type: text/plain; charset=UTF-8\n"
17
+"Content-Transfer-Encoding: 8bit\n"
18
+"Plural-Forms: nplurals=1; plural=0;\n"
19
+
20
+#: admin_frontend/templates/admin_frontend/base.html:76
21
+#: translations/menu_labels.py:12
22
+msgid "Settings"
23
+msgstr "การตั้งค่า"
24
+
25
+#: admin_frontend/templates/admin_frontend/base.html:96
26
+msgid "CMS"
27
+msgstr "CMS"
28
+
29
+#: admin_frontend/templates/admin_frontend/base.html:117
30
+msgid "Frontend"
31
+msgstr "ส่วนหน้า"
32
+
33
+#: admin_frontend/templates/admin_frontend/base.html:137
34
+msgid "Organization"
35
+msgstr "องค์กร"
36
+
37
+#: admin_frontend/templates/admin_frontend/base.html:157
38
+msgid "Billing"
39
+msgstr "การเรียกเก็บเงิน"
40
+
41
+#: admin_frontend/templates/admin_frontend/base.html:177
42
+msgid "Recycle Ops"
43
+msgstr "การดำเนินงานรีไซเคิล"
44
+
45
+#: public_frontend/templates/public_frontend/base.html:17
46
+#: public_frontend/templates/public_frontend/materials_list.html:3
47
+#: translations/menu_labels.py:18
48
+msgid "Materials"
49
+msgstr "วัสดุ"
50
+
51
+#: public_frontend/templates/public_frontend/base.html:18
52
+#: public_frontend/templates/public_frontend/listings_list.html:3
53
+msgid "Listings"
54
+msgstr "รายการ"
55
+
56
+#: public_frontend/templates/public_frontend/base.html:19
57
+#: public_frontend/templates/public_frontend/pickup_request.html:3
58
+msgid "Request Pickup"
59
+msgstr "ขอรับของ"
60
+
61
+#: public_frontend/templates/public_frontend/base.html:20
62
+#: public_frontend/templates/public_frontend/blog_list.html:3
63
+msgid "Blog"
64
+msgstr "บล็อก"
65
+
66
+#: public_frontend/templates/public_frontend/base.html:21
67
+#: public_frontend/templates/public_frontend/contact.html:3
68
+msgid "Contact"
69
+msgstr "ติดต่อเรา"
70
+
71
+#: public_frontend/templates/public_frontend/base.html:53
72
+msgid "Staff Login"
73
+msgstr "เข้าสู่ระบบเจ้าหน้าที่"
74
+
75
+#: public_frontend/templates/public_frontend/blog_list.html:14
76
+msgid "No image"
77
+msgstr "ไม่มีรูปภาพ"
78
+
79
+#: public_frontend/templates/public_frontend/blog_list.html:24
80
+#: public_frontend/templates/public_frontend/home.html:92
81
+msgid "No posts yet."
82
+msgstr "ยังไม่มีโพสต์"
83
+
84
+#: public_frontend/templates/public_frontend/contact.html:5
85
+#: public_frontend/templates/public_frontend/home.html:99
86
+msgid "Contact Us"
87
+msgstr "ติดต่อเรา"
88
+
89
+#: public_frontend/templates/public_frontend/contact.html:10
90
+#: public_frontend/templates/public_frontend/home.html:104
91
+#: public_frontend/templates/public_frontend/materials_list.html:9
92
+#: public_frontend/templates/public_frontend/pickup_request.html:38
93
+msgid "Name"
94
+msgstr "ชื่อ"
95
+
96
+#: public_frontend/templates/public_frontend/contact.html:14
97
+#: public_frontend/templates/public_frontend/home.html:108
98
+#: public_frontend/templates/public_frontend/pickup_request.html:40
99
+msgid "Email"
100
+msgstr "อีเมล"
101
+
102
+#: public_frontend/templates/public_frontend/contact.html:20
103
+#: public_frontend/templates/public_frontend/pickup_request.html:41
104
+msgid "Phone"
105
+msgstr "โทรศัพท์"
106
+
107
+#: public_frontend/templates/public_frontend/contact.html:24
108
+#: public_frontend/templates/public_frontend/home.html:113
109
+msgid "Subject"
110
+msgstr "หัวข้อ"
111
+
112
+#: public_frontend/templates/public_frontend/contact.html:29
113
+#: public_frontend/templates/public_frontend/home.html:117
114
+msgid "Message"
115
+msgstr "ข้อความ"
116
+
117
+#: public_frontend/templates/public_frontend/contact.html:33
118
+msgid "Send"
119
+msgstr "ส่ง"
120
+
121
+#: public_frontend/templates/public_frontend/home.html:3
122
+msgid "Home"
123
+msgstr "หน้าแรก"
124
+
125
+#: public_frontend/templates/public_frontend/home.html:9
126
+msgid "Streamline Your Factory's Recycling"
127
+msgstr "ปรับปรุงการรีไซเคิลของโรงงานให้มีประสิทธิภาพ"
128
+
129
+#: public_frontend/templates/public_frontend/home.html:10
130
+msgid ""
131
+"We partner with businesses like yours to manage scrap materials efficiently. "
132
+"Browse listings, request a pickup, and turn your waste into a resource."
133
+msgstr "เราร่วมมือกับธุรกิจเช่นคุณเพื่อจัดการเศษวัสดุอย่างมีประสิทธิภาพ เรียกดูรายการ ขอรับของ และเปลี่ยนของเสียให้เป็นทรัพยากร"
134
+
135
+#: public_frontend/templates/public_frontend/home.html:12
136
+#: public_frontend/templates/public_frontend/pickup_request.html:6
137
+msgid "Request a Pickup"
138
+msgstr "ขอรับของ"
139
+
140
+#: public_frontend/templates/public_frontend/home.html:13
141
+msgid "Browse Listings"
142
+msgstr "ดูรายการ"
143
+
144
+#: public_frontend/templates/public_frontend/home.html:21
145
+msgid "Our Services"
146
+msgstr "บริการของเรา"
147
+
148
+#: public_frontend/templates/public_frontend/home.html:40
149
+msgid "Materials We Accept"
150
+msgstr "วัสดุที่รับ"
151
+
152
+#: public_frontend/templates/public_frontend/home.html:41
153
+#: public_frontend/templates/public_frontend/home.html:82
154
+msgid "View all"
155
+msgstr "ดูทั้งหมด"
156
+
157
+#: public_frontend/templates/public_frontend/home.html:51
158
+#: public_frontend/templates/public_frontend/materials_list.html:22
159
+msgid "No materials published."
160
+msgstr "ยังไม่มีวัสดุเผยแพร่"
161
+
162
+#: public_frontend/templates/public_frontend/home.html:60
163
+msgid "Open Listings"
164
+msgstr "รายการที่เปิดอยู่"
165
+
166
+#: public_frontend/templates/public_frontend/home.html:61
167
+msgid "Browse all"
168
+msgstr "ดูทั้งหมด"
169
+
170
+#: public_frontend/templates/public_frontend/home.html:66
171
+#: public_frontend/templates/public_frontend/listing_detail.html:7
172
+#: public_frontend/templates/public_frontend/listings_list.html:8
173
+msgid "Ends"
174
+msgstr "สิ้นสุด"
175
+
176
+#: public_frontend/templates/public_frontend/home.html:71
177
+msgid "No public listings at the moment."
178
+msgstr "ขณะนี้ยังไม่มีรายการสาธารณะ"
179
+
180
+#: public_frontend/templates/public_frontend/home.html:81
181
+msgid "Industry Insights"
182
+msgstr "ข้อมูลเชิงลึกอุตสาหกรรม"
183
+
184
+#: public_frontend/templates/public_frontend/home.html:121
185
+msgid "Send Message"
186
+msgstr "ส่งข้อความ"
187
+
188
+#: public_frontend/templates/public_frontend/listing_detail.html:3
189
+msgid "Listing"
190
+msgstr "รายการ"
191
+
192
+#: public_frontend/templates/public_frontend/listing_detail.html:7
193
+msgid "Status"
194
+msgstr "สถานะ"
195
+
196
+#: public_frontend/templates/public_frontend/listing_detail.html:9
197
+msgid "Items"
198
+msgstr "รายการ"
199
+
200
+#: public_frontend/templates/public_frontend/listing_detail.html:14
201
+msgid "No items listed"
202
+msgstr "ยังไม่มีรายการ"
203
+
204
+#: public_frontend/templates/public_frontend/listings_list.html:13
205
+msgid "No public listings."
206
+msgstr "ยังไม่มีรายการสาธารณะ"
207
+
208
+#: public_frontend/templates/public_frontend/materials_list.html:10
209
+msgid "Category"
210
+msgstr "หมวดหมู่"
211
+
212
+#: public_frontend/templates/public_frontend/materials_list.html:11
213
+msgid "Default Unit"
214
+msgstr "หน่วยเริ่มต้น"
215
+
216
+#: public_frontend/templates/public_frontend/pickup_request.html:36
217
+msgid "Review Your Pickup Request"
218
+msgstr "ตรวจสอบคำขอรับของของคุณ"
219
+
220
+#: public_frontend/templates/public_frontend/pickup_request.html:43
221
+msgid "Pickup Address"
222
+msgstr "ที่อยู่รับของ"
223
+
224
+#: public_frontend/templates/public_frontend/pickup_request.html:45
225
+msgid "Preferred Date/Time"
226
+msgstr "วันที่/เวลา ที่ต้องการ"
227
+
228
+#: public_frontend/templates/public_frontend/pickup_request.html:47
229
+msgid "Materials / Notes"
230
+msgstr "วัสดุ / หมายเหตุ"
231
+
232
+#: public_frontend/templates/public_frontend/pickup_request.html:49
233
+msgid "Photos"
234
+msgstr "รูปภาพ"
235
+
236
+#: public_frontend/templates/public_frontend/pickup_request.html:51
237
+msgid "No files attached."
238
+msgstr "ไม่มีไฟล์แนบ"
239
+
240
+#: public_frontend/templates/public_frontend/pickup_request.html:57
241
+msgid "Edit"
242
+msgstr "แก้ไข"
243
+
244
+#: public_frontend/templates/public_frontend/pickup_request.html:58
245
+msgid "Confirm & Send"
246
+msgstr "ยืนยันและส่ง"
247
+
248
+#: public_frontend/templates/public_frontend/pickup_request.html:62
249
+msgid "close"
250
+msgstr "ปิด"
251
+
252
+#: public_frontend/templates/public_frontend/service_detail.html:29
253
+msgid "Back to Home"
254
+msgstr "กลับสู่หน้าแรก"
255
+
256
+#: translations/menu_labels.py:4
257
+msgid "Dashboard"
258
+msgstr "แดชบอร์ด"
259
+
260
+#: translations/menu_labels.py:5
261
+msgid "Profiles"
262
+msgstr "โปรไฟล์"
263
+
264
+#: translations/menu_labels.py:6
265
+msgid "Opportunities"
266
+msgstr "โอกาส"
267
+
268
+#: translations/menu_labels.py:7
269
+msgid "Intro Requests"
270
+msgstr "คำขอแนะนำ"
271
+
272
+#: translations/menu_labels.py:8
273
+msgid "Leaderboard"
274
+msgstr "ตารางจัดอันดับ"
275
+
276
+#: translations/menu_labels.py:9
277
+msgid "Leads"
278
+msgstr "ลีด"
279
+
280
+#: translations/menu_labels.py:10
281
+msgid "CMS Posts"
282
+msgstr "โพสต์ CMS"
283
+
284
+#: translations/menu_labels.py:11
285
+msgid "CMS Categories"
286
+msgstr "หมวดหมู่ CMS"
287
+
288
+#: translations/menu_labels.py:13
289
+msgid "Advanced Settings"
290
+msgstr "การตั้งค่าขั้นสูง"
291
+
292
+#: translations/menu_labels.py:14
293
+msgid "Organization Settings"
294
+msgstr "การตั้งค่าองค์กร"
295
+
296
+#: translations/menu_labels.py:15
297
+msgid "Organization Sites"
298
+msgstr "ไซต์ขององค์กร"
299
+
300
+#: translations/menu_labels.py:16
301
+msgid "Permissions"
302
+msgstr "สิทธิ์การใช้งาน"
303
+
304
+#: translations/menu_labels.py:17
305
+msgid "Users"
306
+msgstr "ผู้ใช้"
307
+
308
+#: translations/menu_labels.py:19
309
+msgid "Customers"
310
+msgstr "ลูกค้า"
311
+
312
+#: translations/menu_labels.py:20
313
+msgid "Pickups"
314
+msgstr "การรับของ"
315
+
316
+#: translations/menu_labels.py:21
317
+msgid "Weigh Tickets"
318
+msgstr "ใบชั่งน้ำหนัก"
319
+
320
+#: translations/menu_labels.py:22
321
+msgid "Documents"
322
+msgstr "เอกสาร"
323
+
324
+#: translations/menu_labels.py:23
325
+msgid "Provided Services"
326
+msgstr "บริการที่ให้"
327
+
328
+#: translations/menu_labels.py:24
329
+msgid "Scrap Listings"
330
+msgstr "รายการเศษวัสดุ"
331
+
332
+#: translations/menu_labels.py:25
333
+msgid "Invoices"
334
+msgstr "ใบแจ้งหนี้"
335
+
336
+#: translations/menu_labels.py:26
337
+msgid "Payouts"
338
+msgstr "การจ่ายเงิน"
339
+
340
+#: recycle_core/models.py
341
+msgid "Pickup & Logistics"
342
+msgstr "การรับของและโลจิสติกส์"
343
+
344
+#: recycle_core/models.py
345
+msgid "Material Sorting"
346
+msgstr "การคัดแยกวัสดุ"
347
+
348
+#: recycle_core/models.py
349
+msgid "Weighing & Ticketing"
350
+msgstr "การชั่งน้ำหนักและออกบัตรชั่ง"
351
+
352
+#: recycle_core/models.py
353
+msgid "Invoicing & Payouts"
354
+msgstr "การวางบิลและการจ่ายเงิน"
355
+
356
+#: recycle_core/models.py
357
+msgid "Reporting & Analytics"
358
+msgstr "การรายงานและการวิเคราะห์"
359
+
360
+#: recycle_core/models.py
361
+msgid "Marketplace & Bidding"
362
+msgstr "มาร์เก็ตเพลสและการประมูล"
363
+
364
+#: recycle_core/models.py
365
+msgid "Compliance & Audits"
366
+msgstr "การปฏิบัติตามและการตรวจสอบ"
367
+
368
+#: recycle_core/models.py
369
+msgid "Consulting & Training"
370
+msgstr "ที่ปรึกษาและการฝึกอบรม"

+ 18 - 0
orgs/apps.py

@@ -14,4 +14,22 @@ class OrgsConfig(AppConfig):
14 14
         except Exception:
15 15
             # Avoid startup hard-fail if migrations/apps not ready; re-raise only in debug if needed
16 16
             raise
17
+
18
+        # Monkey-patch User.__str__ to show "<username>, <fullname>"
19
+        # This affects labels in forms and general stringification.
20
+        try:
21
+            from django.contrib.auth import get_user_model
22
+
23
+            User = get_user_model()
24
+
25
+            def _user_str(self):  # type: ignore[override]
26
+                full = self.get_full_name().strip()
27
+                return f"{self.username}, {full}" if full else f"{self.username}"
28
+
29
+            # Assign only if not already customized
30
+            if getattr(User.__str__, "__name__", None) != "_user_str":  # type: ignore[attr-defined]
31
+                User.__str__ = _user_str  # type: ignore[assignment]
32
+        except Exception:
33
+            # Do not block app startup if something goes wrong
34
+            pass
17 35
         return super().ready()

+ 2 - 1
orgs/views_admin.py

@@ -165,7 +165,8 @@ def permissions_edit_group(request, pk: int):
165 165
         final_ids = [pid for pid in sel_ids if pid in allowed_ids]
166 166
         group.permissions.set(Permission.objects.filter(id__in=final_ids))
167 167
         messages.success(request, f"Permissions updated for group '{group.name}'.")
168
-        return redirect("orgs_admin:permissions_overview")
168
+        # Redirect back to the current URL (stay on the edit page)
169
+        return redirect(request.get_full_path())
169 170
 
170 171
     current_ids = set(group.permissions.values_list("id", flat=True))
171 172
 

+ 22 - 8
public_frontend/templates/public_frontend/base.html

@@ -1,6 +1,7 @@
1
-{% load tailwind_tags static %}
1
+{% load tailwind_tags static i18n %}
2 2
 <!DOCTYPE html>
3
-<html lang="en">
3
+{% get_current_language as LANGUAGE_CODE %}
4
+<html lang="{{ LANGUAGE_CODE }}">
4 5
 <head>
5 6
   <meta charset="utf-8" />
6 7
   <meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -13,12 +14,25 @@
13 14
     <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 flex items-center justify-between h-16">
14 15
       <a href="/" class="text-lg font-semibold">{% if current_site %}{{ current_site.name }}{% else %}Ecoloop{% endif %}</a>
15 16
       <nav class="hidden md:flex items-center gap-6">
16
-        <a href="/#materials" class="hover:text-black/70">Materials</a>
17
-        <a href="/#listings" class="hover:text-black/70">Listings</a>
18
-        <a href="/#pickup-request" class="hover:text-black/70">Request Pickup</a>
19
-        <a href="/#blog" class="hover:text-black/70">Blog</a>
20
-        <a href="/#contact" class="hover:text-black/70">Contact</a>
17
+        <a href="/#materials" class="hover:text-black/70">{% trans "Materials" %}</a>
18
+        <a href="/#listings" class="hover:text-black/70">{% trans "Listings" %}</a>
19
+        <a href="/#pickup-request" class="hover:text-black/70">{% trans "Request Pickup" %}</a>
20
+        <a href="/#blog" class="hover:text-black/70">{% trans "Blog" %}</a>
21
+        <a href="/#contact" class="hover:text-black/70">{% trans "Contact" %}</a>
21 22
       </nav>
23
+      <form method="post" action="{% url 'set_language' %}" class="hidden md:block ml-4">
24
+        {% csrf_token %}
25
+        <input type="hidden" name="next" value="{{ request.get_full_path }}" />
26
+        {% get_available_languages as langs %}
27
+        {% get_language_info_list for langs as languages %}
28
+        <label for="lang" class="sr-only">Language</label>
29
+        <select id="lang" name="language" class="text-sm border border-gray-300 rounded px-2 py-1 bg-white"
30
+                onchange="this.form.submit()">
31
+          {% for lang in languages %}
32
+            <option value="{{ lang.code }}" {% if lang.code == LANGUAGE_CODE %}selected{% endif %}>{{ lang.name_local }}</option>
33
+          {% endfor %}
34
+        </select>
35
+      </form>
22 36
     </div>
23 37
   </header>
24 38
   <main class="mx-auto max-w-7xl p-4 sm:p-6 lg:p-8 min-h-[80vh]">
@@ -36,7 +50,7 @@
36 50
   <footer class="bg-white border-t">
37 51
     <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between text-sm text-gray-600">
38 52
       <span>&copy; {% now "Y" %} {% if current_site %}{{ current_site.name }}{% else %}Ecoloop{% endif %}</span>
39
-      <a href="/webadmin/" class="hover:underline">Staff Login</a>
53
+      <a href="/webadmin/" class="hover:underline">{% trans "Staff Login" %}</a>
40 54
     </div>
41 55
   </footer>
42 56
 </body>

+ 1 - 0
public_frontend/templates/public_frontend/blog_detail.html

@@ -1,4 +1,5 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
+{% load i18n %}
2 3
 {% block title %}{{ post.title }}{% endblock %}
3 4
 {% block content %}
4 5
 <article class="blog-article max-w-none bg-white rounded shadow p-6">

+ 4 - 3
public_frontend/templates/public_frontend/blog_list.html

@@ -1,5 +1,6 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Blog{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Blog" %}{% endblock %}
3 4
 {% block content %}
4 5
 <div class="grid gap-4">
5 6
   {% for p in posts %}
@@ -10,7 +11,7 @@
10 11
             <img src="{{ p.feature_image.url }}" alt="{{ p.title }}" loading="lazy">
11 12
           </div>
12 13
         {% else %}
13
-          <div class="thumb placeholder">No image</div>
14
+          <div class="thumb placeholder">{% trans "No image" %}</div>
14 15
         {% endif %}
15 16
         <div class="min-w-0">
16 17
           <div class="text-sm text-gray-500">{{ p.published_at|date:'M j, Y' }}</div>
@@ -20,7 +21,7 @@
20 21
       </div>
21 22
     </a>
22 23
   {% empty %}
23
-    <div class="text-gray-500">No posts yet.</div>
24
+    <div class="text-gray-500">{% trans "No posts yet." %}</div>
24 25
   {% endfor %}
25 26
   </div>
26 27
 <div class="mt-4">{% include 'admin_frontend/_pagination.html' %}</div>

+ 9 - 8
public_frontend/templates/public_frontend/contact.html

@@ -1,35 +1,36 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Contact{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Contact" %}{% endblock %}
3 4
 {% block content %}
4
-<h1 class="text-xl font-semibold mb-4">Contact Us{% if org %} — {{ org.name }}{% endif %}</h1>
5
+<h1 class="text-xl font-semibold mb-4">{% trans "Contact Us" %}{% if org %} — {{ org.name }}{% endif %}</h1>
5 6
 <form method="post" class="bg-white rounded shadow p-4 grid gap-4">
6 7
   {% csrf_token %}
7 8
   <div class="grid md:grid-cols-2 gap-4">
8 9
     <div>
9
-      <label class="block text-sm font-medium mb-1">Name</label>
10
+      <label class="block text-sm font-medium mb-1">{% trans "Name" %}</label>
10 11
       <input type="text" name="name" value="{{ form.name.value|default:'' }}" required class="w-full border rounded px-3 py-2">
11 12
     </div>
12 13
     <div>
13
-      <label class="block text-sm font-medium mb-1">Email</label>
14
+      <label class="block text-sm font-medium mb-1">{% trans "Email" %}</label>
14 15
       <input type="email" name="email" value="{{ form.email.value|default:'' }}" required class="w-full border rounded px-3 py-2">
15 16
     </div>
16 17
   </div>
17 18
   <div class="grid md:grid-cols-2 gap-4">
18 19
     <div>
19
-      <label class="block text-sm font-medium mb-1">Phone</label>
20
+      <label class="block text-sm font-medium mb-1">{% trans "Phone" %}</label>
20 21
       <input type="text" name="phone" value="{{ form.phone.value|default:'' }}" class="w-full border rounded px-3 py-2">
21 22
     </div>
22 23
     <div>
23
-      <label class="block text-sm font-medium mb-1">Subject</label>
24
+      <label class="block text-sm font-medium mb-1">{% trans "Subject" %}</label>
24 25
       <input type="text" name="subject" value="{{ form.subject.value|default:'' }}" class="w-full border rounded px-3 py-2">
25 26
     </div>
26 27
   </div>
27 28
   <div>
28
-    <label class="block text-sm font-medium mb-1">Message</label>
29
+    <label class="block text-sm font-medium mb-1">{% trans "Message" %}</label>
29 30
     <textarea name="message" rows="5" class="w-full border rounded px-3 py-2">{{ form.message.value|default:'' }}</textarea>
30 31
   </div>
31 32
   <div>
32
-    <button class="btn-primary" type="submit">Send</button>
33
+    <button class="btn-primary" type="submit">{% trans "Send" %}</button>
33 34
   </div>
34 35
 </form>
35 36
 <style>.btn-primary{background:#1d4ed8;color:white;padding:.5rem .75rem;border-radius:.375rem}</style>

+ 24 - 24
public_frontend/templates/public_frontend/home.html

@@ -1,16 +1,16 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% load static %}
3
-{% block title %}Home{% endblock %}
2
+{% load static i18n %}
3
+{% block title %}{% trans "Home" %}{% endblock %}
4 4
 
5 5
 {% block content %}
6 6
 <div class="grid gap-12 md:gap-16">
7 7
   {# Hero Section #}
8 8
   <section id="hero" class="bg-white rounded-lg shadow-md p-6 md:p-8 text-center">
9
-    <h1 class="text-3xl md:text-4xl font-bold mb-2">Streamline Your Factory's Recycling</h1>
10
-    <p class="text-gray-600 max-w-2xl mx-auto mb-6">We partner with businesses like yours to manage scrap materials efficiently. Browse listings, request a pickup, and turn your waste into a resource.</p>
9
+    <h1 class="text-3xl md:text-4xl font-bold mb-2">{% trans "Streamline Your Factory's Recycling" %}</h1>
10
+    <p class="text-gray-600 max-w-2xl mx-auto mb-6">{% trans "We partner with businesses like yours to manage scrap materials efficiently. Browse listings, request a pickup, and turn your waste into a resource." %}</p>
11 11
     <div class="flex gap-3 justify-center">
12
-      <a href="{% url 'public_frontend:pickup_request' %}" class="btn-primary">Request a Pickup</a>
13
-      <a href="#listings" class="btn-outline">Browse Listings</a>
12
+      <a href="{% url 'public_frontend:pickup_request' %}" class="btn-primary">{% trans "Request a Pickup" %}</a>
13
+      <a href="#listings" class="btn-outline">{% trans "Browse Listings" %}</a>
14 14
     </div>
15 15
   </section>
16 16
 
@@ -18,14 +18,14 @@
18 18
   {% if services %}
19 19
   <section id="services">
20 20
     <div class="flex items-center justify-between mb-3">
21
-      <h2 class="text-2xl font-semibold">Our Services</h2>
21
+      <h2 class="text-2xl font-semibold">{% trans "Our Services" %}</h2>
22 22
     </div>
23 23
     <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
24 24
       {% for s in services %}
25 25
         <a href="{% url 'public_frontend:service_detail' s.pk %}" class="block p-4 bg-white rounded-lg shadow-md hover:bg-gray-50 transition flex items-start gap-4">
26 26
           <img src="{% static 'service_icons/' %}{{ s.image_name }}" alt="{{ s.title }} icon" class="w-12 h-12 object-contain"/>
27 27
           <div>
28
-            <div class="font-medium">{{ s.title }}</div>
28
+            <div class="font-medium">{{ s.get_title_display }}</div>
29 29
             <div class="text-sm text-gray-600">{{ s.description }}</div>
30 30
           </div>
31 31
         </a>
@@ -37,8 +37,8 @@
37 37
   {# Materials Section #}
38 38
   <section id="materials">
39 39
     <div class="flex items-center justify-between mb-3">
40
-      <h2 class="text-2xl font-semibold">Materials We Accept</h2>
41
-      <a href="{% url 'public_frontend:materials_list' %}" class="text-blue-700 hover:underline">View all</a>
40
+      <h2 class="text-2xl font-semibold">{% trans "Materials We Accept" %}</h2>
41
+      <a href="{% url 'public_frontend:materials_list' %}" class="text-blue-700 hover:underline">{% trans "View all" %}</a>
42 42
     </div>
43 43
     <div class="bg-white rounded-lg shadow-md p-4">
44 44
         <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
@@ -48,7 +48,7 @@
48 48
                     <p class="text-sm text-gray-500">{{ m.category.name }}</p>
49 49
                 </div>
50 50
             {% empty %}
51
-                <p class="text-gray-500 col-span-full">No materials published.</p>
51
+                <p class="text-gray-500 col-span-full">{% trans "No materials published." %}</p>
52 52
             {% endfor %}
53 53
         </div>
54 54
     </div>
@@ -57,18 +57,18 @@
57 57
   {# Open Listings Section #}
58 58
   <section id="listings">
59 59
     <div class="flex items-center justify-between mb-3">
60
-      <h2 class="text-2xl font-semibold">Open Listings</h2>
61
-      <a href="{% url 'public_frontend:listings_list' %}" class="text-blue-700 hover:underline">Browse all</a>
60
+      <h2 class="text-2xl font-semibold">{% trans "Open Listings" %}</h2>
61
+      <a href="{% url 'public_frontend:listings_list' %}" class="text-blue-700 hover:underline">{% trans "Browse all" %}</a>
62 62
     </div>
63 63
     <div class="grid md:grid-cols-3 gap-4">
64 64
       {% for l in listings %}
65 65
         <a href="{% url 'public_frontend:listing_detail' l.id %}" class="block p-4 border rounded bg-white hover:bg-gray-50 transition">
66
-          <div class="text-sm text-gray-500">Ends {{ l.ends_at|default:'—' }}</div>
66
+          <div class="text-sm text-gray-500">{% trans "Ends" %} {{ l.ends_at|default:'—' }}</div>
67 67
           <div class="font-medium">{{ l.title }}</div>
68 68
           <div class="text-sm text-gray-600 line-clamp-2">{{ l.description|truncatechars:120 }}</div>
69 69
         </a>
70 70
       {% empty %}
71
-        <div class="text-gray-500 p-4 bg-white rounded-lg shadow-md col-span-full">No public listings at the moment.</div>
71
+        <div class="text-gray-500 p-4 bg-white rounded-lg shadow-md col-span-full">{% trans "No public listings at the moment." %}</div>
72 72
       {% endfor %}
73 73
     </div>
74 74
   </section>
@@ -78,8 +78,8 @@
78 78
   {# Blog Section #}
79 79
   <section id="blog">
80 80
     <div class="flex items-center justify-between mb-3">
81
-      <h2 class="text-2xl font-semibold">Industry Insights</h2>
82
-      <a href="{% url 'public_frontend:blog_list' %}" class="text-blue-700 hover:underline">View all</a>
81
+      <h2 class="text-2xl font-semibold">{% trans "Industry Insights" %}</h2>
82
+      <a href="{% url 'public_frontend:blog_list' %}" class="text-blue-700 hover:underline">{% trans "View all" %}</a>
83 83
     </div>
84 84
     <div class="grid md:grid-cols-3 gap-4">
85 85
       {% for p in posts %}
@@ -89,36 +89,36 @@
89 89
           <div class="text-sm text-gray-600 line-clamp-2">{{ p.excerpt|default:p.content|striptags|truncatechars:120 }}</div>
90 90
         </a>
91 91
       {% empty %}
92
-        <div class="text-gray-500 p-4 bg-white rounded-lg shadow-md col-span-full">No posts yet.</div>
92
+        <div class="text-gray-500 p-4 bg-white rounded-lg shadow-md col-span-full">{% trans "No posts yet." %}</div>
93 93
       {% endfor %}
94 94
     </div>
95 95
   </section>
96 96
 
97 97
   {# Contact Section #}
98 98
   <section id="contact">
99
-    <h2 class="text-2xl font-semibold mb-3">Contact Us</h2>
99
+    <h2 class="text-2xl font-semibold mb-3">{% trans "Contact Us" %}</h2>
100 100
     <form method="post" action="{% url 'public_frontend:contact' %}" class="bg-white rounded-lg shadow-md p-4 grid gap-4">
101 101
       {% csrf_token %}
102 102
       <div class="grid md:grid-cols-2 gap-4">
103 103
         <div>
104
-          <label class="block text-sm font-medium mb-1">Name</label>
104
+          <label class="block text-sm font-medium mb-1">{% trans "Name" %}</label>
105 105
           <input type="text" name="name" value="{{ contact_form.name.value|default:'' }}" required class="w-full border rounded px-3 py-2">
106 106
         </div>
107 107
         <div>
108
-          <label class="block text-sm font-medium mb-1">Email</label>
108
+          <label class="block text-sm font-medium mb-1">{% trans "Email" %}</label>
109 109
           <input type="email" name="email" value="{{ contact_form.email.value|default:'' }}" required class="w-full border rounded px-3 py-2">
110 110
         </div>
111 111
       </div>
112 112
       <div>
113
-        <label class="block text-sm font-medium mb-1">Subject</label>
113
+        <label class="block text-sm font-medium mb-1">{% trans "Subject" %}</label>
114 114
         <input type="text" name="subject" value="{{ contact_form.subject.value|default:'' }}" class="w-full border rounded px-3 py-2">
115 115
       </div>
116 116
       <div>
117
-        <label class="block text-sm font-medium mb-1">Message</label>
117
+        <label class="block text-sm font-medium mb-1">{% trans "Message" %}</label>
118 118
         <textarea name="message" rows="5" class="w-full border rounded px-3 py-2">{{ contact_form.message.value|default:'' }}</textarea>
119 119
       </div>
120 120
       <div>
121
-        <button class="btn-primary" type="submit">Send Message</button>
121
+        <button class="btn-primary" type="submit">{% trans "Send Message" %}</button>
122 122
       </div>
123 123
     </form>
124 124
   </section>

+ 5 - 4
public_frontend/templates/public_frontend/listing_detail.html

@@ -1,16 +1,17 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Listing {{ listing.id }}{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Listing" %} {{ listing.id }}{% endblock %}
3 4
 {% block content %}
4 5
 <article class="bg-white rounded shadow p-6">
5 6
   <h1 class="text-2xl font-semibold mb-1">{{ listing.title }}</h1>
6
-  <div class="text-sm text-gray-500 mb-4">Status: {{ listing.status }}{% if listing.ends_at %} • Ends {{ listing.ends_at }}{% endif %}</div>
7
+  <div class="text-sm text-gray-500 mb-4">{% trans "Status" %}: {{ listing.status }}{% if listing.ends_at %} • {% trans "Ends" %} {{ listing.ends_at }}{% endif %}</div>
7 8
   <p class="prose max-w-none">{{ listing.description|linebreaks }}</p>
8
-  <h2 class="font-semibold mt-6 mb-2">Items</h2>
9
+  <h2 class="font-semibold mt-6 mb-2">{% trans "Items" %}</h2>
9 10
   <ul class="list-disc ml-6 text-sm text-gray-700">
10 11
   {% for it in listing.items.all %}
11 12
     <li>{{ it.material.name }} — {{ it.quantity_estimate }} {{ it.get_unit_display }}</li>
12 13
   {% empty %}
13
-    <li>No items listed</li>
14
+    <li>{% trans "No items listed" %}</li>
14 15
   {% endfor %}
15 16
   </ul>
16 17
 </article>

+ 4 - 4
public_frontend/templates/public_frontend/listings_list.html

@@ -1,19 +1,19 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Listings{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Listings" %}{% endblock %}
3 4
 {% block content %}
4 5
 <div class="grid md:grid-cols-3 gap-4">
5 6
   {% for l in listings %}
6 7
     <a href="{% url 'public_frontend:listing_detail' l.id %}" class="block p-4 border rounded bg-white hover:bg-gray-50">
7
-      <div class="text-sm text-gray-500">Ends {{ l.ends_at|default:'—' }}</div>
8
+      <div class="text-sm text-gray-500">{% trans "Ends" %} {{ l.ends_at|default:'—' }}</div>
8 9
       <div class="font-medium">{{ l.title }}</div>
9 10
       <div class="text-sm text-gray-600 line-clamp-2">{{ l.description|truncatechars:140 }}</div>
10 11
     </a>
11 12
   {% empty %}
12
-    <div class="text-gray-500">No public listings.</div>
13
+    <div class="text-gray-500">{% trans "No public listings." %}</div>
13 14
   {% endfor %}
14 15
 </div>
15 16
 <div class="mt-4">
16 17
   {% include 'admin_frontend/_pagination.html' %}
17 18
   </div>
18 19
 {% endblock %}
19
-

+ 6 - 5
public_frontend/templates/public_frontend/materials_list.html

@@ -1,13 +1,14 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Materials{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Materials" %}{% endblock %}
3 4
 {% block content %}
4 5
 <div class="bg-white rounded shadow overflow-hidden">
5 6
   <table class="min-w-full text-sm">
6 7
     <thead class="bg-gray-50 text-left">
7 8
       <tr>
8
-        <th class="px-4 py-2">Name</th>
9
-        <th class="px-4 py-2">Category</th>
10
-        <th class="px-4 py-2">Default Unit</th>
9
+        <th class="px-4 py-2">{% trans "Name" %}</th>
10
+        <th class="px-4 py-2">{% trans "Category" %}</th>
11
+        <th class="px-4 py-2">{% trans "Default Unit" %}</th>
11 12
       </tr>
12 13
     </thead>
13 14
     <tbody>
@@ -18,7 +19,7 @@
18 19
           <td class="px-4 py-2">{{ m.get_default_unit_display }}</td>
19 20
         </tr>
20 21
       {% empty %}
21
-        <tr><td colspan="3" class="px-4 py-6 text-center text-gray-500">No materials published.</td></tr>
22
+        <tr><td colspan="3" class="px-4 py-6 text-center text-gray-500">{% trans "No materials published." %}</td></tr>
22 23
       {% endfor %}
23 24
     </tbody>
24 25
   </table>

+ 15 - 14
public_frontend/templates/public_frontend/pickup_request.html

@@ -1,8 +1,9 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
-{% block title %}Request Pickup{% endblock %}
2
+{% load i18n %}
3
+{% block title %}{% trans "Request Pickup" %}{% endblock %}
3 4
 {% load crispy_forms_tags widget_tweaks %}
4 5
 {% block content %}
5
-<h1 class="text-xl font-semibold mb-4">Request a Pickup</h1>
6
+<h1 class="text-xl font-semibold mb-4">{% trans "Request a Pickup" %}</h1>
6 7
 <div x-data="pickupForm()">
7 8
   <div class="bg-white rounded shadow p-4" >
8 9
     <form x-ref="form" id="pickup-form" method="post" enctype="multipart/form-data" class="space-y-4">
@@ -32,33 +33,33 @@
32 33
 
33 34
   <dialog x-ref="dialog" id="review_modal" class="modal dark:bg-black/40">
34 35
     <div class="modal-box dark:bg-gray-900 dark:text-gray-100 dark:border dark:border-gray-700">
35
-      <h3 class="font-bold text-lg">Review Your Pickup Request</h3>
36
+      <h3 class="font-bold text-lg">{% trans "Review Your Pickup Request" %}</h3>
36 37
       <div class="py-4 space-y-3">
37
-        <div><div class="text-sm text-gray-600 dark:text-gray-300">Name</div><div class="font-medium" x-text="rv.name || '—'"></div></div>
38
+        <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Name" %}</div><div class="font-medium" x-text="rv.name || '—'"></div></div>
38 39
         <div class="grid md:grid-cols-2 gap-4">
39
-          <div><div class="text-sm text-gray-600 dark:text-gray-300">Email</div><div class="font-medium" x-text="rv.email || '—'"></div></div>
40
-          <div><div class="text-sm text-gray-600 dark:text-gray-300">Phone</div><div class="font-medium" x-text="rv.phone || '—'"></div></div>
40
+          <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Email" %}</div><div class="font-medium" x-text="rv.email || '—'"></div></div>
41
+          <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Phone" %}</div><div class="font-medium" x-text="rv.phone || '—'"></div></div>
41 42
         </div>
42
-        <div><div class="text-sm text-gray-600 dark:text-gray-300">Pickup Address</div><div class="whitespace-pre-line" x-text="rv.address || '—'"></div></div>
43
+        <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Pickup Address" %}</div><div class="whitespace-pre-line" x-text="rv.address || '—'"></div></div>
43 44
         <div class="grid md:grid-cols-2 gap-4">
44
-          <div><div class="text-sm text-gray-600 dark:text-gray-300">Preferred Date/Time</div><div class="font-medium" x-text="rv.preferred_at || '—'"></div></div>
45
+          <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Preferred Date/Time" %}</div><div class="font-medium" x-text="rv.preferred_at || '—'"></div></div>
45 46
         </div>
46
-        <div><div class="text-sm text-gray-600 dark:text-gray-300">Materials / Notes</div><div class="whitespace-pre-line" x-text="rv.materials || '—'"></div></div>
47
+        <div><div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Materials / Notes" %}</div><div class="whitespace-pre-line" x-text="rv.materials || '—'"></div></div>
47 48
         <div>
48
-          <div class="text-sm text-gray-600 dark:text-gray-300">Photos</div>
49
+          <div class="text-sm text-gray-600 dark:text-gray-300">{% trans "Photos" %}</div>
49 50
           <ul class="list-disc list-inside text-sm text-gray-700 dark:text-gray-300">
50
-            <template x-if="(rv.photos||[]).length === 0"><li>No files attached.</li></template>
51
+            <template x-if="(rv.photos||[]).length === 0"><li>{% trans "No files attached." %}</li></template>
51 52
             <template x-for="fname in rv.photos" :key="fname"><li x-text="fname"></li></template>
52 53
           </ul>
53 54
         </div>
54 55
       </div>
55 56
       <div class="modal-action">
56
-        <button class="btn" @click="$refs.dialog.close()">Edit</button>
57
-        <button class="btn btn-primary" @click.prevent="confirm">Confirm &amp; Send</button>
57
+        <button class="btn" @click="$refs.dialog.close()">{% trans "Edit" %}</button>
58
+        <button class="btn btn-primary" @click.prevent="confirm">{% trans "Confirm & Send" %}</button>
58 59
       </div>
59 60
     </div>
60 61
     <form method="dialog" class="modal-backdrop dark:bg-black/60">
61
-      <button class="dark:text-gray-200">close</button>
62
+      <button class="dark:text-gray-200">{% trans "close" %}</button>
62 63
     </form>
63 64
   </dialog>
64 65
 </div>

+ 2 - 2
public_frontend/templates/public_frontend/service_detail.html

@@ -1,4 +1,5 @@
1 1
 {% extends 'public_frontend/base.html' %}
2
+{% load i18n %}
2 3
 {% load static %}
3 4
 {% block title %}{{ service.title }}{% endblock %}
4 5
 
@@ -25,8 +26,7 @@
25 26
   {% endif %}
26 27
 
27 28
   <div>
28
-    <a href="/" class="text-blue-700 hover:underline">← Back to Home</a>
29
+    <a href="/" class="text-blue-700 hover:underline">← {% trans "Back to Home" %}</a>
29 30
   </div>
30 31
 </article>
31 32
 {% endblock %}
32
-

+ 9 - 8
recycle_core/models.py

@@ -6,6 +6,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey
6 6
 from django.contrib.contenttypes.models import ContentType
7 7
 from django.db import models
8 8
 from django.utils import timezone
9
+from django.utils.translation import gettext_lazy as _
9 10
 from orgs.models import Organization
10 11
 from markdownfield.models import MarkdownField, RenderedMarkdownField
11 12
 from markdownfield.validators import VALIDATOR_STANDARD
@@ -52,14 +53,14 @@ class MaterialCategory(TimestampedModel):
52 53
 class ProvidedService(TimestampedModel):
53 54
     organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="services")
54 55
     TITLE_CHOICES = (
55
-        ("Pickup & Logistics", "Pickup & Logistics"),
56
-        ("Material Sorting", "Material Sorting"),
57
-        ("Weighing & Ticketing", "Weighing & Ticketing"),
58
-        ("Invoicing & Payouts", "Invoicing & Payouts"),
59
-        ("Reporting & Analytics", "Reporting & Analytics"),
60
-        ("Marketplace & Bidding", "Marketplace & Bidding"),
61
-        ("Compliance & Audits", "Compliance & Audits"),
62
-        ("Consulting & Training", "Consulting & Training"),
56
+        ("Pickup & Logistics", _("Pickup & Logistics")),
57
+        ("Material Sorting", _("Material Sorting")),
58
+        ("Weighing & Ticketing", _("Weighing & Ticketing")),
59
+        ("Invoicing & Payouts", _("Invoicing & Payouts")),
60
+        ("Reporting & Analytics", _("Reporting & Analytics")),
61
+        ("Marketplace & Bidding", _("Marketplace & Bidding")),
62
+        ("Compliance & Audits", _("Compliance & Audits")),
63
+        ("Consulting & Training", _("Consulting & Training")),
63 64
     )
64 65
     title = models.CharField(max_length=100, choices=TITLE_CHOICES)
65 66
     # Short summary text

+ 10 - 8
recycle_core/templates/recycle_core/pickups_list.html

@@ -8,9 +8,9 @@
8 8
 </div>
9 9
 
10 10
 <div class="bg-white rounded shadow p-4 mb-4">
11
-  <form method="get" class="space-y-3 flex gap-2">
11
+  <form method="get" class="flex flex-wrap gap-3 items-end">
12 12
     {{ filter.form|crispy }}
13
-    <div class="flex items-center gap-2">
13
+    <div class="flex items-center gap-2 w-full">
14 14
       <button class="px-3 py-2 bg-blue-600 text-white rounded">Filter</button>
15 15
       <a href="{% url 'recycle_core:pickups_list' %}" class="btn-outline">Reset</a>
16 16
     </div>
@@ -20,15 +20,16 @@
20 20
   {% endif %}
21 21
 </div>
22 22
 
23
-<div class="bg-white rounded shadow overflow-hidden">
24
-  <table class="min-w-full divide-y divide-gray-200">
23
+<div class="bg-white rounded shadow">
24
+  <div class="overflow-x-auto">
25
+  <table class="min-w-[1100px] divide-y divide-gray-200">
25 26
     <thead class="bg-gray-50">
26 27
       <tr>
27 28
         <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Customer</th>
28 29
         <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Site</th>
29 30
         <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Status</th>
30 31
         <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Scheduled</th>
31
-        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Driver</th>
32
+        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 w-56 min-w-[220px]">Driver</th>
32 33
         <th class="px-4 py-2 text-left text-xs font-medium text-gray-500">Actions</th>
33 34
       </tr>
34 35
     </thead>
@@ -38,11 +39,11 @@
38 39
         <td class="px-4 py-2">{{ p.customer.name }}</td>
39 40
         <td class="px-4 py-2">{{ p.site.name }}</td>
40 41
         <td class="px-4 py-2"><span class="px-2 py-1 rounded bg-gray-100 text-gray-700">{{ p.status }}</span></td>
41
-        <td class="px-4 py-2 text-gray-500">{{ p.scheduled_at|default:"-" }}</td>
42
-        <td class="px-4 py-2 text-gray-600">{{ p.assigned_driver.username|default:"-" }}</td>
42
+        <td class="px-4 py-2 text-gray-500">{{ p.scheduled_at|date:"SHORT_DATETIME_FORMAT"|default:"-" }}</td>
43
+        <td class="px-4 py-2 text-gray-600 w-56 min-w-[220px] whitespace-nowrap">{{ p.assigned_driver.username|default:"-" }}</td>
43 44
         <td class="px-4 py-2">
44 45
           <div class="flex flex-wrap gap-2 justify-end">
45
-            <a class="btn-outline btn-xs" href="{% url 'recycle_core:pickup_detail' p.id %}">View</a>
46
+            <a class="text-blue-600 hover:text-blue-700 hover:underline text-xs font-medium mr-3" href="{% url 'recycle_core:pickup_detail' p.id %}">View</a>
46 47
             {% if perms.recycle_core.assign_driver %}
47 48
             <form method="post" action="{% url 'recycle_core:pickup_assign' p.id %}" class="flex items-center gap-2">
48 49
               {% csrf_token %}
@@ -78,6 +79,7 @@
78 79
       {% endfor %}
79 80
     </tbody>
80 81
   </table>
82
+  </div>
81 83
   {% include 'admin_frontend/_pagination.html' %}
82 84
 </div>
83 85
 {% endblock %}

+ 22 - 1
recycle_core/views.py

@@ -7,6 +7,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
7 7
 import django_filters as filters
8 8
 
9 9
 from admin_frontend.templatetags.public_urls import public_route
10
+from django import forms
10 11
 from admin_frontend.nav import _nav_items
11 12
 from cms.views import breadcrumbs
12 13
 from orgs.decorators import permissions_required
@@ -421,7 +422,16 @@ def pickups_list(request):
421 422
         site = filters.ModelChoiceFilter(queryset=CustomerSite.objects.all())
422 423
         assigned_driver = filters.CharFilter(field_name="assigned_driver__username", lookup_expr="icontains", label="Driver")
423 424
         status = filters.ChoiceFilter(field_name="status", choices=PickupOrder.STATUS_CHOICES)
424
-        scheduled_at = filters.DateFromToRangeFilter(field_name="scheduled_at", label="Scheduled between")
425
+        scheduled_at = filters.DateTimeFromToRangeFilter(
426
+            field_name="scheduled_at",
427
+            label="Scheduled between",
428
+            widget=filters.widgets.RangeWidget(
429
+                attrs={
430
+                    "type": "datetime-local",
431
+                    "class": "border border-gray-300 rounded px-2 py-1"
432
+                }
433
+            ),
434
+        )
425 435
 
426 436
         class Meta:
427 437
             model = PickupOrder
@@ -448,6 +458,11 @@ def pickups_list(request):
448 458
 
449 459
     # empty forms used in row actions
450 460
     assign_form = PickupAssignForm()
461
+    # Limit driver choices to users with driver role, scoped to org if present
462
+    drivers_qs = get_user_model().objects.filter(recycle_profile__role="driver")
463
+    if org is not None:
464
+        drivers_qs = drivers_qs.filter(recycle_profile__organization=org)
465
+    assign_form.fields["driver"].queryset = drivers_qs.order_by("username")
451 466
     status_form = PickupStatusForm()
452 467
 
453 468
     context = {
@@ -467,6 +482,12 @@ def pickups_list(request):
467 482
 def pickup_assign(request, pk: int):
468 483
     pickup = get_object_or_404(PickupOrder, pk=pk)
469 484
     form = PickupAssignForm(request.POST)
485
+    # Enforce driver role (and org, if present) on POST validation
486
+    org = getattr(request, "org", None)
487
+    drivers_qs = get_user_model().objects.filter(recycle_profile__role="driver")
488
+    if org is not None:
489
+        drivers_qs = drivers_qs.filter(recycle_profile__organization=org)
490
+    form.fields["driver"].queryset = drivers_qs
470 491
     if form.is_valid():
471 492
         pickup.assigned_driver = form.cleaned_data["driver"]
472 493
         pickup.status = PickupOrder.STATUS_SCHEDULED

+ 27 - 0
translations/menu_labels.py

@@ -0,0 +1,27 @@
1
+from django.utils.translation import gettext_lazy as _
2
+
3
+# Mark app menu labels for translation extraction
4
+_("Dashboard")
5
+_("Profiles")
6
+_("Opportunities")
7
+_("Intro Requests")
8
+_("Leaderboard")
9
+_("Leads")
10
+_("CMS Posts")
11
+_("CMS Categories")
12
+_("Settings")
13
+_("Advanced Settings")
14
+_("Organization Settings")
15
+_("Organization Sites")
16
+_("Permissions")
17
+_("Users")
18
+_("Materials")
19
+_("Customers")
20
+_("Pickups")
21
+_("Weigh Tickets")
22
+_("Documents")
23
+_("Provided Services")
24
+_("Scrap Listings")
25
+_("Invoices")
26
+_("Payouts")
27
+

tum/occp_server - Gogs: Simplico Git Service

説明なし

README.md 75KB

# [e-Mobility charging stations simulator](https://github.com/sap/e-mobility-charging-stations-simulator)
[![GitHub Clones](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=Clone&query=count&url=https://gist.githubusercontent.com/jerome-benoit/c7c669b881d5b27dc0b44a639504ff93/raw/clone.json&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/traffic) [![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/SAP/e-mobility-charging-stations-simulator/main?color=brightgreen&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/commit-activity) [![CI workflow](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml/badge.svg)](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml) [![REUSE status](https://api.reuse.software/badge/github.com/SAP/e-mobility-charging-stations-simulator)](https://api.reuse.software/info/github.com/SAP/e-mobility-charging-stations-simulator) [![neostandard Javascript Code Style]()](https://github.com/neostandard/neostandard)

Simple node.js software to simulate and scale a set of charging stations based on the OCPP-J protocol as part of SAP e-Mobility solution.

Table of contents

Installation

Prerequisites

Install the node.js current LTS or superior version runtime environment:

Windows

choco install -y nodejs

MacOSX

brew install node

GNU/Linux

  • NodeSource node.js binary distributions for all supported versions.

Development prerequisites (optional)

Install volta for managing automatically the node.js runtime and package manager version:

Unix

curl https://get.volta.sh | bash

Windows

choco install -y volta

Setup volta with pnpm package manager support: https://docs.volta.sh/advanced/pnpm

Branching model

The main branch is the default development branch.
The vX branches are the maintenance branches for the corresponding major version X.
The vX.Y branches are the maintenance branches for the corresponding major and minor version X.Y.

Dependencies

Enable corepack, if volta is not installed and configured, and install latest pnpm version:

corepack enable
corepack prepare pnpm@latest --activate

In the repository root, run the following command:

pnpm install

Initial configuration

Copy the configuration template file src/assets/config-template.json to src/assets/config.json.
Copy the RFID tags template file src/assets/idtags-template.json to src/assets/idtags.json.

Tweak them to your needs by following the section configuration files syntax: OCPP server supervision URL(s), charging station templates, etc.

Start simulator

pnpm start

Start Web UI

See Web UI README.md for more information.

Configuration files syntax

All configuration files are using the JSON standard syntax.

Configuration files locations:

The charging stations simulator's configuration parameters must be within the src/assets/config.json file. A charging station simulator configuration template file is available at src/assets/config-template.json.

All charging station configuration templates are in the directory src/assets/station-templates.

A list of RFID tags must be defined for the automatic transaction generator in a file with the default location and name: src/assets/idtags.json. A template file is available at src/assets/idtags-template.json.

Configuration files hierarchy and priority:

  1. charging station configuration: dist/assets/configurations;
  2. charging station configuration template: src/assets/station-templates;
  3. charging stations simulator configuration: src/assets/config.json.

The charging stations simulator has an automatic configuration files reload feature at change for:

  • charging stations simulator configuration;
  • charging station configuration templates;
  • charging station authorization RFID tags lists.

But the modifications to test have to be done to the files in the build target directory dist/assets. Once the modifications are done, they have to be reported to the matching files in the build source directory src/assets to ensure they will be taken into account at next build.

Charging stations simulator configuration

src/assets/config.json:

- console: output logs on the console
- format: winston log format
- rotate: enable daily log files rotation
- maxFiles: maximum number of log files: https://github.com/winstonjs/winston-daily-rotate-file#options
- maxSize: maximum size of log files in bytes, or units of kb, mb, and gb: https://github.com/winstonjs/winston-daily-rotate-file#options- poolMaxSize: worker threads pool maximum number of threads
- resourceLimits: worker threads resource limits object option
Key Value(s) Default Value Value type Description
supervisionUrls [] string | string[] string or strings array containing global connection URIs to OCPP-J servers
supervisionUrlDistribution round-robin/random/charging-station-affinity charging-station-affinity string supervision urls distribution policy to simulated charging stations
log {
"enabled": true,
"file": "logs/combined.log",
"errorFile": "logs/error.log",
"statisticsInterval": 60,
"level": "info",
"console": false,
"format": "simple",
"rotate": true
}
{
enabled?: boolean;
file?: string;
errorFile?: string;
statisticsInterval?: number;
level?: string;
console?: boolean;
format?: string;
rotate?: boolean;
maxFiles?: string | number;
maxSize?: string | number;
}
Log configuration section:
- enabled: enable logging
- file: log file relative path
- errorFile: error log file relative path
- statisticsInterval: seconds between charging stations statistics output in the logs
- level: emerg/alert/crit/error/warning/notice/info/debug winston logging level
worker {
"processType": "workerSet",
"startDelay": 500,
"elementAddDelay": 0,
"elementsPerWorker": 'auto',
"poolMinSize": 4,
"poolMaxSize": 16
}
{
processType?: WorkerProcessType;
startDelay?: number;
elementAddDelay?: number;
elementsPerWorker?: number | 'auto' | 'all';
poolMinSize?: number;
poolMaxSize?: number;
resourceLimits?: ResourceLimits;
}
Worker configuration section:
- processType: worker threads process type (workerSet/fixedPool/dynamicPool)
- startDelay: milliseconds to wait at worker threads startup (only for workerSet worker threads process type)
- elementAddDelay: milliseconds to wait between charging station add
- elementsPerWorker: number of charging stations per worker threads for the workerSet process type (auto means (number of stations) / (number of CPUs) * 1.5 if (number of stations) > (number of CPUs), otherwise 1; all means a unique worker will run all charging stations)
- poolMinSize: worker threads pool minimum number of threads
uiServer {
"enabled": false,
"type": "ws",
"version": "1.1",
"options": {
"host": "localhost",
"port": 8080
}
} {
enabled?: boolean;
type?: ApplicationProtocol;
version?: ApplicationProtocolVersion;
options?: ServerOptions;
authentication?: {
enabled: boolean;
type: AuthenticationType;
username?: string;
password?: string;
}
} UI server configuration section:
- enabled: enable UI server
- type: 'http' or 'ws'
- version: HTTP version '1.1' or '2.0'
- options: node.js net module listen options
- authentication: authentication type configuration section performanceStorage {
"enabled": true,
"type": "none",
} {
enabled?: boolean;
type?: string;
uri?: string;
} Performance storage configuration section:
- enabled: enable performance storage
- type: 'jsonfile', 'mongodb' or 'none'
- uri: storage URI stationTemplateUrls {}[] {
file: string;
numberOfStations: number;
provisionedNumberOfStations?: number;
}[] array of charging station templates URIs configuration section:
- file: charging station configuration template file relative path
- numberOfStations: template number of stations at startup
- provisionedNumberOfStations: template provisioned number of stations after startup

Worker process model

  • workerSet: Worker set executing each a fixed number (elementsPerWorker) of simulated charging stations from the total

  • fixedPool: Fixedly sized worker pool executing a fixed total number of simulated charging stations

  • dynamicPool (experimental): Dynamically sized worker pool executing a fixed total number of simulated charging stations

Charging station template configuration

src/assets/station-templates/<name>.json:

Configuration section syntax example

  "Configuration": {
    "configurationKey": [
       ...
       {
        "key": "StandardKey",
        "readonly": false,
        "value": "StandardValue",
        "visible": true,
        "reboot": false
      },
      ...
      {
        "key": "VendorKey",
        "readonly": false,
        "value": "VendorValue",
        "visible": false,
        "reboot": true
      },
      ...
    ]
  }

AutomaticTransactionGenerator section syntax example

Type definition:
type AutomaticTransactionGeneratorConfiguration = {
  enable: boolean
  minDuration: number
  maxDuration: number
  minDelayBetweenTwoTransactions: number
  maxDelayBetweenTwoTransactions: number
  probabilityOfStart: number
  stopAfterHours: number
  stopAbsoluteDuration: boolean
  requireAuthorize?: boolean
  idTagDistribution?: 'random' | 'round-robin' | 'connector-affinity'
}
Example:
  "AutomaticTransactionGenerator": {
    "enable": false,
    "minDuration": 60,
    "maxDuration": 80,
    "minDelayBetweenTwoTransactions": 15,
    "maxDelayBetweenTwoTransactions": 30,
    "probabilityOfStart": 1,
    "stopAfterHours": 0.3,
    "requireAuthorize": true,
    "idTagDistribution": "random"
  }

Connectors section syntax example

  "Connectors": {
    "0": {},
    "1": {
      "bootStatus": "Available",
      "MeterValues": [
        ...
        {
          "unit": "W",
          "measurand": "Power.Active.Import",
          "phase": "L1-N",
          "value": "5000",
          "fluctuationPercent": "10"
        },
        ...
        {
          "unit": "A",
          "measurand": "Current.Import",
          "minimum": "0.5"
        },
        ...
        {
          "unit": "Wh"
        },
        ...
      ]
    }
  },

Evses section syntax example

  "Evses": {
    "0": {
      "Connectors": {
        "0": {}
      }
    },
    "1": {
      "Connectors": {
        "1": {
          "bootStatus": "Available",
          "MeterValues": [
            ...
            {
              "unit": "W",
              "measurand": "Power.Active.Import",
              "phase": "L1-N",
              "value": "5000",
              "fluctuationPercent": "10"
            },
            ...
            {
              "unit": "A",
              "measurand": "Current.Import",
              "minimum": "0.5"
            },
            ...
            {
              "unit": "Wh"
            },
            ...
          ]
        }
      }
    }
  },

Charging station configuration

dist/assets/configurations/<hashId>.json:

The charging station configuration file is automatically generated at startup from the charging station configuration template file and is persistent.

The charging station configuration file content can be regenerated partially on matching charging station configuration template file changes. The charging station serial number is kept unchanged.

stationInfo section (optional)

The syntax is similar to charging station configuration template with some added fields like the charging station id (name) and the 'Configuration' section removed.

That section is overwritten on matching charging station configuration template file changes.

connectorsStatus section

The syntax is similar to charging station configuration template 'Connectors' section with some added fields.

That section is overwritten on matching charging station configuration template file changes.

evsesStatus section

The syntax is similar to charging station configuration template 'Evses' section with some added fields.

That section is overwritten on matching charging station configuration template file changes.

automaticTransactionGenerator section (optional)

The syntax is similar to the charging station configuration template 'AutomaticTransactionGenerator' section.

That section is overwritten on matching charging station configuration template file changes.

automaticTransactionGeneratorStatuses section

That section is not overwritten on matching charging station configuration template file changes.

configurationKey section (optional)

The syntax is similar to the charging station configuration template 'Configuration' section.

That section is not overwritten on matching charging station configuration template file changes.

Docker

In the docker folder:

make

OCPP-J commands supported

Version 1.6

Core Profile

  • :white_check_mark: Authorize
  • :white_check_mark: BootNotification
  • :white_check_mark: ChangeAvailability
  • :white_check_mark: ChangeConfiguration
  • :white_check_mark: ClearCache
  • :white_check_mark: DataTransfer
  • :white_check_mark: GetConfiguration
  • :white_check_mark: Heartbeat
  • :white_check_mark: MeterValues
  • :white_check_mark: RemoteStartTransaction
  • :white_check_mark: RemoteStopTransaction
  • :white_check_mark: Reset
  • :white_check_mark: StartTransaction
  • :white_check_mark: StatusNotification
  • :white_check_mark: StopTransaction
  • :white_check_mark: UnlockConnector

Firmware Management Profile

  • :white_check_mark: GetDiagnostics
  • :white_check_mark: DiagnosticsStatusNotification
  • :white_check_mark: FirmwareStatusNotification
  • :white_check_mark: UpdateFirmware

Local Auth List Management Profile

  • :x: GetLocalListVersion
  • :x: SendLocalList

Reservation Profile

  • :white_check_mark: CancelReservation
  • :white_check_mark: ReserveNow

Smart Charging Profile

  • :white_check_mark: ClearChargingProfile
  • :white_check_mark: GetCompositeSchedule
  • :white_check_mark: SetChargingProfile

Remote Trigger Profile

  • :white_check_mark: TriggerMessage

Version 2.x.x

Provisioning

  • :white_check_mark: BootNotification

Authorization

  • :white_check_mark: ClearCache

Availability

  • :white_check_mark: StatusNotification
  • :white_check_mark: Heartbeat

OCPP-J standard parameters supported

All kind of OCPP parameters are supported in charging station configuration or charging station configuration template file. The list here mention the standard ones also handled automatically in the simulator.

Version 1.6

Core Profile

  • :white_check_mark: AuthorizeRemoteTxRequests (type: boolean) (units: -)
  • :x: ClockAlignedDataInterval (type: integer) (units: seconds)
  • :white_check_mark: ConnectionTimeOut (type: integer) (units: seconds)
  • :x: GetConfigurationMaxKeys (type: integer) (units: -)
  • :white_check_mark: HeartbeatInterval (type: integer) (units: seconds)
  • :x: LocalAuthorizeOffline (type: boolean) (units: -)
  • :x: LocalPreAuthorize (type: boolean) (units: -)
  • :x: MeterValuesAlignedData (type: CSL) (units: -)
  • :white_check_mark: MeterValuesSampledData (type: CSL) (units: -)
  • :white_check_mark: MeterValueSampleInterval (type: integer) (units: seconds)
  • :white_check_mark: NumberOfConnectors (type: integer) (units: -)
  • :x: ResetRetries (type: integer) (units: times)
  • :white_check_mark: ConnectorPhaseRotation (type: CSL) (units: -)
  • :x: StopTransactionOnEVSideDisconnect (type: boolean) (units: -)
  • :x: StopTransactionOnInvalidId (type: boolean) (units: -)
  • :x: StopTxnAlignedData (type: CSL) (units: -)
  • :x: StopTxnSampledData (type: CSL) (units: -)
  • :white_check_mark: SupportedFeatureProfiles (type: CSL) (units: -)
  • :x: TransactionMessageAttempts (type: integer) (units: times)
  • :x: TransactionMessageRetryInterval (type: integer) (units: seconds)
  • :x: UnlockConnectorOnEVSideDisconnect (type: boolean) (units: -)
  • :white_check_mark: WebSocketPingInterval (type: integer) (units: seconds)

Firmware Management Profile

  • none

Local Auth List Management Profile

  • :white_check_mark: LocalAuthListEnabled (type: boolean) (units: -)
  • :x: LocalAuthListMaxLength (type: integer) (units: -)
  • :x: SendLocalListMaxLength (type: integer) (units: -)

Reservation Profile

  • :white_check_mark: ReserveConnectorZeroSupported (type: boolean) (units: -)

Smart Charging Profile

  • :x: ChargeProfileMaxStackLevel (type: integer) (units: -)
  • :x: ChargingScheduleAllowedChargingRateUnit (type: CSL) (units: -)
  • :x: ChargingScheduleMaxPeriods (type: integer) (units: -)
  • :x: MaxChargingProfilesInstalled (type: integer) (units: -)

Remote Trigger Profile

  • none

Version 2.x.x

UI Protocol

Protocol to control the simulator via a Websocket or HTTP server:

sequenceDiagram
Client->>UI Server: request
UI Server->>Client: response
Note over UI Server,Client: HTTP or Websocket

Websocket Protocol

SRPC protocol over Websocket. PDU stands for 'Protocol Data Unit'.

  • Request:
    [uuid, ProcedureName, PDU]
    uuid: String uniquely representing this request
    ProcedureName: The procedure to run on the simulator
    PDU: The parameters for said procedure

  • Response:
    [uuid, PDU]
    uuid: String uniquely linking the response to the request
    PDU: Response parameters to requested procedure

To learn how to use the Websocket protocol to pilot the simulator, an Insomnia Websocket requests collection is available in src/assets/ui-protocol directory.

Version 0.0.1

Set the Websocket header Sec-Websocket-Protocol to ui0.0.1.

Procedures
Simulator State
  • Request:
    ProcedureName: 'simulatorState'
    PDU: {}

  • Response:
    PDU: {
    status: 'success' | 'failure',
    state: {
    version: string,
    configuration: ConfigurationData,
    started: boolean,
    templateStatistics: Record
    }
    }

  • Start Simulator
    • Request:
      ProcedureName: 'startSimulator'
      PDU: {}

    • Response:
      PDU: {
      status: 'success' | 'failure'
      }

    Stop Simulator
    • Request:
      ProcedureName: 'stopSimulator'
      PDU: {}

    • Response:
      PDU: {
      status: 'success' | 'failure'
      }

    List Charging Station Templates
    • Request:
      ProcedureName: 'listTemplates'
      PDU: {}

    • Response:
      PDU: {
      status: 'success' | 'failure',
      templates: string[]
      }

    Add Charging Stations
    • Request:
      ProcedureName: 'addChargingStations'
      PDU: {
      template: string,
      numberOfStations: number,
      options?: {
      supervisionUrls?: string | string[],
      persistentConfiguration?: boolean,
      autoStart?: boolean,
      autoRegister?: boolean,
      enableStatistics?: boolean,
      ocppStrictCompliance?: boolean,
      stopTransactionsOnStopped?: boolean
      }
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array (optional),
      hashIdsFailed: charging station unique identifier strings array (optional)
      }

    Delete Charging Stations
    • Request:
      ProcedureName: 'deleteChargingStations'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations),
      deleteConfiguration?: boolean
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Set Charging Station Supervision Url
    • Request:
      ProcedureName: 'setSupervisionUrl'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations),
      url: string
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Performance Statistics
    • Request:
      ProcedureName: 'performanceStatistics'
      PDU: {}

    • Response:
      PDU: {
      status: 'success' | 'failure',
      performanceStatistics: Statistics[]
      }

    List Charging Stations
    • Request:
      ProcedureName: 'listChargingStations'
      PDU: {}

    • Response:
      PDU: {
      status: 'success' | 'failure',
      chargingStations: ChargingStationData[]
      }

    Start Charging Station
    • Request:
      ProcedureName: 'startChargingStation'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Stop Charging Station
    • Request:
      ProcedureName: 'stopChargingStation'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Open Connection
    • Request:
      ProcedureName: 'openConnection'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Close Connection
    • Request:
      ProcedureName: 'closeConnection'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Start Automatic Transaction Generator
    • Request:
      ProcedureName: 'startAutomaticTransactionGenerator'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations),
      connectorIds: connector id integer array (optional, default: all connectors)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Stop Automatic Transaction Generator
    • Request:
      ProcedureName: 'stopAutomaticTransactionGenerator'
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations),
      connectorIds: connector id integer array (optional, default: all connectors)
      }

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    OCPP commands trigger
    • Request:
      ProcedureName: 'commandName' (the OCPP command name in camel case)
      PDU: {
      hashIds: charging station unique identifier strings array (optional, default: all charging stations),
      ...commandPayload
      } (the OCPP command payload with some optional fields added to target the simulated charging stations)

    • Response:
      PDU: {
      status: 'success' | 'failure',
      hashIdsSucceeded: charging station unique identifier strings array,
      hashIdsFailed: charging station unique identifier strings array (optional),
      responsesFailed: failed responses payload array (optional)
      }

    Examples:

    • Start Transaction

      • Request:
        ProcedureName: 'startTransaction'
        PDU: {
        hashIds: charging station unique identifier strings array (optional, default: all charging stations),
        connectorId: connector id integer,
        idTag: RFID tag string
        }

      • Response:
        PDU: {
        status: 'success' | 'failure',
        hashIdsSucceeded: charging station unique identifier strings array,
        hashIdsFailed: charging station unique identifier strings array (optional),
        responsesFailed: failed responses payload array (optional)
        }

    • Stop Transaction

      • Request:
        ProcedureName: 'stopTransaction'
        PDU: {
        hashIds: charging station unique identifier strings array (optional, default: all charging stations),
        transactionId: transaction id integer
        }

      • Response:
        PDU: {
        status: 'success' | 'failure',
        hashIdsSucceeded: charging station unique identifier strings array,
        hashIdsFailed: charging station unique identifier strings array (optional),
        responsesFailed: failed responses payload array (optional)
        }

    • Status Notification

      • Request:
        ProcedureName: 'statusNotification'
        PDU: {
        hashIds: charging station unique identifier strings array (optional, default: all charging stations),
        connectorId: connector id integer,
        errorCode: connector error code,
        status: connector status
        }

      • Response:
        PDU: {
        status: 'success' | 'failure',
        hashIdsSucceeded: charging station unique identifier strings array,
        hashIdsFailed: charging station unique identifier strings array (optional),
        responsesFailed: failed responses payload array (optional)
        }

    • Heartbeat

      • Request:
        ProcedureName: 'heartbeat'
        PDU: {
        hashIds: charging station unique identifier strings array (optional, default: all charging stations)
        }

      • Response:
        PDU: {
        status: 'success' | 'failure',
        hashIdsSucceeded: charging station unique identifier strings array,
        hashIdsFailed: charging station unique identifier strings array (optional),
        responsesFailed: failed responses payload array (optional)
        }

    HTTP Protocol

    To learn how to use the HTTP protocol to pilot the simulator, an Insomnia HTTP requests collection is available in src/assets/ui-protocol directory.

    Support, Feedback, Contributing

    This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

    Code of Conduct

    We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

    Licensing

    Copyright 2020-2024 SAP SE or an SAP affiliate company and e-mobility-charging-stations-simulator contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Key Value(s) Default Value Value type Description
supervisionUrls [] string | string[] string or strings array containing connection URIs to OCPP-J servers
supervisionUser undefined string basic HTTP authentication user to OCPP-J server
supervisionPassword undefined string basic HTTP authentication password to OCPP-J server
supervisionUrlOcppConfiguration true/false false boolean enable supervision URL configuration via a vendor OCPP parameter key
supervisionUrlOcppKey 'ConnectionUrl' string the vendor string that will be used as a vendor OCPP parameter key to set the supervision URL
autoStart true/false true boolean enable automatic start of added charging station from template
ocppVersion 1.6/2.0/2.0.1 1.6 string OCPP version
ocppProtocol json json string OCPP protocol
ocppStrictCompliance true/false true boolean enable strict adherence to the OCPP version and protocol specifications with OCPP commands PDU validation against OCA JSON schemas
ocppPersistentConfiguration true/false true boolean enable persistent OCPP parameters storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations
stationInfoPersistentConfiguration true/false true boolean enable persistent station information and specifications storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations
automaticTransactionGeneratorPersistentConfiguration true/false true boolean enable persistent automatic transaction generator configuration storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations
wsOptions {} ClientOptions & ClientRequestArgs ws and node.js http clients options intersection
idTagsFile undefined string RFID tags list file relative to src/assets path
baseName undefined string base name to build charging stations id
nameSuffix undefined string name suffix to build charging stations id
fixedName true/false false boolean use the 'baseName' as the charging stations unique name
chargePointModel undefined string charging stations model
chargePointVendor undefined string charging stations vendor
chargePointSerialNumberPrefix undefined string charge point serial number prefix
chargeBoxSerialNumberPrefix undefined string charge box serial number prefix (deprecated since OCPP 1.6)
firmwareVersionPattern Semantic versioning regular expression: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string string charging stations firmware version pattern
firmwareVersion undefined string charging stations firmware version
power float | float[] charging stations maximum power value(s)
powerSharedByConnectors true/false false boolean charging stations power shared by its connectors
powerUnit W/kW W string charging stations power unit
currentOutType AC/DC AC string charging stations current out type
voltageOut AC:230/DC:400 integer charging stations voltage out
numberOfPhases 0/1/3 AC:3/DC:0 integer charging stations number of phase(s)
numberOfConnectors integer | integer[] charging stations number of connector(s)
useConnectorId0 true/false true boolean use connector id 0 definition from the charging station configuration template
randomConnectors true/false false boolean randomize runtime connector id affectation from the connector id definition in charging station configuration template
resetTime 60 integer seconds to wait before the charging stations come back at reset
autoRegister true/false false boolean set charging stations as registered at boot notification for testing purpose
autoReconnectMaxRetries -1 (unlimited) integer connection retries to the OCPP-J server
reconnectExponentialDelay true/false false boolean connection delay retry to the OCPP-J server
registrationMaxRetries -1 (unlimited) integer charging stations boot notification retries
amperageLimitationOcppKey undefined string charging stations OCPP parameter key used to set the amperage limit, per phase for each connector on AC and global for DC
amperageLimitationUnit A/cA/dA/mA A string charging stations amperage limit unit
enableStatistics true/false false boolean enable charging stations statistics
remoteAuthorization true/false true boolean enable RFID tags remote authorization
beginEndMeterValues true/false false boolean enable Transaction.{Begin,End} MeterValues
outOfOrderEndMeterValues true/false false boolean send Transaction.End MeterValues out of order. Need to relax OCPP specifications strict compliance ('ocppStrictCompliance' parameter)
meteringPerTransaction true/false true boolean enable metering history on a per transaction basis
transactionDataMeterValues true/false false boolean enable transaction data MeterValues at stop transaction
stopTransactionsOnStopped true/false true boolean enable stop transactions on charging station stop
mainVoltageMeterValues true/false true boolean include charging stations main voltage MeterValues on three phased charging stations
phaseLineToLineVoltageMeterValues true/false false boolean include charging stations line to line voltage MeterValues on three phased charging stations
customValueLimitationMeterValues true/false true boolean enable limitation on custom fluctuated value in MeterValues
firmwareUpgrade {
"versionUpgrade": {
"step": 1
},
"reset": true
}
{
versionUpgrade?: {
patternGroup?: number;
step?: number;
};
reset?: boolean;
failureStatus?: 'DownloadFailed' | 'InstallationFailed';
}
Configuration section for simulating firmware upgrade support.
commandsSupport {
"incomingCommands": {},
"outgoingCommands": {}
}
{
incomingCommands: Record;
outgoingCommands?: Record;
}
Configuration section for OCPP commands support. Empty section or subsections means all implemented OCPP commands are supported
messageTriggerSupport {} Record Configuration section for OCPP commands trigger support. Empty section means all implemented OCPP trigger commands are supported
Configuration ChargingStationOcppConfiguration charging stations OCPP parameters configuration section
AutomaticTransactionGenerator AutomaticTransactionGeneratorConfiguration charging stations ATG configuration section
Connectors Record charging stations connectors configuration section
Evses Record charging stations EVSEs configuration section