本文整理汇总了Python中django_fixmystreet.fixmystreet.models.FMSUser类的典型用法代码示例。如果您正苦于以下问题:Python FMSUser类的具体用法?Python FMSUser怎么用?Python FMSUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FMSUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.bxl = OrganisationEntity.objects.get(id=4)
self.manager_bxl = FMSUser(
is_active=True,
email="[email protected]",
telephone="0123456789",
last_used_language="fr",
manager=True,
organisation=self.bxl)
self.manager_bxl.set_password('test')
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.usergroupmembership = UserOrganisationMembership(user_id=self.manager_bxl.id, organisation_id=self.group.id, contact_user=True)
self.usergroupmembership.save()
self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
self.citizen.save()
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
self.client.login(username=self.manager_bxl.email, password='test')
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_bxl
)
self.report.save()
self.report.attachments.add(ReportComment(
text='test comment 1',
security_level=ReportComment.PRIVATE
))
self.client.logout()
self.report.attachments.add(ReportComment(
text='test comment 2',
security_level=ReportComment.PUBLIC
))
self.report.attachments.add(ReportComment(
text='test comment 3',
logical_deleted=True,
security_level=ReportComment.PUBLIC
))
self.client = Client()
示例2: 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()
示例3: setUp
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.manager.categories.add(ReportCategory.objects.get(pk=1))
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
}
示例4: setUp
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=4)
self.department = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=self.organisation,
email="[email protected]"
)
self.department.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.department.dispatch_categories.add(self.secondary_category)
self.usergroupmembership = UserOrganisationMembership(user=self.manager, organisation=self.department, contact_user=True)
self.usergroupmembership.save()
self.applicant_group = OrganisationEntity(
type="A",
name_nl="Belgacom",
name_fr="Belgacom",
phone="090987",
email="[email protected]"
)
self.applicant_group.save()
self.applicant = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.applicant.set_password('test')
self.applicant.save()
self.applicantmembership = UserOrganisationMembership(user=self.applicant, organisation=self.applicant_group, contact_user=True)
self.applicantmembership.save()
示例5: PhotosTest
class PhotosTest(FMSTestCase):
def setUp(self):
self.user = User.objects.create_user('test', '[email protected]e', '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()
示例6: handle
def handle(self, *args, **options):
from django_fixmystreet.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)
示例7: 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(
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.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.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()
示例8: 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
}
示例9: testAssignToImpetrantMail
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)
示例10: 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)
示例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)
示例12: setUp
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()
示例13: 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)
示例14: ExportPDFTest
class ExportPDFTest(SampleFilesTestCase):
def setUp(self):
self.bxl = OrganisationEntity.objects.get(id=4)
self.manager_bxl = FMSUser(
is_active=True,
email="[email protected]",
telephone="0123456789",
last_used_language="fr",
manager=True,
organisation=self.bxl)
self.manager_bxl.set_password('test')
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.usergroupmembership = UserOrganisationMembership(user_id=self.manager_bxl.id, organisation_id=self.group.id, contact_user=True)
self.usergroupmembership.save()
self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
self.citizen.save()
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
self.client.login(username=self.manager_bxl.email, password='test')
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_bxl
)
self.report.save()
self.report.attachments.add(ReportComment(
text='test comment 1',
security_level=ReportComment.PRIVATE
))
self.client.logout()
self.report.attachments.add(ReportComment(
text='test comment 2',
security_level=ReportComment.PUBLIC
))
self.report.attachments.add(ReportComment(
text='test comment 3',
logical_deleted=True,
security_level=ReportComment.PUBLIC
))
self.client = Client()
def test_pdf_attachment(self):
response = self.client.get(reverse('report_pdf', args=[self.report.id]) + '?output=html', follow=True)
self.assertEqual(response.status_code, 200)
self.assertIn('comments', response.context)
self.assertEqual(len(response.context['comments']), 1)
self.assertEqual(response.context['comments'][0].text, 'test comment 2')
self.assertEqual(response.context['privacy'], 'public')
def test_attachment_private(self):
self.assertTrue(self.client.login(username=self.manager_bxl.email, password='test'))
response = self.client.get(reverse('report_pdf_pro', args=[self.report.id]) + '?output=html', follow=True)
self.assertEqual(response.status_code, 200)
self.assertTrue(hasattr(response.context['request'], 'fmsuser'))
self.assertIn('comments', response.context)
self.assertEqual(len(response.context['comments']), 2)
self.assertEqual(response.context['comments'][0].text, 'test comment 1')
self.assertEqual(response.context['comments'][1].text, 'test comment 2')
self.assertEqual(response.context['privacy'], 'private')
def test_show_attachment(self):
response = self.client.get(reverse('report_show', kwargs={'report_id': self.report.id, 'slug': ''}), follow=True)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, 'test comment 1')
self.assertContains(response, 'test comment 2')
self.assertNotContains(response, 'test comment 3')
def test_show_attachment_private(self):
self.assertTrue(self.client.login(username=self.manager_bxl.email, password='test'))
response = self.client.get(reverse('report_show_pro', kwargs={'report_id': self.report.id, 'slug': ''}), follow=True)
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'test comment 1')
self.assertContains(response, 'test comment 2')
self.assertNotContains(response, 'test comment 3')
示例15: setUp
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)
self.impetrant = OrganisationEntity(
name_nl="MIVB",
name_fr="STIB",
#.........这里部分代码省略.........