Esempio n. 1
0
 def add_doc(self, text, meta, labels, updated=None, priority=None):
     from api.models import Document
     doc = Document(text=text, meta=meta, project=self.project)
     if updated is not None:
         doc.updated_at = updated
     if priority is not None:
         doc.priority = priority
     doc.save()
     self._set_annotations(doc, labels)
Esempio n. 2
0
 def add_doc(self, text, meta, labels):
     from api.models import Document, SequenceAnnotation
     doc = Document(text=text, meta=meta, project=self.project)
     doc.save()
     for (start, end, label) in labels:
         sa = SequenceAnnotation(start_offset=start,
                                 end_offset=end,
                                 document=doc,
                                 user=self.admin)
         sa.label = self.label_by_name[label]
         sa.save()
Esempio n. 3
0
 def setUp(self):
     d = Document()
     dep = Department()
     try:
         dep.name = 'NIH'
         dep.save()
     except:
         self.fail('Department could not be saved!')
     try:
         d.title = 'Correlations within Causations'
         d.institution = 'COS'
         d.pifirstname = 'Foo'
         d.pilastname = 'Bar'
         d.piemail = '*****@*****.**'
         d.status = 'Pending'
         d.datepublished = datetime.datetime.now()  # update this to use datetime
         d.filelink = '~/doc.txt'
         d.department = dep
         d.save()
     except:
         self.fail('Document could not be saved!')
Esempio n. 4
0
 def setUp(self):
     d = Document()
     dep = Department()
     try:
         dep.name = 'NIH'
         dep.save()
     except:
         self.fail('Department could not be saved!')
     try:
         d.title = 'Correlations within Causations'
         d.institution = 'COS'
         d.pifirstname = 'Foo'
         d.pilastname = 'Bar'
         d.piemail = '*****@*****.**'
         d.status = 'Pending'
         d.datepublished = datetime.datetime.now(
         )  # update this to use datetime
         d.filelink = '~/doc.txt'
         d.department = dep
         d.save()
     except:
         self.fail('Document could not be saved!')
Esempio n. 5
0
d1 = Department(name="DOE")
d1.save()
d2 = Department(name="DOD")
d2.save()

u1 = User.objects.create_user(username="******", password="******")
u1.save()
u1type = Usertype(user=u1, usertype="moderator", department=d1)
u1type.save()
u1.groups.add(moderators)

u2 = User.objects.create_user(username="******", password="******")
u2.save()
u2type = Usertype(user=u2, usertype="researcher", department=d2)
u2type.save()
u2.groups.add(researchers)

doc1 = Document(date_published="2016-12-20 00:00", title="DOEdoc", publisher="blah", institution="blah", status="unread", file_link="blah", PI_first_name="first",
    PI_last_name="last", PI_email="*****@*****.**", author_list="1, 2, 3", department=d1)
doc1.save()

#Should all print true
u1.has_perm("api.change_document")
u1.has_perm("api.view_grant")
u2.has_perm("api.add_document")

#Should all print false
u1.has_perm("api.change_department")
u2.has_perm("view_document")
u2.has_perm("delete_document")
Esempio n. 6
0
u1.groups.add(moderators)

u2 = User.objects.create_user(username="******", password="******")
u2.save()
u2type = Usertype(user=u2, usertype="researcher", department=d2)
u2type.save()
u2.groups.add(researchers)

doc1 = Document(date_published="2016-12-20 00:00",
                title="DOEdoc",
                publisher="blah",
                institution="blah",
                status="unread",
                file_link="blah",
                PI_first_name="first",
                PI_last_name="last",
                PI_email="*****@*****.**",
                author_list="1, 2, 3",
                department=d1)
doc1.save()

#Should all print true
u1.has_perm("api.change_document")
u1.has_perm("api.view_grant")
u2.has_perm("api.add_document")

#Should all print false
u1.has_perm("api.change_department")
u2.has_perm("view_document")
u2.has_perm("delete_document")