Exemple #1
0
    def index_post(self, **kw):
        user = request.context["user"]

        for k, v in kw.items():
            user.settings[k] = v

        if request.context["metric"] == True:
            user.settings["default_recipe_volume"] = to_us(*(user.settings["default_recipe_volume"], "LITER"))[0]
        user.settings["brewhouse_efficiency"] = user.settings["brewhouse_efficiency"] / 100.00

        notify("Your settings have been saved.")
        redirect("/settings/recipe", headers=response.headers)
Exemple #2
0
    def index_post(self, **kw):
        user = request.context['user']

        for k, v in kw.items():
            user.settings[k] = v

        if request.context['metric'] is True:
            user.settings['default_recipe_volume'] = to_us(
                *(user.settings['default_recipe_volume'], 'LITER'))[0]

        user.settings['brewhouse_efficiency'] /= 100.00

        notify('Your settings have been saved.')
        redirect('/settings/recipe', headers=response.headers)
Exemple #3
0
    def index_post(self, **kw):
        user = request.context['user']

        for k, v in kw.items():
            user.settings[k] = v

        if request.context['metric'] is True:
            user.settings['default_recipe_volume'] = to_us(
                *(user.settings['default_recipe_volume'], 'LITER')
            )[0]

        user.settings['brewhouse_efficiency'] /= 100.00

        notify('Your settings have been saved.')
        redirect('/settings/recipe', headers=response.headers)
Exemple #4
0
    def post(self, **kw):
        recipe = model.Recipe(
            name        = kw.get('name'),
            type        = kw.get('type'),
            author      = request.context['user']
        )

        if recipe.metric:
            recipe.gallons = to_us(*(kw.get('volume'), 'LITER'))[0]
        else:
            recipe.gallons = kw.get('volume')

        recipe.fermentation_steps.append(
            model.FermentationStep(
                step = 'PRIMARY',
                days = 7,
                fahrenheit = 65
            )
        )
        recipe.flush()

        #
        # If the recipe is created by a guest instead of an authenticated
        # user, store the trial recipe in a cookie.
        #
        if recipe.author is None:
            save_trial_recipe(recipe)

        #
        # If we have an authenticated user, and this is their first recipe,
        # save their choices as defaults so they'll be used again on their
        # next recipe.
        #
        if recipe.author and len(recipe.author.recipes) == 1:
            recipe.author.settings['default_recipe_type'] = recipe.type
            recipe.author.settings['default_recipe_volume'] = recipe.gallons

        redirect('/recipes/%x/%s/builder/' % (recipe.id, recipe.slugs[0].slug))
Exemple #5
0
    def post(self, **kw):
        recipe = model.Recipe(
            name=kw.get('name'),
            type=kw.get('type'),
            author=request.context['user']
        )

        if recipe.metric:
            recipe.gallons = to_us(*(kw.get('volume'), 'LITER'))[0]
        else:
            recipe.gallons = kw.get('volume')

        recipe.fermentation_steps.append(
            model.FermentationStep(
                step='PRIMARY',
                days=7,
                fahrenheit=65
            )
        )
        recipe.flush()

        #
        # If the recipe is created by a guest instead of an authenticated
        # user, store the trial recipe in a cookie.
        #
        if recipe.author is None:
            save_trial_recipe(recipe)

        #
        # If we have an authenticated user, and this is their first recipe,
        # save their choices as defaults so they'll be used again on their
        # next recipe.
        #
        if recipe.author and len(recipe.author.recipes) == 1:
            recipe.author.settings['default_recipe_type'] = recipe.type
            recipe.author.settings['default_recipe_volume'] = recipe.gallons

        redirect('/recipes/%x/%s/builder' % (recipe.id, recipe.slugs[0].slug))
 def test_gram_to_ounce(self):
     """Convert g to oz"""
     assert to_us(*(50, 'GRAM')) == (1.7636980949999999, 'OUNCE')
 def test_kg_to_pound(self):
     """Convert kg to pounds"""
     assert to_us(*(5, 'KILOGRAM')) == (11.0231131, 'POUND')
Exemple #8
0
 def liters(self, v):
     gallons = to_us(*(v, "LITER"))[0]
     self.gallons = gallons
Exemple #9
0
 def test_gram_to_ounce(self):
     """Convert g to oz"""
     assert to_us(*(50, 'GRAM')) == (1.7636980949999999, 'OUNCE')
 def test_passthrough(self):
     assert to_us(*(5, "TSP")) == (5, "TSP")
 def test_gram_to_ounce(self):
     """Convert g to oz"""
     assert to_us(*(50, "GRAM")) == (1.7636980949999999, "OUNCE")
 def test_kg_to_pound(self):
     """Convert kg to pounds"""
     assert to_us(*(5, "KILOGRAM")) == (11.0231131, "POUND")
Exemple #13
0
 def liters(self, v):
     gallons = to_us(*(v, "LITER"))[0]
     self.gallons = gallons
Exemple #14
0
 def test_passthrough(self):
     assert to_us(*(5, 'TSP')) == (5, 'TSP')
Exemple #15
0
 def test_liter_to_gallon(self):
     """Convert liters to gallons"""
     assert to_us(*(20, 'LITER')) == (5.2834410399999996, 'GALLON')
Exemple #16
0
 def test_liter_to_gallon(self):
     """Convert liters to gallons"""
     assert to_us(*(20, 'LITER')) == (5.2834410399999996, 'GALLON')
Exemple #17
0
 def test_passthrough(self):
     assert to_us(*(5, 'TSP')) == (5, 'TSP')
Exemple #18
0
 def test_kg_to_pound(self):
     """Convert kg to pounds"""
     assert to_us(*(5, 'KILOGRAM')) == (11.0231131, 'POUND')