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


Python models.FMSUser类代码示例

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


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

示例1: setUp

 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,代码行数:35,代码来源:test_reports.py

示例2: test_citizen_with_pro_email

    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,代码行数:26,代码来源:test_users.py

示例3: ReportProViewsTest

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,代码行数:60,代码来源:test_views.py

示例4: test_citizen_form_update

    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,代码行数:30,代码来源:test_users.py

示例5: handle

    def handle(self, *args, **options):
        from apps.fixmystreet.models import GroupMailConfig, OrganisationEntity, ReportEventLog, UserOrganisationMembership

        # Date of yesterday (or specific date)
        if options['date']:
            YESTERDAY = datetime.datetime.strptime(options['date'], "%d/%m/%Y").date()
        else:
            YESTERDAY = datetime.date.today() - datetime.timedelta(days=1)

        logger.info('DIGEST OF NOTIFICATIONS FOR ACTVITIES OF %s' % YESTERDAY)

        # All group mail configurations with at least 1 digest config
        group_mail_configs = GroupMailConfig.objects.filter(group__type=OrganisationEntity.DEPARTMENT).filter(Q(digest_closed=True) | Q(digest_created=True) | Q(digest_inprogress=True) | Q(digest_other=True))
        logger.info('group_mail_configs %s' % group_mail_configs)

        # All group having digest config
        groups = group_mail_configs.values_list('group', flat=True)
        logger.info('groups %s' % groups)

        # All events of yesterday related to groups
        events_yesterday = ReportEventLog.objects.filter(event_at__contains=YESTERDAY, report__responsible_department__in=groups)
        logger.info('events_yesterday %s' % events_yesterday)

        for mail_config in group_mail_configs:
            group = mail_config.group

            # Returns all activities of yesterday grouped by reports where and related to group
            activities_list = events_yesterday.filter(report__responsible_department=group)

            if not activities_list:
                continue

            # Send digest to responsibles according to mail config
            recipients = mail_config.get_manager_recipients()

            logger.info('Digest of %s %s' % (group, recipients))
            logger.info('   Number of activities: %s' % activities_list.count())

            for activity in activities_list:
                logger.info('   %s %s %s' % (activity.event_at, activity.report.id, activity))

            # If NOT option send, do not send email
            if not options['send']:
                continue

            for recipient in recipients:
                # Because recipients are email and can be a user or group email, have to mock a user
                user = FMSUser()
                user.email = recipient
                user.is_pro = lambda: True
                user.last_used_language = "fr"

                # Render and send the digest by mail
                send_digest(user, activity, activities_list, YESTERDAY)
开发者ID:,项目名称:,代码行数:54,代码来源:

示例6: PhotosTest

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,代码行数:16,代码来源:test_reports.py

示例7: setUp

    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
        }
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:44,代码来源:test_users.py

示例8: setUp

 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()
开发者ID:CIRB,项目名称:django-fixmystreet,代码行数:10,代码来源:test_users.py

示例9: test_assign_to_contractor_mail

    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,代码行数:21,代码来源:test_mail.py

示例10: test_pro_with_citizen_email

    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,代码行数:22,代码来源:test_users.py

示例11: test_assign_to_impetrant_mail

    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,代码行数:24,代码来源:test_mail.py

示例12: test_previous_reports

 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,代码行数:19,代码来源:test_updates.py

示例13: setUp

    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,代码行数:98,代码来源:test_views.py

示例14: ReportViewsTest

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,代码行数:101,代码来源:test_views.py

示例15: UsersTest

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,代码行数:101,代码来源:test_users.py


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