Skip to content

Commit

Permalink
Merge pull request #1086 from yilmazbekdemir/issue-172
Browse files Browse the repository at this point in the history
Fix #172 - remove Contact model from workflow module
  • Loading branch information
Rafael Muñoz Cárdenas authored Apr 25, 2018
2 parents 43de2c1 + e3003e6 commit 7b8d9cb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 70 deletions.
12 changes: 0 additions & 12 deletions factories/workflow_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Budget as BudgetM,
Checklist as ChecklistM,
CodedField as CodedFieldM,
Contact as ContactM,
Country as CountryM,
Documentation as DocumentationM,
FundCode as FundCodeM,
Expand Down Expand Up @@ -78,17 +77,6 @@ class Meta:
code = 'AF'


class Contact(DjangoModelFactory):
class Meta:
model = ContactM

name = 'Aryana Sayeed'
city = 'Kabul'
email = lazy_attribute(lambda o: slugify(o.name) + "@external-contact.com")
phone = '+93 555444333'
country = SubFactory(Country)


class Organization(DjangoModelFactory):
class Meta:
model = OrganizationM
Expand Down
10 changes: 1 addition & 9 deletions workflow/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
WorkflowLevel2, WorkflowLevel2Sort, Documentation,
SiteProfile, ProjectType, Budget,
ProfileType, WorkflowTeam, ChecklistItem, Checklist,
Stakeholder, Contact, StakeholderType, TolaUser, TolaSites,
Stakeholder, StakeholderType, TolaUser, TolaSites,
FormGuidance, TolaUserProxy, TolaBookmarks, Currency,
ApprovalWorkflow, ApprovalType, FundCode, RiskRegister,
IssueRegister, CodedField, WorkflowModules, Milestone,
Expand Down Expand Up @@ -186,13 +186,6 @@ class ProjectTypeAdmin(admin.ModelAdmin):
display = 'Project Type'


class ContactAdmin(admin.ModelAdmin):
list_display = ('name', 'country', 'create_date', 'edit_date')
display = 'Contact'
list_filter = ('create_date','country')
search_fields = ('name','country','title','city')


class FundCodeAdmin(admin.ModelAdmin):
list_display = ('name', 'create_date', 'edit_date')
display = 'Fund Code'
Expand Down Expand Up @@ -305,7 +298,6 @@ class WorkflowLevel1SectorAdmin(admin.ModelAdmin):
admin.site.register(ChecklistItem, ChecklistItemAdmin)
admin.site.register(Checklist, ChecklistAdmin)
admin.site.register(Stakeholder, StakeholderAdmin)
admin.site.register(Contact, ContactAdmin)
admin.site.register(StakeholderType)
admin.site.register(TolaUser, TolaUserAdmin)
admin.site.register(TolaSites, TolaSitesAdmin)
Expand Down
64 changes: 64 additions & 0 deletions workflow/migrations/0023_auto_20180425_0136.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-04-25 08:36
from __future__ import unicode_literals

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

dependencies = [
('workflow', '0022_organization_allow_budget_decimal'),
]

operations = [
migrations.RemoveField(
model_name='contact',
name='country',
),
migrations.RemoveField(
model_name='contact',
name='organization',
),
migrations.RemoveField(
model_name='contact',
name='workflowlevel1',
),
migrations.RemoveField(
model_name='partner',
name='contact',
),
migrations.RemoveField(
model_name='stakeholder',
name='contact',
),
migrations.AlterField(
model_name='historicalworkflowlevel2',
name='level2_uuid',
field=models.CharField(blank=True, db_index=True, default=uuid.uuid4, editable=False, help_text='Unique ID', max_length=255, verbose_name='WorkflowLevel2 UUID'),
),
migrations.AlterField(
model_name='historicalworkflowlevel2',
name='progress',
field=models.CharField(blank=True, choices=[('open', 'Open'), ('awaitingapproval', 'Awaiting Approval'), ('tracking', 'Tracking'), ('inprogress', 'In Progress'), ('invoiced', 'Invoiced'), ('closed', 'Closed')], default='open', max_length=50),
),
migrations.AlterField(
model_name='workflowlevel1',
name='level1_uuid',
field=models.CharField(default=uuid.uuid4, editable=False, max_length=255, unique=True, verbose_name='WorkflowLevel1 UUID'),
),
migrations.AlterField(
model_name='workflowlevel2',
name='level2_uuid',
field=models.CharField(blank=True, default=uuid.uuid4, editable=False, help_text='Unique ID', max_length=255, unique=True, verbose_name='WorkflowLevel2 UUID'),
),
migrations.AlterField(
model_name='workflowlevel2',
name='progress',
field=models.CharField(blank=True, choices=[('open', 'Open'), ('awaitingapproval', 'Awaiting Approval'), ('tracking', 'Tracking'), ('inprogress', 'In Progress'), ('invoiced', 'Invoiced'), ('closed', 'Closed')], default='open', max_length=50),
),
migrations.DeleteModel(
name='Contact',
),
]
39 changes: 1 addition & 38 deletions workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,41 +957,6 @@ def __unicode__(self):
return new_name


