当前位置: 首页>>代码示例>>Python>>正文


Python FMSUser.save方法代码示例

本文整理汇总了Python中django_fixmystreet.fixmystreet.models.FMSUser.save方法的典型用法代码示例。如果您正苦于以下问题:Python FMSUser.save方法的具体用法?Python FMSUser.save怎么用?Python FMSUser.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_fixmystreet.fixmystreet.models.FMSUser的用法示例。


在下文中一共展示了FMSUser.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PhotosTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class PhotosTest(FMSTestCase):

    def setUp(self):
        self.user = User.objects.create_user('test', '[email protected]', 'pwd')
        self.user.save()
        self.category = ReportMainCategoryClass.objects.all()[0]
        #Create a FMSUser
        self.fmsuser = FMSUser(telephone="0123456789", last_used_language="fr", agent=False, manager=False, leader=False, applicant=False, contractor=False)
        self.fmsuser.save()
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:11,代码来源:reports.py

示例2: ValueUpdate

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class ValueUpdate(FMSTestCase):

    def setUp(self):
        self.secondary_category = ReportCategory.objects.all()[0]
        self.category = self.secondary_category.category_class
        #Create a FMSUser
        self.etterbeek = OrganisationEntity.objects.get(id=5)  # postal code = 1040 Etterbeek
        self.etterbeek.save()
        self.bxl = OrganisationEntity.objects.get(id=4)  # postal code = 1000 Bxl
        self.bxl.save()
        self.manager_etterbeek = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr", manager=True, organisation=self.etterbeek)
        self.manager_etterbeek.save()
        self.manager_bxl = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr", manager=True, organisation=self.bxl)
        self.manager_bxl.save()
        self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
        self.citizen.save()
        self.client = Client()
        self.manager = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:31,代码来源:reports.py

示例3: test_previous_reports

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
 def test_previous_reports(self):
     self.client.login(username='[email protected]', password='test')
     manager2 = FMSUser(
         telephone="0123456789",
         last_used_language="fr",
         password='test',
         first_name="manager2",
         last_name="manager2",
         email="[email protected]",
         manager=True
     )
     manager2.set_password('test')
     manager2.organisation = self.organisation
     manager2.save()
     managerId = "manager_%s" % (manager2.id)
     self.client.post(reverse("report_change_manager_pro", args=[self.report.id])+"?manId="+managerId)
     self.assertEquals(len(self.manager.previous_reports.all()), 1)
     self.assertEquals(self.manager.previous_reports.all()[0].id, self.report.id)
     self.assertEquals(len(self.manager.reports_in_charge.all()), 0)
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:21,代码来源:updates.py

