Skip to content
Snippets Groups Projects
Commit e2dc41f2 authored by Ben Adida's avatar Ben Adida
Browse files

fixed level where json ld is applied

parent 27c19e13
No related branches found
No related tags found
No related merge requests found
......@@ -80,8 +80,8 @@ class LDObjectContainer(object):
return self._ld_object
def toJSONDict(self):
return self.ld_object.toJSONDict()
def toJSONDict(self, complete=False):
return self.ld_object.toJSONDict(complete=complete)
def toJSON(self):
return self.ld_object.serialize()
......@@ -177,12 +177,10 @@ class LDObject(object):
self._setattr_wrapped(f, new_val)
def serialize(self):
d = self.toDict()
if self.USE_JSON_LD:
d['#'] = {'_': 'http://heliosvoting.org/ns#'}
d = self.toDict(complete = True)
return utils.to_json(d)
def toDict(self, alternate_fields=None):
def toDict(self, alternate_fields=None, complete=False):
val = {}
for f in (alternate_fields or self.FIELDS):
# is it a structured subfield?
......@@ -190,6 +188,10 @@ class LDObject(object):
val[f] = recursiveToDict(self.structured_fields[f])
else:
val[f] = self.process_value_out(f, self._getattr_wrapped(f))
if complete and self.USE_JSON_LD:
val['#'] = {'_': 'http://heliosvoting.org/ns#'}
return val
toJSONDict = toDict
......
......
......@@ -26,11 +26,6 @@ from helios.datatypes.djangofield import LDObjectField
import csv, copy
# global counters
GLOBAL_COUNTER_VOTERS = 'global_counter_voters'
GLOBAL_COUNTER_CAST_VOTES = 'global_counter_cast_votes'
GLOBAL_COUNTER_ELECTIONS = 'global_counter_elections'
class HeliosModel(models.Model, datatypes.LDObjectContainer):
class Meta:
abstract = True
......
......
......@@ -214,7 +214,7 @@ def one_election_schedule(request, election):
def one_election(request, election):
if not election:
raise Http404
return datatypes.LDObject.instantiate(election, datatype='legacy/Election')
return election.toJSONDict(complete=True)
@election_view()
def election_badge(request, election):
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment