コード例 #1
0
    def terminate_legacy(self, user):
        if not user.is_novice:
            # Migrate entries before deleting the user completely
            user.entry_set.all().update(author=get_generic_privateuser())
            logger.info("User entires migrated: %s<->%d", user.username,
                        user.pk)

        self.terminate_no_trace(user)
コード例 #2
0
    def commit_terminations(self):
        self._private_user = get_generic_privateuser()

        for termination in self.get_terminated().select_related("author"):
            if termination.state == "NT":
                self.terminate_no_trace(termination.author)
            elif termination.state == "LE":
                self.terminate_legacy(termination.author)
コード例 #3
0
ファイル: entry.py プロジェクト: wickieonya/django-sozluk
    def delete(self, *args, **kwargs):
        if self.comments.exists():
            self.author = get_generic_privateuser()
            self.save()
            return

        self.author.invalidate_entry_counts()
        super().delete(*args, **kwargs)

        if self.author.is_novice and self.author.application_status == "PN" and self.author.entry_count < 10:
            # If the entry count drops less than 10, remove user from novice lookup.
            # This does not trigger if bulk deletion made on admin panel (users can
            # only remove one entry at a time) or the entry in question has answers.
            self.author.application_status = "OH"
            self.author.application_date = None
            self.author.queue_priority = 0
            self.author.save(update_fields=["application_status", "application_date", "queue_priority"])