示例4: testAssignToImpetrantMail

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
    def testAssignToImpetrantMail(self):
        settings.CACHE_TIMEOUT = 0;

        response = self.client.post(reverse('report_new') + '?x=150056.538&y=170907.56', self.sample_post, follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertIn('report', response.context)
        report_id = response.context['report'].id
        self.assertEquals(len(mail.outbox), 2)  # one for creator subscription, one for manager

        # Add a worker for this entity
        worker = FMSUser(email="[email protected]", telephone="0123456789")
        worker.save()
        worker.memberships.create(organisation=self.impetrant)

        #Login to access the pro page
        self.client.login(username='[email protected]', password='test')
        #Publish the created report
        response = self.client.post(reverse('report_accept_pro', args=[report_id]), follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertEquals(len(mail.outbox), 3)
        response = self.client.get(reverse('report_change_contractor_pro', args=[report_id]) + '?contractorId=' + str(self.impetrant.id), {}, follow=True)

        self.assertEquals(response.status_code, 200)

        # Should be 6 mails: 2 for creation, 1 for acceptance and
        # 1 for assigning the issue to impetrant,
        # 1 to subcribers (user, not to manager because he comment)
        self.assertEquals(len(mail.outbox), 5)
        self.assertIn(self.impetrant.email, mail.outbox[3].to)
        self.assertIn(self.citizen.email, mail.outbox[4].to)
        #if the gestionnaire updates the report the impetrant should be informed by mail
        response = self.client.post(reverse('report_show_pro', kwargs={'report_id': report_id, 'slug': 'hello'}), {
            'comment-text': 'new created comment',
            'files-TOTAL_FORMS': 0,
            'files-INITIAL_FORMS': 0,
            'files-MAX_NUM_FORMS': 0
        }, follow=True)
        # One notification should be sent to impetrant to inform him of new comment
        # One notification should be sent to responsible demartment
        self.assertEquals(len(mail.outbox), 7)
        self.assertIn(self.impetrant.email, mail.outbox[5].to + mail.outbox[6].to)
        self.assertIn(self.group.email, mail.outbox[5].to + mail.outbox[6].to)
开发者ID:ppo,项目名称:django-fixmystreet,代码行数:44,代码来源:mail.py

示例5: test_assign_to_contractor_mail

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
    def test_assign_to_contractor_mail(self):
        response = self.client.post(reverse('report_new') + '?x=150056.538&y=170907.56', self.sample_post, follow=True)

        report             = response.context['report']
        report.accepted_at = datetime.now()
        report.save()

        # Add a worker for this entity
        worker = FMSUser(email="[email protected]", telephone="0123456789")
        worker.save()
        worker.memberships.create(organisation=self.contractor)

        # Reset outbox
        mail.outbox = []

        self.client.login(username='[email protected]', password='test')
        response = self.client.get(reverse('report_change_contractor_pro', args=[report.id]) + '?contractorId=' + str(self.contractor.id), {}, follow=True)

        # 1 mail sent in real time to contractor
        self.assertEquals(len(mail.outbox), 1)
        self.assertIn(self.contractor.email, mail.outbox[0].to)
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:23,代码来源:mail.py

示例6: test_assign_to_impetrant_mail

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
    def test_assign_to_impetrant_mail(self):
        response = self.client.post(reverse('report_new') + '?x=150056.538&y=170907.56', self.sample_post, follow=True)
        report   = response.context['report']

        # Add a worker for this entity
        worker = FMSUser(email="[email protected]", telephone="0123456789")
        worker.save()
        worker.memberships.create(organisation=self.impetrant)

        # Login to access the pro page
        self.client.login(username='[email protected]', password='test')

        # Publish the created report
        response = self.client.post(reverse('report_accept_pro', args=[report.id]), follow=True)

        # Reset outbox
        mail.outbox = []

        # Assign to another impetrant
        response = self.client.get(reverse('report_change_contractor_pro', args=[report.id]) + '?contractorId=' + str(self.impetrant.id), {}, follow=True)

        # 1 mail sent in real time to impetrant
        self.assertEquals(len(mail.outbox), 1)
        self.assertIn(self.impetrant.email, mail.outbox[0].to)
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:26,代码来源:mail.py

示例7: GroupsTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class GroupsTest(TestCase):

    fixtures = ["bootstrap", "list_items"]

    def setUp(self):
        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()

        self.leader = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="leader",
            last_name="leader",
            email="[email protected]",
            manager=True,
            leader=True
        )
        self.leader.set_password('test')
        self.leader.organisation = OrganisationEntity.objects.get(pk=14)
        self.leader.save()

        self.group1 = OrganisationEntity(
            name_fr="groupe1",
            name_nl="groep1",
            phone="00000000",
            email="[email protected]",
            type='D',
            dependency=OrganisationEntity.objects.get(pk=14)
        )
        self.group1.save()

        self.group2 = OrganisationEntity(
            name_fr="groupe2",
            name_nl="groep2",
            phone="00000000",
            email="[email protected]",
            type='D',
            dependency=OrganisationEntity.objects.get(pk=11)
        )
        self.group2.save()

        self.creategroup_post = {
            'name_fr': 'groupe3',
            'name_nl': 'groep3',
            'phone': '0000000000',
            'email': '[email protected]',
            'type': 'D'
        }

        self.creategroup_post2 = {
            'name_fr': 'groupe4',
            'name_nl': 'groep4',
            'phone': '0000000000',
            'email': '[email protected]',
            'type': 'S'
        }

        self.editgroup_post = {
            'name_fr': 'groupe1nouveau',
            'name_nl': 'groep1nieuw',
            'phone': '111111',
            'email': '[email protected]',
            'type': 'D'
        }
        self.editgroup_post2 = {
            'name_fr': 'groupe2nouveau',
            'name_nl': 'groep2nieuw',
            'phone': '2222222',
            'email': '[email protected]',
            'type': 'S'
        }

    def testListGroups(self):
        self.client.login(username='[email protected]', password='test')
        response = self.client.post(reverse('list_groups'), follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertTrue('groups' in response.context)
        self.assertTrue('can_create' in response.context)
        can_create = response.context['can_create']
        #This user should not be able to create
        groups = response.context['groups']
        self.assertFalse(can_create)
        #now check that all groups are groups of organisation should only be group1 as the other is assigned to other entity

        #check to see only your groups is back enabled
        self.assertEquals(groups.count(), 1)
        self.assertEquals(self.group1, groups[0])
#.........这里部分代码省略.........
开发者ID:ppo,项目名称:django-fixmystreet,代码行数:103,代码来源:groups.py

示例8: FMSUserTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class FMSUserTest(TestCase):

    fixtures = ["bootstrap", "list_items"]

    def setUp(self):
        self.user = User.objects.create_user('admin', '[email protected]', 'pwd')
        self.user.save()

        # these are from the fixtures file.
        self.category = ReportCategory.objects.all()[0]
        self.categoryclass = self.category.category_class

        self.commune = OrganisationEntity(name='test ward')
        #Create a FMSUser
        self.fmsuser = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            username="aaa",
            first_name="aaa",
            last_name="aaa",
            email="[email protected]")
        self.fmsuser.save()

    def testCreationOfFMSUser(self):
       '''Create a user and check if the row in database has been created'''
       self.assertTrue(self.fmsuser.id > 0)

    def testFMSCitizenOrProRole(self):
       '''Test the roles of the FMSUser created'''
       self.assertTrue(self.fmsuser.is_citizen())
       self.assertFalse(self.fmsuser.is_pro())
       self.fmsuser.agent = True
       self.assertFalse(self.fmsuser.is_citizen())
       self.assertTrue(self.fmsuser.is_pro())
       self.fmsuser.agent = False
       self.fmsuser.manager = True
       self.assertFalse(self.fmsuser.is_citizen())
       self.assertTrue(self.fmsuser.is_pro())
       self.fmsuser.manager = False
       self.fmsuser.leader = True
       self.assertFalse(self.fmsuser.is_citizen())
       self.assertTrue(self.fmsuser.is_pro())
       self.fmsuser.leader = False
       self.fmsuser.applicant = True
       self.assertFalse(self.fmsuser.is_citizen())
       self.assertTrue(self.fmsuser.is_pro())
       self.fmsuser.applicant = False
       self.fmsuser.contractor = True
       self.assertFalse(self.fmsuser.is_citizen())
       self.assertTrue(self.fmsuser.is_pro())
       self.fmsuser.contractor = False
       self.assertTrue(self.fmsuser.is_citizen())
       self.assertFalse(self.fmsuser.is_pro())

    def testFMSLanguage(self):
       '''Test the user language'''
       self.assertEquals(self.fmsuser.last_used_language, "fr")

    def testFMSSpecificRoles(self):
       '''Test the user roles boolean values'''
       self.assertFalse(self.fmsuser.agent)
       self.assertFalse(self.fmsuser.manager)
       self.assertFalse(self.fmsuser.leader)
       self.assertFalse(self.fmsuser.applicant)
       self.assertFalse(self.fmsuser.contractor)
开发者ID:ppo,项目名称:django-fixmystreet,代码行数:67,代码来源:users.py

示例9: UsersTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class UsersTest(FMSTestCase):

    def setUp(self):
        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()

        self.leader = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="leader",
            last_name="leader",
            email="[email protected]",
            manager=True,
            leader=True
        )
        self.leader.set_password('test')
        self.leader.organisation = OrganisationEntity.objects.get(pk=14)
        self.leader.save()
        self.createuser_post = {
            'telephone': '123456',
            'is_active': True,
            'first_name': 'david',
            'last_name': 'hasselhof',
            'email': '[email protected]'
        }
        self.edituser_post = {
            'telephone': '654321',
            'is_active': True,
            'first_name': 'new_manager',
            'last_name': 'new_manager',
            'email': '[email protected]',
            'manager': True
        }

    def testListUser(self):
        self.client.login(username='[email protected]', password='test')
        response = self.client.post(reverse('list_users'), follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertTrue('users' in response.context)
        self.assertTrue('can_create' in response.context)
        can_create = response.context['can_create']
        self.assertFalse(can_create)
        #This user should not be able to create
        users = response.context['users']
        self.assertEquals(users.count(), 2)
        self.assertIn(self.manager, users)
        self.assertIn(self.leader, users)
        #same result for leader
        self.client.logout()
        self.client.login(username='[email protected]', password='test')
        response = self.client.post(reverse('list_users'), follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertTrue('users' in response.context)
        self.assertTrue('can_create' in response.context)
        can_create = response.context['can_create']
        self.assertTrue(can_create)
        #This user should not be able to create
        users = response.context['users']
        self.assertEquals(users.count(), 2)
        self.assertIn(self.manager, users)
        self.assertIn(self.leader, users)

    def testCreateUser(self):
        self.client.login(username='[email protected]', password='test')
        response = self.client.post(reverse('create_user'), self.createuser_post, follow=True)
        self.assertEquals(response.status_code, 200)
        response = self.client.post(reverse('list_users'), follow=True)

        self.assertEquals(response.status_code, 200)
        self.assertTrue('users' in response.context)
        self.assertTrue('can_create' in response.context)
        can_create = response.context['can_create']
        users = response.context['users']
        self.assertTrue(can_create)
        self.assertEquals(users.count(), 3)
        self.assertContains(response, self.createuser_post["email"])

        new_user = FMSUser.objects.get(email=self.createuser_post['email'])
        self.assertTrue(new_user.password)
        self.assertNotEqual('!', new_user.password)
        self.assertEquals(len(mail.outbox), 1)

    def testUpdateLeaderAsLeader(self):
        self.client.login(username='[email protected]', password='test')
        response = self.client.post(reverse('edit_user', args=[self.leader.id]), self.edituser_post, follow=True)
        self.assertEquals(response.status_code, 200)
        self.assertTrue('can_edit' in response.context)
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:users.py

示例10: UpdatesTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class UpdatesTest(FMSTestCase):

    def setUp(self):
        self.client = Client()

        self.secondary_category = ReportCategory.objects.all()[0]
        self.category = self.secondary_category.category_class

        self.organisation = OrganisationEntity.objects.get(pk=14)
        self.organisation2 = OrganisationEntity.objects.get(pk=15)

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=self.organisation,
            email="[email protected]"
            )
        self.group.save()

        self.group_mail_config       = GroupMailConfig()
        self.group_mail_config.group = self.group
        self.group_mail_config.save()

        self.group2 = OrganisationEntity(
            type="D",
            name_nl="Werken2",
            name_fr="Travaux2",
            phone="090987",
            dependency=self.organisation2,
            email="[email protected]"
            )
        self.group2.save()

        self.group_mail_config2       = GroupMailConfig()
        self.group_mail_config2.group = self.group2
        self.group_mail_config2.save()

        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = self.organisation
        self.manager.save()

        self.manager2 = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager2",
            last_name="manager2",
            email="[email protected]",
            manager=True
        )
        self.manager2.set_password('test')
        self.manager2.organisation = self.organisation
        self.manager2.save()

        self.usergroupmembership = UserOrganisationMembership(user_id=self.manager.id, organisation_id=self.group.id, contact_user=True)
        self.usergroupmembership.save()

        self.usergroupmembership = UserOrganisationMembership(user_id=self.manager2.id, organisation_id=self.group2.id, contact_user=True)
        self.usergroupmembership.save()

        self.report = Report(
            status=Report.CREATED,
            secondary_category=self.secondary_category,
            category=self.category,
            description='Just a test',
            postalcode=1000,
            address='my address',
            point=dict_to_point({"x": '149776', "y": '170005'}),
            address_number='6h',
            created_by=self.manager,
            accepted_at=datetime.now()
        )
        self.report.save()

    def test_change_manager(self):
        """Tests manager change assigned to a report and test the view of it."""

        report = self.report
        report.responsible_department = self.group
        report.save()

        self.client.login(username='[email protected]', password='test')

        """Change manager department"""
        url = reverse('report_change_manager_pro', args=[report.id])
        response = self.client.get("{0}?manId=department_{1}".format(url, self.group2.id), follow=True)
        self.assertEqual(response.status_code, 200)
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:updates.py

示例11: ReportViewsTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class ReportViewsTest(FMSTestCase):

    def setUp(self):

        self.user = FMSUser(username='test1', email='[email protected]', password='test')
        self.user.save()

        self.client = Client()

        self.citizen = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            first_name="citizen",
            last_name="citizen",
            email="[email protected]"
        )
        self.citizen.save()

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=14),
            email="[email protected]"
            )
        self.group.save()

        self.group_mail_config       = GroupMailConfig()
        self.group_mail_config.group = self.group
        self.group_mail_config.save()

        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()
        self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))

        p1 = (148776, 171005)
        p2 = (150776, 171005)
        p3 = (150776, 169005)
        p4 = (148776, 169005)

        surface = OrganisationEntitySurface(
            geom=Polygon([p1, p2, p3, p4, p1]),
            owner=OrganisationEntity.objects.get(pk=14),
        )
        surface.save()

        self.manager.memberships.create(organisation=self.group, contact_user=True)

        self.sample_post = {
            'report-x': '150056.538',
            'report-y': '170907.56',
            'report-address_fr': 'Avenue des Arts, 3',
            'report-address_nl': 'Kunstlaan, 3',
            'report-address_number': '3',
            'report-postalcode': '1210',
            'report-category': '1',
            'report-secondary_category': '1',
            'report-subscription': 'on',
            'comment-text': 'test',
            'files-TOTAL_FORMS': 0,
            'files-INITIAL_FORMS': 0,
            'files-MAX_NUM_FORMS': 0,
            'citizen-email': self.citizen.email,
            'citizen-firstname': self.citizen.first_name,
            'citizen-lastname': self.citizen.last_name,
            'citizen-quality': '1',
            'report-terms_of_use_validated': True
        }
        self.sample_post_2 = {
            'report-x': '150056',
            'report-y': '170907.56',
            'report-address_fr': 'Avenue des Arts, 3',
            'report-address_nl': 'Kunstlaan, 3',
            'report-address_number': '5',
            'report-postalcode': '1210',
            'report-category': '1',
            'report-secondary_category': '1',
            'report-subscription': 'on',
            'comment-text': 'test2',
            'files-TOTAL_FORMS': 0,
            'files-INITIAL_FORMS': 0,
            'files-MAX_NUM_FORMS': 0,
            'citizen-email': self.citizen.email,
            'citizen-firstname': self.citizen.first_name,
            'citizen-lastname': self.citizen.last_name,
            'citizen-quality': '1',
            'report-terms_of_use_validated': True
        }
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:views.py

