Skip to content

Instantly share code, notes, and snippets.

@cnk
Created January 31, 2018 21:05
Show Gist options
  • Save cnk/4c094894912bcdfb2ef859701b6ca6d3 to your computer and use it in GitHub Desktop.
Save cnk/4c094894912bcdfb2ef859701b6ca6d3 to your computer and use it in GitHub Desktop.
def site_authors(request):
return Author.objects.filter(site_id=request.site.id)
class Authorships(Orderable, models.Model):
author = models.ForeignKey('Author', related_name='author_paper_relationship', on_delete=models.CASCADE)
paper = ParentalKey('Page', related_name='paper_author_relationship', on_delete=models.CASCADE)
panels = [
SnippetChooserPanel('author', qs_restriction=site_authors, editable=False)
]
class Meta:
unique_together = ["author", "paper"]
#### and then I need to create code that adds a permissible kwarg to SnippetChooserPanel and figure out
### how to have it affect the query done in wagtailsnippets/views/chooser.py#choose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment