-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add review views for all content types.
Review view provides additional information when entering content review, displaying explicit message e.g. if the content is already approved, or the user doesn't have the rights to approve it. Fixes #13. Fixes #12.
- Loading branch information
Showing
15 changed files
with
180 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.contrib import messages | ||
from django.contrib.auth.decorators import login_required | ||
from django.utils.decorators import method_decorator | ||
from django.views.generic import RedirectView | ||
|
||
|
||
class ReviewContentView(RedirectView): | ||
""" Redirects to content to be reviewed and puts up a helper message | ||
depending on whether the item has already been reviewed and whether the user | ||
has the rights to approve it. | ||
Requirements for impl: | ||
- self.get_object() has to return the content item | ||
""" | ||
|
||
@method_decorator(login_required) | ||
def dispatch(self, *args, **kwargs): | ||
return super().dispatch(*args, **kwargs) | ||
|
||
def get_redirect_url(self, *args, **kwargs): | ||
item = self.get_object() | ||
if item.is_live(): | ||
messages.add_message(self.request, messages.INFO, | ||
"Materiał został już wcześniej zatwierdzony.") | ||
return item.get_absolute_url() | ||
|
||
if not item.can_be_approved_by(self.request.user): | ||
messages.add_message(self.request, messages.INFO, | ||
"Ten materiał nie może być zatwierdzony przez " | ||
"Ciebie.") | ||
return item.get_absolute_url() | ||
|
||
messages.add_message(self.request, messages.INFO, | ||
"Edytuj lub zatwierdź materiał przy pomocy linków " | ||
"na dole strony.") | ||
return item.get_absolute_url() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.