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


Python FMSUser.save方法代码示例

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


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

示例1: test_citizen_form_update

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
    def test_citizen_form_update(self):
        my_user = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="nl",
            password='test',
            first_name="my_user",
            last_name="my_user",
            email="[email protected]",
            manager=False
        )
        my_user.save()

        #Change values
        citizen_data = {
            "email"    : "[email protected]",
            "last_name": "user modified",
            "telephone": "987654321",
            "quality"  : 2
        }
        citizen_form = CitizenForm(citizen_data)
        self.assertTrue(citizen_form.is_valid())
        citizen_form.save()

        my_user = FMSUser.objects.filter(username__iexact=citizen_data['email']).get()

        self.assertEqual(my_user.last_name, citizen_data["last_name"])
        self.assertEqual(my_user.telephone, citizen_data["telephone"])
        self.assertEqual(my_user.quality, citizen_data["quality"])
        self.assertEqual(my_user.last_used_language, "fr")
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:32,代码来源:test_users.py

示例2: test_citizen_with_pro_email

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
    def test_citizen_with_pro_email(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
        )
        manager.save()

        citizen_data = {
            "email"    : manager.email,
            "last_name": "user",
            "telephone": "123456789",
            "quality"  : 1
        }

        # Create a citizen user
        citizen_form = CitizenForm(citizen_data)

        # Form has to be INVALID because the citizen use a pro email
        self.assertFalse(citizen_form.is_valid())
        self.assertTrue(citizen_form.errors)
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:28,代码来源:test_users.py

示例3: PhotosTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:arnemutab,项目名称:django-fixmystreet,代码行数:18,代码来源:test_reports.py

示例4: test_previous_reports

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:CIRB,项目名称:django-fixmystreet,代码行数:21,代码来源:test_updates.py

示例5: test_assign_to_contractor_mail

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:arnemutab,项目名称:django-fixmystreet,代码行数:23,代码来源:test_mail.py

示例6: ReportProViewsTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
class ReportProViewsTest(FMSTestCase):
    def setUp(self):
        self.user = User.objects.create_user(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.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.super_user = FMSUser(
            is_active=True,
            telephone="0123456789",
            last_used_language="fr",
            first_name="superuser",
            last_name="superuser",
            email="[email protected]",
        )
        self.super_user.set_password("test")
        self.super_user.is_superuser = True
        self.super_user.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",
            "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,
        }
开发者ID:arnemutab,项目名称:django-fixmystreet,代码行数:62,代码来源:test_views.py

示例7: test_pro_with_citizen_email

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
    def test_pro_with_citizen_email(self):
        citizen = FMSUser(
            telephone="0123456789",
            first_name="citizen",
            last_name="citizen",
            email="[email protected]",
        )
        citizen.save()

        pro_data = {
            "email"    : citizen.email,
            "last_name": "user",
            "telephone": "123456789",
            "quality"  : 1
        }

        # Create a pro user
        pro_form = FmsUserForm(pro_data)

        # Form has to be INVALID because a citizen uses this email
        self.assertFalse(pro_form.is_valid())
        self.assertTrue(pro_form.errors)
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:24,代码来源:test_users.py

示例8: test_assign_to_impetrant_mail

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:arnemutab,项目名称:django-fixmystreet,代码行数:26,代码来源:test_mail.py

示例9: ValueUpdate

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:arnemutab,项目名称:django-fixmystreet,代码行数:38,代码来源:test_reports.py

示例10: ReportViewsTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:CIRB,项目名称:django-fixmystreet,代码行数:103,代码来源:test_views.py

示例11: UsersTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:CIRB,项目名称:django-fixmystreet,代码行数:103,代码来源:test_users.py

