class UserConnection(ThresholdedBadge): slug = 'user-connection' levels = [ BadgeDetail( name='Bienvenue', description='Se conecter 1 jour', score=20 ), BadgeDetail( name='Vous, ici?', description='Se conecter 10 jours d\'affilé', score=20 ), BadgeDetail( name='Faites comme chez vous', description='Se conecter 50 jours d\'affilé', score=100 ), ] level_thresholds = [ 1, 10, 50, ] events = [ 'on_user_connection', ]
class ExploreDatasetBadge(ThresholdedBadge): slug = 'dataset-explore' levels = [ BadgeDetail(name="Touriste", description='Explorer 1 datasets.', image='dataset-explore-bronze.png', score=10), BadgeDetail(name='Explorateur', description='Explorer 5 datasets.', image='dataset-explore-silver.png', score=40), BadgeDetail(name='Globetrotter', description='Explorer 10 datasets.', image='dataset-explore-gold.png', score=50), ] level_thresholds = [ 1, 5, 10, ] events = [ 'on_dataset_explore', ] def thresholded_value(self, user): return user.profile.visited_datasets.count()
class SubscribeThemeBadge(ThresholdedBadge): slug = 'theme-subscribe' levels = [ BadgeDetail(name="Intéressant ?", description='S\'abonner à un thème.', image='theme-subscribe-bronze.png', score=10), BadgeDetail(name='Stay tuned', description='S\'abonner à cinq thèmes.', image='theme-subscribe-silver.png', score=50), BadgeDetail(name='Rule them all', description='S\'abonner à dix thèmes.', image='theme-subscribe-gold.png', score=50), ] level_thresholds = [ 1, 5, 10, ] events = [ 'on_theme_subscription', ] def thresholded_value(self, user): return user.profile.theme_subscriptions.count()
class QuizFailedBadge(ThresholdedBadge): slug = "quiz-fail" levels = [ BadgeDetail( name="Errare humanum est", description="Se tromper dans un quiz.", image="cancel.png", score=5 ), BadgeDetail( name="Persevare diabolicum", description="Se tromper dans cinq quiz.", image="cancel.png", score=25 ), ] level_thresholds = [ 1, 5, ] events = [ "on_quiz_result", ] def thresholded_value(self, user): return len([quiz for quiz in user.quizzes_taken.all() if not quiz.is_perfect_score])
class DownloadDatasetBadge(OnceBadge): slug = 'dataset-download' levels = [ BadgeDetail(name='Données ouvertes', description='Télécharger un jeu de données.', image='dataset-download.png', score=80), ] events = [ 'on_dataset_download', ]
class QuizDatasetInspection(OnceBadge): slug = 'quiz-dataset-inspection' levels = [ BadgeDetail(name='La curiosité est un bon défaut', description='Inspecter le jeu de données lié à un quiz.', image='quiz-dataset-inspection.png', score=20), ] events = [ 'on_linked_quiz_inspect', ]
class UserTimeConnection(ThresholdedBadge): slug = 'user-time-connection' levels = [ BadgeDetail( name='Une petite pause ?', description='Rester connecté 30 minutes d\'affilé', score=20 ), ] events = [ 'on_user_time_connection', ]
class AddBiography(OnceBadge): slug = 'add-biograpy' levels = [ BadgeDetail( name='Dis moi qui tu es, je saurai qui tu es.', description='Ajouter une biographie', score=20 ), ] events = [ 'on_user_profil_bio', ]
class ModifyProfilName(OnceBadge): slug = 'modify-profil-name' levels = [ BadgeDetail( name='Say my name', description='Changer de nom de profil', score=20 ), ] events = [ 'on_user_profil_name', ]
class WinnerBadge(OnceBadge): slug = 'be-the-best' levels = [ BadgeDetail( name='Veni vidi vici', description='Être le premier du tableau des scores', score=0 ), ] events = [ 'top_1', ]
class LikeDatasetBadge(ThresholdedBadge): slug = 'dataset-like' levels = [ BadgeDetail(name="J'aime donc je suis", description='Liker un jeu de données.', image='dataset-like-silver.png', score=10), BadgeDetail(name='Open relationship', description='Liker cinq jeux de données.', image='dataset-like-gold.png', score=50), ] level_thresholds = [ 1, 5, ] events = [ 'on_dataset_like', ] def thresholded_value(self, user): return user.profile.liked_datasets.count()
class AnswerQuestionBadge(ThresholdedBadge): slug = 'question-answer' levels = [ BadgeDetail(name='Le savoir c\'est comme la confiture...', description='Répondre à une question', score=20), BadgeDetail(name='...moins on en a...', description='Répondre à 20 questions.', score=100), BadgeDetail(name='...plus on l\'étale.', description='Répondre à 50 questions.', score=200), ] level_thresholds = [ 1, 20, 50, ] events = [ 'on_question_answer', ] def thresholded_value(self, user): return user.profile.contents.filter(answer__isnull=False).count()
class AskQuestionBadge(ThresholdedBadge): slug = 'question-ask' levels = [ BadgeDetail(name='Il n\'y a pas de question bête', description='Poser une question', score=20), BadgeDetail(name='non sérieusement continue à poser des questions', description='Poser 20 questions.', score=100), BadgeDetail(name='Bon il y a des limites quand même....', description='Poser 50 questions.', score=200), ] level_thresholds = [ 1, 20, 50, ] events = [ 'on_question_ask', ] def thresholded_value(self, user): return user.profile.contents.filter(question__isnull=False).count()
class QuizPerfectBadge(ThresholdedBadge): slug = "quiz-perfect" levels = [ BadgeDetail( name="Question pour un champion", description="Répondre parfaitement à un quiz.", score=20 ), BadgeDetail( name="Veni, vidi, vici", description="Répondre parfaitement à cinq quiz.", score=100 ) ] level_thresholds = [ 1, 5, ] events = [ "on_quiz_result", ] def thresholded_value(self, user): return len([quiz for quiz in user.quizzes_taken.all() if quiz.is_perfect_score])
class VisitedAllThemeDatasetBadge(Badge): slug = 'dataset-first-comment' levels = [ BadgeDetail(name='Le tour de la question', description='Explorer au moins un dataset par thème.', score=100), ] events = [ 'on_dataset_explore', ] multiple = False def award(self, **states): user = states['user'] if ProxyDataset.objects.all().count( ) == user.profile.visited_datasets.count(): return BadgeAwarded(level=1) return None
class FirstCommentDatasetBadge(Badge): slug = 'dataset-first-comment' levels = [ BadgeDetail( name='First !', description='Être le premier à commenter un jeu de données.', image='dataset-first-comment.png', score=200), ] events = [ 'on_question_ask', ] multiple = False def award(self, **states): dataset = states['dataset'] if dataset and dataset.questions.count() == 1: return BadgeAwarded(level=1) return None