<commit_before>from django.shortcuts import render

from .forms import HomeDiceRollForm
from .models import DiceRoll

# def home(request):
#     return render(request, 'dice/home.html')

def home(request):
    if request.method == 'POST':
        form = HomeDiceRollForm(request.POST)
        roll_output = ''
        if form.is_valid():
            print('form ok')
            number_of_dice = form.clean_number_of_dice()
            dice_type = form.clean_dice_type()
            roll_modifier = form.clean_roll_modifier()
            explode_value = form.clean_explode_value()
            success_condition = form.clean_success_condition()
            roll = DiceRoll(number_of_dice, dice_type, roll_modifier,
                            explode_value, success_condition)
            roll.roll_dice()
            roll.explode_dice()
            roll.success_counter()
            roll_output = roll.output()
            print(roll_output)
        return render(request, 'dice/home.html', {
            'form': form,
            'roll_output': roll_output,
        })
        
            
    else:
        form = HomeDiceRollForm()
        return render(request, 'dice/home.html', {'form': form})
   
<commit_msg>adds minor adjustments to views.py in the dice app<commit_after>from django.shortcuts import render

from .forms import HomeDiceRollForm
from .models import DiceRoll

# def home(request):
#     return render(request, 'dice/home.html')

def home(request):
    if request.method == 'POST':
        form = HomeDiceRollForm(request.POST)
        roll_output = ''
        if form.is_valid():
            number_of_dice = form.clean_number_of_dice()
            dice_type = form.clean_dice_type()
            roll_modifier = form.clean_roll_modifier()
            explode_value = form.clean_explode_value()
            success_condition = form.clean_success_condition()
            roll = DiceRoll(number_of_dice, dice_type, roll_modifier, 
                            explode_value, success_condition)
            roll.roll_dice()
            roll.explode_dice()
            roll.success_counter()
            roll_output = roll.output()
        return render(request, 'dice/home.html', {
            'form': form,
            'roll_output': roll_output,
        })
        
            
    else:
        form = HomeDiceRollForm()
        return render(request, 'dice/home.html', {'form': form})
   

{'fraction_non_alphanumeric': 0.09652029826014913, 'fraction_numerical': 0.0, 'mean_word_length': 2.1121134020618557, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1944200', 'n_tokens_mistral': 701, 'n_tokens_neox': 702, 'n_words': 137}