示例12: setUp

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
    def setUp(self):

        try:
            organisation = OrganisationEntity.objects.get(id=1)
        except ObjectDoesNotExist:
            organisation = OrganisationEntity(id=1, name="Test organisation")
            organisation.save()

        p1 = (148776, 171005)
        p2 = (150776, 171005)
        p3 = (150776, 169005)
        p4 = (148776, 169005)

        surface = OrganisationEntitySurface(
            geom=Polygon([p1, p2, p3, p4, p1]),
            owner=OrganisationEntity.objects.get(pk=14)
        )
        surface.save()

        #user_auth = User.objects.create_user(username='superuser', email='[email protected]', password='test')
        #user_auth.save()
        user = FMSUser(
            is_active=True,
            password="test",
            first_name="zaza",
            telephone="00000000",
            last_used_language="fr",
            organisation=organisation,
            username='superuser')
        user.save()

        #~ main_category = ReportMainCategoryClass(id=2,name_en='test main en',name_nl='test main nl',name_fr='test main fr')
        #~ main_category.save()
        #~
        #~ secondary_category = ReportSecondaryCategoryClass(id=2,name_en='test second en',name_nl='test second nl',name_fr='test second fr')
        #~ secondary_category.save()
        #~
        #~ category = ReportCategory(id=2,name_en='test parent en',name_nl='test parent nl',name_fr='test parent fr', public=True, category_class=main_category, secondary_category_class=secondary_category)
        #~ category.save()
        self.citizen = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            first_name="citizen",
            last_name="citizen",
            email="[email protected]"
        )
        self.citizen.save()

        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=14),
            email="[email protected]"
            )
        self.group.save()

        self.group_mail_config       = GroupMailConfig()
        self.group_mail_config.group = self.group
        self.group_mail_config.save()

        self.usergroupmembership = UserOrganisationMembership(user_id=self.manager.id, organisation_id=self.group.id, contact_user=True)
        self.usergroupmembership.save()

        self.sample_post = {
            'report-x': '150056.538',
            'report-y': '170907.56',
            'report-address_fr': 'Avenue des Arts, 3',
            'report-address_nl': 'Kunstlaan, 3',
            'report-address_number': '3',
            'report-postalcode': '1210',
            'report-category': '1',
            'report-secondary_category': '1',
            'report-subscription': 'on',
            'report-terms_of_use_validated': True,

            'comment-text': 'test',

            'files-TOTAL_FORMS': 0,
            'files-INITIAL_FORMS': 0,
            'files-MAX_NUM_FORMS': 1000,

            'citizen-quality': '1',
            'citizen-email': self.citizen.email,
            'citizen-firstname': self.citizen.first_name,
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:api.py

示例13: ReopenRequestTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class ReopenRequestTest(FMSTestCase):

    def setUp(self):
        self.citizen = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            first_name="citizen",
            last_name="citizen",
            email="[email protected]"
        )
        self.citizen.save()
        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=14),
            email="[email protected]"
            )
        self.group.save()
        self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))

        self.group_mail_config = GroupMailConfig()
        self.group_mail_config.group = self.group
        self.group_mail_config.save()

        self.manager.memberships.create(organisation=self.group, contact_user=True)

        self.client = Client()

        self.manager2 = FMSUser(
            is_active=True,
            telephone="9876543210",
            last_used_language="nl",
            password='test',
            first_name="manager2",
            last_name="manager2",
            email="[email protected]",
            manager=True
        )
        self.manager2.set_password('test2')
        self.manager2.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager2.save()

        self.group2 = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=21),
            email="[email protected]"
        )
        self.group2.save()
        self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=2))
        self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=1))

        p1 = (148776, 171005)
        p2 = (150776, 171005)
        p3 = (150776, 169005)
        p4 = (148776, 169005)

        surface = OrganisationEntitySurface(
            geom=Polygon([p1, p2, p3, p4, p1]),
            owner=OrganisationEntity.objects.get(pk=14),
        )
        surface.save()

        self.manager2.memberships.create(organisation=self.group2)

        self.manager3 = FMSUser(
            is_active=True,
            telephone="000000000",
            last_used_language="nl",
            password='test',
            first_name="manager3",
            last_name="manager3",
            email="[email protected]",
            manager=True
        )
        self.manager3.set_password('test3')
        self.manager3.organisation = OrganisationEntity.objects.get(pk=21)
        self.manager3.save()

        self.manager3.memberships.create(organisation=self.group2)

        self.impetrant = OrganisationEntity(
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:reopen_request.py

示例14: ListTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class ListTest(FMSTestCase):

    def setUp(self):
        self.secondary_category = ReportCategory.objects.all()[0]
        self.category = self.secondary_category.category_class

        self.bxl = OrganisationEntity.objects.get(id=4)  # postal code = 1000 Bxl
        self.bxl.save()

        p1 = (148776, 171005)
        p2 = (150776, 171005)
        p3 = (150776, 169005)
        p4 = (148776, 169005)

        surface = OrganisationEntitySurface(
            geom=Polygon([p1, p2, p3, p4, p1]),
            owner=self.bxl,
        )
        surface.save()

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=self.bxl,
            email="[email protected]"
        )
        self.group.save()

        self.group_mail_config       = GroupMailConfig()
        self.group_mail_config.group = self.group
        self.group_mail_config.save()

        self.agent = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr",
            agent=True,
            organisation=self.bxl)
        self.agent.save()

        self.stib = OrganisationEntity.objects.get(id=21)
        self.stib.dependency = self.bxl
        self.stib.save()

        self.contractor = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr",
            contractor=True,
            organisation=self.bxl)
        self.contractor.save()

        self.contractor_manager = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="90870870",
            last_used_language="fr",
            contractor=True,
            organisation=self.bxl,
            manager=True
        )
        self.contractor_manager.save()
        uom = UserOrganisationMembership(user=self.contractor_manager, organisation=self.group)
        uom.save()

        self.entity_manager = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="90870870",
            last_used_language="fr",
            leader=True,
            organisation=self.bxl,
            manager=True
        )
        self.entity_manager.save()
        self.usergroupmembership = UserOrganisationMembership(user_id = self.entity_manager.id, organisation_id = self.group.id)
        self.usergroupmembership.save()

        self.manager = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr",
            manager=True,
            organisation=self.bxl
        )
        self.manager.save()
        self.usergroupmembership2 = UserOrganisationMembership(user_id = self.manager.id, organisation_id = self.group.id, contact_user = True)
        self.usergroupmembership2.save()

        self.citizen = FMSUser(
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr"
        )
        self.citizen.save()
