CORD-1532: Fix pluralization in the GRPC API
Change-Id: I7c68ec2fae7fde9eb36b9d8d1d5fa918c8757de3
diff --git a/lib/xos-genx/xosgenx/targets/django-split.xtarget b/lib/xos-genx/xosgenx/targets/django-split.xtarget
index 13212ae..8a0082a 100644
--- a/lib/xos-genx/xosgenx/targets/django-split.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django-split.xtarget
@@ -16,6 +16,8 @@
class {{ m.name }}{{ xproto_base_def(m.name, m.bases) }}:
+ plural_name = "{{ xproto_pluralize(m) }}"
+
# Primitive Fields (Not Relations)
{% for f in m.fields %}
{%- if not f.link -%}
@@ -39,4 +41,4 @@
{% if file_exists(xproto_base_name(m.name)|lower+'_bottom.py') -%}{{ include_file(xproto_base_name(m.name)|lower+'_bottom.py') }}{% endif %}
+++ {{m.name|lower}}.py
-{% endif %}{% endfor %}
\ No newline at end of file
+{% endif %}{% endfor %}
diff --git a/lib/xos-genx/xosgenx/targets/django.xtarget b/lib/xos-genx/xosgenx/targets/django.xtarget
index 20b4e51..67e25c5 100644
--- a/lib/xos-genx/xosgenx/targets/django.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django.xtarget
@@ -17,6 +17,8 @@
class {{ m.name }}{{ xproto_base_def(m.name, m.bases) }}:
+ plural_name = "{{ xproto_pluralize(m) }}"
+
# Primitive Fields (Not Relations)
{% for f in m.fields %}
{%- if not f.link -%}
@@ -39,4 +41,4 @@
pass
{% if file_exists(xproto_base_name(m.name)|lower+'_bottom.py') -%}{{ include_file(xproto_base_name(m.name)|lower+'_bottom.py') }}{% endif %}
-{% endif %}{% endfor %}
\ No newline at end of file
+{% endif %}{% endfor %}
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index 1ba3cff..d3875d5 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -27,6 +27,7 @@
{% for m in proto.messages %}
class {{ m.name }}{{ legacy_tag }}{{ xproto_base_def(m.name, m.bases) }}:
+ plural_name = "{{ xproto_pluralize(m) }}"
KIND = {{ xproto_first_non_empty([m.options.kind, options.kind, options.name, "Set a kind in your xproto!"]) }}
@@ -53,4 +54,4 @@
{% if file_exists(m.name|lower+'_bottom.py') -%}{{ include_file(m.name|lower+'_bottom.py') }}{% endif %}
{% endfor %}
-+++ models{{ legacy_tag }}.py
\ No newline at end of file
++++ models{{ legacy_tag }}.py
diff --git a/xos/core/models/user.py b/xos/core/models/user.py
index a42a719..bffbc87 100644
--- a/xos/core/models/user.py
+++ b/xos/core/models/user.py
@@ -89,6 +89,7 @@
class User(AbstractBaseUser, PlModelMixIn):
+ plural_name = "Users"
@property
def remote_password(self):
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index 17fd6c9..de7ee19 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -112,7 +112,7 @@
return pClass
def getPluralProtoClass(self, djangoClass):
- pClass = getattr(xos_pb2, djangoClass.__name__ + "s")
+ pClass = getattr(xos_pb2, djangoClass.plural_name)
return pClass
def convertFloat(self, x):