from modularodm import fields

from framework.mongo import (
    ObjectId,
    StoredObject,
    utils as mongo_utils
)


@mongo_utils.unique_on(['id', '_id'])
class Subject(StoredObject):
    _id = fields.StringField(primary=True, default=lambda: str(ObjectId()))
    type = fields.StringField(required=True)
    text = fields.StringField(required=True)
    parent_ids = fields.StringField(list=True)

    def get_absolute_url(self):
        return '{}taxonomies/?filter[id]={}'.format(self.absolute_api_v2_url, self._id)

@@ -114,16 +114,52 @@
 tils%0A)%0A%0A
+from website.util import api_v2_url%0A
 %0A@mongo_
@@ -180,17 +180,12 @@
 n(%5B'
-id', '_id
+text
 '%5D)%0A
@@ -298,11 +298,11 @@
    t
-ype
+ext
  = f
@@ -334,28 +334,31 @@
 d=True)%0A    
-text
+parents
  = fields.St
@@ -359,82 +359,57 @@
 lds.
-StringField(required
+ForeignField('subject', list
 =True)%0A
+%0A
     
-parent_ids = fields.StringField(list=True)%0A
+@property
 %0A   
@@ -417,12 +417,8 @@
 def 
-get_
 abso
@@ -422,16 +422,23 @@
 bsolute_
+api_v2_
 url(self
@@ -459,36 +459,34 @@
 urn 
-'%7B%7Dtaxonomies/?filter%5Bid%5D=
+api_v2_url('taxonomies/
 %7B%7D
+/
 '.fo
@@ -495,16 +495,75 @@
 at(self.
+_id))%0A%0A    def get_absolute_url(self):%0A        return self.
 absolute
@@ -577,16 +577,5 @@
 _url
-, self._id)
 %0A

Update Subject model -remove superfluous type field -fix parents field type -update url building