Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] fixes + added twitter/facebook #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parltrack_meps/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

from django.contrib import admin

from memopol.reps.models import Party
#from memopol.reps.models import Party
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line then?

from .models import CountryMEP, GroupMEP, DelegationRole
from .models import Committee, Delegation, Country, Group, MEP, CommitteeRole
from .models import Committee, Delegation, Country, Group, Party, MEP, CommitteeRole

admin.site.register(Committee)
admin.site.register(CommitteeRole)
Expand Down
14 changes: 7 additions & 7 deletions parltrack_meps/management/commands/update_meps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
JSON_DUMP_LOCALIZATION = join("/tmp", "ep_meps_current.json")
_parse_date = lambda date: datetime.strptime(date, "%Y-%m-%dT00:%H:00")


def get_or_create(klass, _id=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are breaking pep8, this is bad #syntaxNatzi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be easely avoided with git add -p instead of plain git add ^^

if _id is None:
object = klass.objects.filter(**kwargs)
Expand All @@ -53,7 +52,6 @@ def get_or_create(klass, _id=None, **kwargs):
# print " add new", klass.__name__, kwargs
return klass.objects.create(**kwargs)


class Command(BaseCommand):
help = 'Update the eurodeputies data by pulling it from parltrack'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.


Expand Down Expand Up @@ -143,8 +141,9 @@ def add_addrs(mep, addrs):
mep.bxl_floor = bxl["Address"]["Office"][:2]
mep.bxl_office_number = bxl["Address"]["Office"][2:]
mep.bxl_fax = bxl.get("Fax")
mep.bxl_phone1 = bxl["Phone"]
mep.bxl_phone2 = bxl["Phone"][:-4] + "7" + bxl["Phone"][-3:]
mep.bxl_phone1 = bxl.get("Phone")
if mep.bxl_phone1:
mep.bxl_phone2 = bxl["Phone"][:-4] + "7" + bxl["Phone"][-3:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch bro !!

# print " add Strasbourg infos"
if addrs.get("Strasbourg"):
stg = addrs["Strasbourg"]
Expand Down Expand Up @@ -220,6 +219,8 @@ def change_mep_details(mep, mep_json):
# print " update mep birth place"
if "place" in mep_json["Birth"]:
mep.birth_place = mep_json["Birth"]["place"]
mep.twitter = mep_json.get("Twitter", [None])[0]
mep.facebook = mep_json.get("Facebook", [None])[0]
# print " update mep first name"
mep.first_name = mep_json["Name"]["sur"]
# print " update mep last name"
Expand Down Expand Up @@ -331,7 +332,6 @@ def add_assistants(mep, assistants):
assistant = get_or_create(Assistant, full_name=assistant)
get_or_create(AssistantMEP, mep=mep, assistant=assistant, type=type_name)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.


def manage_mep(mep, mep_json):
change_mep_details(mep, mep_json)
mep.committeerole_set.all().delete()
Expand Down Expand Up @@ -359,7 +359,7 @@ def add_missing_details(mep, mep_json):

def create_mep(mep_json):
mep = MEP()
mep.active = True
mep.active = mep_json["active"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it B)

change_mep_details(mep, mep_json)
add_missing_details(mep, mep_json)
if mep_json.get("Addresses"):
Expand All @@ -371,7 +371,7 @@ def create_mep(mep_json):
add_delegations(mep, mep_json.get("Delegations", []))
add_countries(mep, mep_json.get("Constituencies", []))
add_groups(mep, mep_json.get("Groups", []))
add_assistants(mep, mep_json.get("assistant", []))
add_assistants(mep, mep_json.get("assistants", []))
add_organizations(mep, mep_json.get("Staff", []))
if mep_json.get("Mail"):
add_mep_email(mep, mep_json["Mail"])
Expand Down
2 changes: 2 additions & 0 deletions parltrack_meps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ class MEP(models.Model):
birth_place = models.CharField(max_length=255)
active = models.BooleanField(default=False)
ep_id = models.IntegerField(unique=True)
twitter = models.CharField(max_length=140, null=True)
facebook = models.CharField(max_length=512, null=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

ep_opinions = models.URLField()
ep_debates = models.URLField()
ep_questions = models.URLField()
Expand Down