-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
b6f0e89
f145ec9
9e8c63a
ada5610
754ee30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are breaking pep8, this is bad #syntaxNatzi There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
|
||
|
@@ -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:] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"] | ||
|
@@ -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" | ||
|
@@ -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) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
@@ -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"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"): | ||
|
@@ -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"]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💃 |
||
ep_opinions = models.URLField() | ||
ep_debates = models.URLField() | ||
ep_questions = models.URLField() | ||
|
There was a problem hiding this comment.
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?