Exemplo n.º 1
0
def submit_game(request):
    form = GameForm(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        game = form.save()
        submission = GameSubmission(user=request.user, game=game)
        submission.save()

        # Notify managers a game has been submitted
        admin_url = "https://lutris.net" + reverse("admin:games_game_change",
                                                   args=(game.id, ))
        context = {
            "game_name": game.name,
            "username": request.user.username,
            "admin_link": admin_url,
        }
        subject = "New game submitted: {}".format(game.name)
        send_email("new_game", context, subject, settings.MANAGERS[0][1])

        redirect_url = request.build_absolute_uri(reverse("game-submitted"))

        # Enforce https
        if not settings.DEBUG:
            redirect_url = redirect_url.replace("http:", "https:")

        LOGGER.info("Game submitted, redirecting to %s", redirect_url)
        return redirect(redirect_url)
    return render(request, "games/submit.html", {"form": form})
Exemplo n.º 2
0
def submit_game(request):
    form = GameForm(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        game = form.save()
        submission = GameSubmission(user=request.user, game=game)
        submission.save()

        # Notify managers a game has been submitted
        admin_url = "https://lutris.net" + reverse(
            "admin:games_game_change", args=(game.id,)
        )
        context = {
            "game_name": game.name,
            "username": request.user.username,
            "admin_link": admin_url,
        }
        subject = "New game submitted: {}".format(game.name)
        send_email("new_game", context, subject, settings.MANAGERS[0][1])

        redirect_url = request.build_absolute_uri(reverse("game-submitted"))

        # Enforce https
        if not settings.DEBUG:
            redirect_url = redirect_url.replace("http:", "https:")

        LOGGER.info("Game submitted, redirecting to %s", redirect_url)
        return redirect(redirect_url)
    return render(request, "games/submit.html", {"form": form})
Exemplo n.º 3
0
 def send(self, request):
     user = request.user
     confirmation_link = request.build_absolute_uri(self.get_token_url())
     context = {
         'username': user.username,
         'confirmation_link': confirmation_link
     }
     subject = 'Confirm your email address'
     messages.send_email('email_confirmation', context, subject, user.email)
Exemplo n.º 4
0
 def send(self, request):
     user = request.user
     confirmation_link = request.build_absolute_uri(self.get_token_url())
     context = {
         'username': user.username,
         'confirmation_link': confirmation_link
     }
     subject = 'Confirm your email address'
     messages.send_email('email_confirmation', context, subject, user.email)
Exemplo n.º 5
0
def send_daily_mod_mail():
    """Send the email to moderators"""
    context = get_mod_mail_content()
    if settings.DEBUG:
        moderators = [u[1] for u in settings.MANAGERS]
    else:
        moderators = [u.email for u in User.objects.filter(is_staff=True)]
    subject = 'Your daily moderator mail'
    return send_email('daily_mod_mail', context, subject, moderators)
Exemplo n.º 6
0
def send_daily_mod_mail():
    from accounts.models import User
    context = get_mod_mail_content()
    if settings.DEBUG:
        moderators = [u[1] for u in settings.MANAGERS]
    else:
        moderators = [u.email for u in User.objects.filter(is_staff=True)]
    subject = 'Your daily moderator mail'
    return send_email('daily_mod_mail', context, subject, moderators)