def handle(self, **options):
     with transaction.atomic():
         split_url = urlsplit(options['SITE-URL'])
         if (split_url.path not in ('', '/') \
             or split_url.query
             or split_url.fragment):
             raise CommandError('You must only supply the base URL of the site')
         # Then form the base API URL:
         new_url_parts = list(split_url)
         new_url_parts[2] = ''
         self.base_url = urlunsplit(new_url_parts)
         new_url_parts[2] = '/api/v0.9/'
         self.base_api_url = urlunsplit(new_url_parts)
         self.check_database_is_empty()
         self.mirror_from_api()
 def handle(self, **options):
     with transaction.atomic():
         split_url = urlsplit(options['SITE-URL'])
         if (split_url.path not in ('', '/') \
             or split_url.query
             or split_url.fragment):
             raise CommandError('You must only supply the base URL of the site')
         # Then form the base API URL:
         new_url_parts = list(split_url)
         new_url_parts[2] = ''
         self.base_url = urlunsplit(new_url_parts)
         new_url_parts[2] = '/api/v0.9/'
         self.base_api_url = urlunsplit(new_url_parts)
         self.check_database_is_empty()
         self.remove_field_objects()
         self.mirror_from_api()
Beispiel #3
0
 def item_extra_kwargs(self, o):
     user_id = None
     if o.user:
         user_id = o.user.id
     image_url = o.image_url_path
     if image_url:
         # FIXME: this is just assuming 'https' as the protocol and
         # that the current site has a correct domain at the moment,
         # since this class doesn't have access to the request object.
         image_url = urlunsplit(
             ("https", Site.objects.get_current().domain, image_url, "", "")
         )
     return {
         "retraction": int(o.retraction),
         "election_slug": o.election.slug,
         "election_name": o.election.name,
         "election_date": o.election.election_date,
         "post_id": o.post.slug if o.post else o.old_post_id,
         "winner_person_id": o.winner.id,
         "winner_person_name": o.winner.name,
         "winner_party_id": o.winner_party.legacy_slug,
         "winner_party_name": o.winner_party.name,
         "user_id": user_id,
         "post_name": o.short_post_name,
         "information_source": o.source,
         "image_url": image_url,
         "parlparse_id": o.parlparse_id,
     }
Beispiel #4
0
 def item_extra_kwargs(self, o):
     user_id = None
     if o.user:
         user_id = o.user.id
     image_url = o.image_url_path
     if image_url:
         # FIXME: this is just assuming 'https' as the protocol and
         # that the current site has a correct domain at the moment,
         # since this class doesn't have access to the request object.
         image_url = urlunsplit(
             ('https', Site.objects.get_current().domain, image_url, '', ''))
     return {
         'retraction': int(o.retraction),
         'election_slug': o.election.slug,
         'election_name': o.election.name,
         'election_date': o.election.election_date,
         'post_id': o.post.extra.slug if o.post else o.old_post_id,
         'winner_person_id': o.winner.id,
         'winner_person_name': o.winner.name,
         'winner_party_id': o.winner_party.extra.slug,
         'winner_party_name': o.winner_party.name,
         'user_id': user_id,
         'post_name': o.short_post_name,
         'information_source': o.source,
         'image_url': image_url,
         'parlparse_id': o.parlparse_id,
     }
 def handle(self, **options):
     with transaction.atomic():
         split_url = urlsplit(options["SITE-URL"])
         if (
             split_url.path not in ("", "/")
             or split_url.query
             or split_url.fragment
         ):
             raise CommandError(
                 "You must only supply the base URL of the site"
             )
         # Then form the base API URL:
         new_url_parts = list(split_url)
         new_url_parts[2] = ""
         self.base_url = urlunsplit(new_url_parts)
         new_url_parts[2] = "/api/"
         self.base_api_url = urlunsplit(new_url_parts)
         self.check_database_is_empty()
         self.mirror_from_api(ignore_images=options["ignore_images"])
         call_command("parties_update_current_candidates")