Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
249e026
commit 2379b7e
Showing
5 changed files
with
58 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
from udata.api import api, API | ||
from udata.utils import id_or_404 | ||
from udata.auth import admin_permission | ||
from udata.utils import id_or_404 | ||
|
||
|
||
class SpamAPI(API): | ||
''' | ||
""" | ||
Base Spam Model API. | ||
''' | ||
""" | ||
model = None | ||
|
||
def get_model(self, id): | ||
'''This function returns the base model and the spamable model which can be different. The base model is the model stored inside Mongo and the spamable model is the embed document (for exemple a comment inside a discussion)''' | ||
""" | ||
This function returns the base model and the spamable model which can be different. The base model is the | ||
model stored inside Mongo and the spamable model is the embed document (for example a comment inside a | ||
discussion) | ||
""" | ||
model = self.model.objects.get_or_404(id=id_or_404(id)) | ||
return model, model | ||
|
||
@api.secure(admin_permission) | ||
def delete(self, **kwargs): | ||
'''Mark a potentiel spam as no spam''' | ||
""" | ||
Mark a potential spam as no spam | ||
""" | ||
base_model, model = self.get_model(**kwargs) | ||
|
||
if not model.is_spam(): | ||
return {}, 200 | ||
|
||
model.mark_as_no_spam(base_model) | ||
return {}, 200 |
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