def set_entries(self, podcasts): """ Updates the list to include the given podcast, removes others """ existing = {e.content_object: e for e in self.entries.all()} set_ordered_entries( self, podcasts, existing, PodcastListEntry, 'content_object', 'podcastlist' )
def set_urls(self, urls): """Update the object's URLS to the given list 'urls' should be a list of strings. Slugs that do not exist are created. Existing urls that are not in the 'urls' list are deleted.""" urls = [utils.to_maxlength(URL, "url", url) for url in urls] existing = {u.url: u for u in self.urls.all()} utils.set_ordered_entries(self, urls, existing, URL, "url", "content_object")
def set_slugs(self, slugs): """Update the object's slugs to the given list 'slugs' should be a list of strings. Slugs that do not exist are created. Existing slugs that are not in the 'slugs' list are deleted.""" slugs = [utils.to_maxlength(Slug, "slug", slug) for slug in slugs] existing = {s.slug: s for s in self.slugs.all()} utils.set_ordered_entries(self, slugs, existing, Slug, "slug", "content_object")
def set_urls(self, urls): """ Update the object's URLS to the given list 'urls' should be a list of strings. Slugs that do not exist are created. Existing urls that are not in the 'urls' list are deleted. """ urls = [utils.to_maxlength(URL, 'url', url) for url in urls] existing = {u.url: u for u in self.urls.all()} utils.set_ordered_entries(self, urls, existing, URL, 'url', 'content_object')
def set_slugs(self, slugs): """ Update the object's slugs to the given list 'slugs' should be a list of strings. Slugs that do not exist are created. Existing slugs that are not in the 'slugs' list are deleted. """ slugs = [utils.to_maxlength(Slug, 'slug', slug) for slug in slugs] existing = {s.slug: s for s in self.slugs.all()} utils.set_ordered_entries(self, slugs, existing, Slug, 'slug', 'content_object')
def set_entries(self, podcasts): """ Updates the list to include the given podcast, removes others """ existing = {e.content_object: e for e in self.entries.all()} set_ordered_entries(self, podcasts, existing, PodcastListEntry, 'content_object', 'podcastlist')