#.........这里部分代码省略.........
开发者ID:IMIO,项目名称:django-fixmystreet,代码行数:103,代码来源:lists.py

示例15: HistoryTest

# 需要导入模块: from django_fixmystreet.fixmystreet.models import FMSUser [as 别名]
# 或者: from django_fixmystreet.fixmystreet.models.FMSUser import save [as 别名]
class HistoryTest(TestCase):

    fixtures = ["bootstrap", "list_items"]

    def setUp(self):
        self.citizen = FMSUser(
            telephone="0123456789",
            last_used_language="fr",
            first_name="Fake first name",
            last_name="Fake last name",
            email="[email protected]"
        )
        self.citizen.save()
        self.citizen2 = FMSUser(
            telephone="9876543210",
            last_used_language="nl",
            first_name="Fake first name2",
            last_name="Fake last name2",
            email="[email protected]"
        )
        self.citizen2.save()
        self.citizen3 = FMSUser(
            telephone="5649783210",
            last_used_language="nl",
            first_name="Fake first name3",
            last_name="Fake last name3",
            email="[email protected]"
        )
        self.citizen3.save()

        self.manager = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            password='test',
            first_name="manager",
            last_name="manager",
            email="[email protected]",
            manager=True
        )
        self.manager.set_password('test')
        self.manager.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager.save()

        self.group = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=14),
            email="[email protected]"
            )
        self.group.save()
        self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))
        self.group.dispatch_categories.add(ReportCategory.objects.get(pk=2))

        self.manager.memberships.create(organisation=self.group, contact_user=True)

        self.manager2 = FMSUser(
            is_active=True,
            telephone="9876543210",
            last_used_language="nl",
            password='test',
            first_name="manager2",
            last_name="manager2",
            email="[email protected]",
            manager=True
        )
        self.manager2.set_password('test2')
        self.manager2.organisation = OrganisationEntity.objects.get(pk=14)
        self.manager2.save()

        self.manager2.memberships.create(organisation=self.group)

        self.manager3 = FMSUser(
            is_active=True,
            telephone="000000000",
            last_used_language="nl",
            password='test',
            first_name="manager3",
            last_name="manager3",
            email="[email protected]",
            manager=True
        )
        self.manager3.set_password('test3')
        self.manager3.organisation = OrganisationEntity.objects.get(pk=21)
        self.manager3.save()

        self.group2 = OrganisationEntity(
            type="D",
            name_nl="Werken",
            name_fr="Travaux",
            phone="090987",
            dependency=OrganisationEntity.objects.get(pk=21),
            email="[email protected]"
            )
        self.group2.save()
        self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=1))

        self.manager3.memberships.create(organisation=self.group2)
#.........这里部分代码省略.........
开发者ID:ppo,项目名称:django-fixmystreet,代码行数:103,代码来源:history.py


注:本文中的django_fixmystreet.fixmystreet.models.FMSUser.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。