"""Rules and defaults for public link previews.""" from django.core.exceptions import ValidationError from django.urls import resolve from .backgrounds import validate_background_path DEFAULTS = { 'home': ('SLUMP X LAND', 'Read the official SLUMP X LAND ManaA series. Find new chapters, news, and updates from the studio.'), 'coming-soon': ('Coming Soon · SLUMP X LAND', 'See what’s coming next from SLUMP X LAND.'), 'chapters': ('Chapter Archive · SLUMP X LAND', 'Browse released SLUMP X LAND chapters in the official reader.'), 'upcoming': ('Upcoming Releases · SLUMP X LAND', 'See the next SLUMP X LAND releases and countdowns.'), 'blog': ('Blog · SLUMP X LAND', 'Read announcements, creator notes, and updates from the studio.'), 'entries': ('World Archive · SLUMP X LAND', 'Explore the characters and places of SLUMP X LAND.'), 'books': ('Official Shop · SLUMP X LAND', 'Shop SLUMP X LAND comics, music, apparel, and merchandise.'), 'slx-community': ('Fan Community · SLUMP X LAND', 'Follow the series and join SLUMP X LAND readers in the fan community.'), 'newsletter-signup': ('Newsletter · SLUMP X LAND', 'Sign up for new chapter announcements and behind-the-scenes updates.'), 'search': ('Search · SLUMP X LAND', 'Find chapters, studio posts, characters, and locations.'), 'slx-reviews': ('Chapter Reviews · SLUMP X LAND', 'Read fan reviews and reactions to a SLUMP X LAND chapter.'), 'slx-series-reviews': ('Series Reviews · SLUMP X LAND', 'Read what fans think of the SLUMP X LAND series.'), 'slx-profile': ('Reader Profile · SLUMP X LAND', 'Explore this reader’s public reviews and favorites.'), } SHARE_ROUTES = set(DEFAULTS) | {'chapter', 'chapter-discussion', 'entry', 'blog-post', 'slx-review', 'slx-series-review'} def validate_share_path(path): validate_background_path(path) if resolve(path).url_name not in SHARE_ROUTES: raise ValidationError('Choose a publicly shareable page. Private, sign-in and write pages do not have previews.')