class Contact(models.Model):
"""
A contact is a person or entity who may be approached for information or assistance about a Site.
Example: Building Maintenance Manager at a Training Center.
"""
name = models.CharField("Name", max_length=255, blank=True, null=True)
title = models.CharField("Title", max_length=255, blank=True, null=True)
city = models.CharField("City/Town", max_length=255, blank=True, null=True)
address = models.TextField("Address", max_length=255, blank=True, null=True)
email = models.CharField("Email", max_length=255, blank=True, null=True)
phone = models.CharField("Phone", max_length=255, blank=True, null=True)
country = models.ForeignKey(Country)
organization = models.ForeignKey(Organization, blank=True, null=True)
workflowlevel1 = models.ForeignKey(WorkflowLevel1, blank=True, null=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)

class Meta:
ordering = ('name', 'country', 'title')
verbose_name_plural = "Contact"

# onsave add create date or update edit date
def save(self, *args, **kwargs):
if self.create_date == None:
self.create_date = timezone.now()
self.edit_date = timezone.now()
super(Contact, self).save()

def __unicode__(self):
if self.title:
return u"{}, {}".format(self.name, self.title)
else:
return unicode(self.name)

class StakeholderType(models.Model):
name = models.CharField("Stakeholder Type", max_length=255, blank=True, null=True)
default_global = models.BooleanField(default=0)
Expand All @@ -1015,7 +980,7 @@ def __unicode__(self):

class StakeholderManager(models.Manager):
def get_queryset(self):
return super(StakeholderManager, self).get_queryset().prefetch_related('contact', 'sectors').select_related(
return super(StakeholderManager, self).get_queryset().prefetch_related('sectors').select_related(
'country', 'type', 'formal_relationship_document', 'vetting_document')


Expand All @@ -1035,7 +1000,6 @@ class Stakeholder(models.Model):
type = models.ForeignKey(StakeholderType, blank=True, null=True)
role = models.CharField("Role", max_length=255, blank=True, null=True)
contribution = models.CharField("Contribution", max_length=255, blank=True, null=True)
contact = models.ManyToManyField(Contact, max_length=255, blank=True)
country = models.ForeignKey(Country, blank=True, null=True)
organization = models.ForeignKey(Organization, default=1)
workflowlevel1 = models.ManyToManyField(WorkflowLevel1, blank=True)
Expand Down Expand Up @@ -1071,7 +1035,6 @@ class Partner(models.Model):
partners_uuid = models.CharField(max_length=255, verbose_name='Partner UUID', default=uuid.uuid4, unique=True)
name = models.CharField("Partner/Organization Name", max_length=255, blank=True, null=True)
type = models.ForeignKey(StakeholderType, blank=True, null=True, related_name="stakeholder_partner")
contact = models.ManyToManyField(Contact, max_length=255, blank=True)
country = models.ForeignKey(Country, blank=True, null=True)
sectors = models.ManyToManyField(Sector, blank=True)
organization = models.ForeignKey(Organization, default=1)
Expand Down
11 changes: 0 additions & 11 deletions workflow/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ def test_print_instance_without_code(self):
self.assertEqual(unicode(office), u'Office')


@tag('pkg')
class ContactTest(TestCase):
def test_print_instance(self):
contact = factories.Contact.build(title="Title")
self.assertEqual(unicode(contact), u'Aryana Sayeed, Title')

def test_print_instance_without_title(self):
contact = factories.Contact.build()
self.assertEqual(unicode(contact), u'Aryana Sayeed')


@tag('pkg')
class WorkflowLevel2Test(TestCase):
def test_print_instance(self):
Expand Down

0 comments on commit 7b8d9cb

Please sign in to comment.