示例12: NotificationTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
class NotificationTest(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()

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

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

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

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

        self.manager_etterbeek = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr",
            manager=True,
            organisation=self.etterbeek,
        )
        self.manager_etterbeek.save()
        self.manager_bxl = FMSUser(
            is_active=True,
            email="[email protected]",
            telephone="0123456789",
            last_used_language="fr",
            manager=True,
            organisation=self.bxl,
        )
        self.manager_bxl.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.usergroupmembership = UserOrganisationMembership(
            user_id=self.manager_bxl.id, organisation_id=self.group.id, contact_user=True
        )
        self.usergroupmembership.save()

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

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

        self.usergroupmembership2 = UserOrganisationMembership(
            user_id=self.manager_etterbeek.id, organisation_id=self.group2.id, contact_user=True
        )
        self.usergroupmembership2.save()
        self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
        self.citizen.save()

    def testReportFileType(self):
        new_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": "170105"}),
            address_number="6h",
            created_by=self.manager_etterbeek,
        )
        new_report.save()

        reportFile = ReportFile(file_type=ReportFile.PDF, report=new_report)
        self.assertTrue(reportFile.is_pdf())
        self.assertFalse(reportFile.is_word())
        self.assertFalse(reportFile.is_excel())
        self.assertFalse(reportFile.is_image())
        self.assertTrue(reportFile.is_document())
#.........这里部分代码省略.........
开发者ID:arnemutab,项目名称:django-fixmystreet,代码行数:103,代码来源:test_reports.py

示例13: FMSUserTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
class FMSUserTest(FMSTestCase):
    def setUp(self):
        # 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)

    def test_double_citizen_case_insensitive(self):
        citizen_data = {"email": "[email protected]", "last_name": "user", "telephone": "123456789", "quality": 1}

        # Create first citizen
        citizen_form = CitizenForm(citizen_data)

        # Form has to be valid
        self.assertTrue(citizen_form.is_valid())
        citizen_form.save()

        # Create second citizen with a caps in email
        citizen_data["email"] = citizen_data["email"].upper()
        citizen_form = CitizenForm(citizen_data)

        # Form has to be valid
        self.assertTrue(citizen_form.is_valid())
        citizen_form.save()

        # And only one user with the same email case insensitive is created (it's the same citizen in both cases)
        self.assertEqual(1, FMSUser.objects.filter(username__iexact=citizen_data["email"]).count())

    def test_citizen_with_pro_email(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,
        )
        manager.save()

        citizen_data = {"email": manager.email, "last_name": "user", "telephone": "123456789", "quality": 1}

        # Create a citizen user
        citizen_form = CitizenForm(citizen_data)

        # Form has to be INVALID because the citizen use a pro email
        self.assertFalse(citizen_form.is_valid())
        self.assertTrue(citizen_form.errors)
开发者ID:arnemutab,项目名称:django-fixmystreet,代码行数:100,代码来源:test_users.py

示例14: ReopenRequestTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.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:,项目名称:,代码行数:103,代码来源:

示例15: GroupsTest

# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import save [as 别名]
class GroupsTest(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.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.group_mail_config1       = GroupMailConfig()
        self.group_mail_config1.group = self.group1
        self.group_mail_config1.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.group_mail_config2       = GroupMailConfig()
        self.group_mail_config2.group = self.group2
        self.group_mail_config2.save()

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

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

        self.editgroup_post = {
            'name_fr': 'groupe1nouveau',
            'name_nl': 'groep1nieuw',
            'phone': '111111',
            'email': '[email protected]',
            'type': 'D',

            ### Mail Config ###
            'groupmailconfig-TOTAL_FORMS'   : u'1',
            'groupmailconfig-INITIAL_FORMS' : u'1',
            'groupmailconfig-MAX_NUM_FORMS' : u'1',

            'groupmailconfig-0-notify_group'      : True,
            'groupmailconfig-0-notify_members'    : True,
            'groupmailconfig-0-digest_created'    : True,
            'groupmailconfig-0-digest_inprogress' : True,
            'groupmailconfig-0-digest_closed'     : True,
            'groupmailconfig-0-digest_other'      : True,
        }
        self.editgroup_post2 = {
            'name_fr': 'groupe2nouveau',
            'name_nl': 'groep2nieuw',
#.........这里部分代码省略.........
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:103,代码来源:test_groups.py


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