def setUp(self): instance = make_instance() self.creator_user = make_officer_user(instance) self.admin_user = make_admin_user(instance) self.other_user = make_officer_user(instance, username='******') self.plot = Plot(geom=instance.center, instance=instance) self.plot.save_with_user(self.creator_user) self.tree = Tree(plot=self.plot, instance=instance) self.tree.save_with_user(self.creator_user) self.rainBarrel = RainBarrel(geom=instance.center, instance=instance, capacity=5) self.rainBarrel.save_with_user(self.creator_user)
def setUp(self): self.p1 = Point(-7615441.0, 5953519.0) self.instance = make_instance(point=self.p1) self.commander_user = make_commander_user(self.instance) self.direct_user = make_officer_user(self.instance) self.pending_user = make_apprentice_user(self.instance) self.observer_user = make_observer_user(self.instance) self.plot = Plot(geom=self.p1, instance=self.instance, length=5.0) self.plot.save_with_user(self.commander_user)
def setUp(self): self.p1 = Point(-7615441.0, 5953519.0) self.instance = make_instance(point=self.p1) self.commander_user = make_commander_user(self.instance) self.direct_user = make_officer_user(self.instance) self.pending_user = make_apprentice_user(self.instance) self.observer_user = make_observer_user(self.instance) self.outlaw_user = make_user_with_default_role(self.instance, 'outlaw') self.tweaker_user = make_tweaker_user(self.instance) self.conjurer_user = make_conjurer_user(self.instance)
def setUp(self): self.p1 = Point(-8515941.0, 4953519.0) self.instance = make_instance(point=self.p1) self.commander = make_commander_user(self.instance) self.officer = make_officer_user(self.instance) self.observer = make_observer_user(self.instance) self.outlaw = make_user_with_default_role(self.instance, 'outlaw') self.plot = Plot(geom=self.p1, instance=self.instance) self.plot.save_with_user(self.officer) self.tree = Tree(plot=self.plot, instance=self.instance) self.tree.save_with_user(self.officer)
def setUp(self): self.p1 = Point(-7615441.0, 5953519.0) self.instance = make_instance(point=self.p1) self.commander = make_commander_user(self.instance) self.privileged_user = make_officer_user(self.instance) self.unprivileged_user = make_apprentice_user(self.instance) self.plot = Plot(geom=self.p1, instance=self.instance) self.plot.save_with_user(self.commander) rm = ReputationMetric(instance=self.instance, model_name='Tree', action=Audit.Type.Insert, direct_write_score=2, approval_score=20, denial_score=5) rm.save()
def setUp(self): instance = make_instance() # Fancy name, but no write, create, or delete permissions instance.default_role.name = Role.ADMINISTRATOR self.creator_user = make_officer_user(instance) self.admin_user = make_admin_user(instance) self.other_user = make_observer_user(instance, username='******') self.tweaker_user = make_tweaker_user(instance) self.conjurer_user = make_conjurer_user(instance) self.plot = Plot(geom=instance.center, instance=instance) self.plot.save_with_user(self.creator_user) self.tree = Tree(plot=self.plot, instance=instance) self.tree.save_with_user(self.creator_user) self.rainBarrel = RainBarrel(geom=instance.center, instance=instance, capacity=5) self.rainBarrel.save_with_user(self.creator_user)
def test_mask_unauthorized_with_udfs(self): officer_user = make_officer_user(self.instance) self.plot.udfs['Test choice'] = 'b' self.plot.save_with_user(self.commander_user) self.plot.udfs['Test unauth'] = 'foo' self.plot.save_base() newplot = Plot.objects.get(pk=self.plot.pk) self.assertEqual(newplot.udfs['Test choice'], 'b') self.assertEqual(newplot.udfs['Test unauth'], 'foo') newplot = Plot.objects.get(pk=self.plot.pk) newplot.mask_unauthorized_fields(self.commander_user) self.assertEqual(newplot.udfs['Test choice'], 'b') self.assertEqual(newplot.udfs['Test unauth'], None) newplot = Plot.objects.get(pk=self.plot.pk) newplot.mask_unauthorized_fields(officer_user) self.assertEqual(newplot.udfs['Test choice'], None) self.assertEqual(newplot.udfs['Test unauth'], None)
def test_mask_unauthorized_with_udfs(self): officer_user = make_officer_user(self.instance) self.plot.udfs["Test choice"] = "b" self.plot.save_with_user(self.commander_user) self.plot.udfs["Test unauth"] = "foo" self.plot.save_base() newplot = Plot.objects.get(pk=self.plot.pk) self.assertEqual(newplot.udfs["Test choice"], "b") self.assertEqual(newplot.udfs["Test unauth"], "foo") newplot = Plot.objects.get(pk=self.plot.pk) newplot.mask_unauthorized_fields(self.commander_user) self.assertEqual(newplot.udfs["Test choice"], "b") self.assertEqual(newplot.udfs["Test unauth"], None) newplot = Plot.objects.get(pk=self.plot.pk) newplot.mask_unauthorized_fields(officer_user) self.assertEqual(newplot.udfs["Test choice"], None) self.assertEqual(newplot.udfs["Test unauth"], None)