コード例 #1
0
    def get(self, username=None, recipe_slug=None, version=None):
        """
        Render the recipe view. If no slug is given then create a new recipe
        and render it in edit mode.
        """
        # Create a new recipe if we have no slug, otherwise query
        if not recipe_slug:
            publicuser = self.user
            recipe = Recipe()
            recipe.owner = publicuser
            recipe.new = True
        else:
            publicuser = UserPrefs.all().filter('name =', username).get()

            if not publicuser:
                self.abort(404)

            recipe = Recipe.all()\
                           .filter('owner =', publicuser)\
                           .filter('slug =', recipe_slug)\
                           .get()

            if not recipe:
                self.abort(404)

            if version:
                try:
                    version = int(version)
                except:
                    self.abort(404)

                history = RecipeHistory.get_by_id(version, recipe)

                if not history:
                    self.abort(404)

                recipe.old = True
                recipe.oldname = history.name
                recipe.description = history.description
                recipe.type = history.type
                recipe.category = history.category
                recipe.style = history.style
                recipe.batch_size = history.batch_size
                recipe.boil_size = history.boil_size
                recipe.bottling_temp = history.bottling_temp
                recipe.bottling_pressure = history.bottling_pressure
                recipe._ingredients = history._ingredients

        cloned_from = None
        try:
            cloned_from = recipe.cloned_from
        except Exception, e:
            pass
コード例 #2
0
ファイル: recipes.py プロジェクト: jensyt/malt.io
    def get(self, username=None, recipe_slug=None, version=None):
        """
        Render the recipe view. If no slug is given then create a new recipe
        and render it in edit mode.
        """
        # Create a new recipe if we have no slug, otherwise query
        if not recipe_slug:
            publicuser = self.user
            recipe = Recipe()
            recipe.owner = publicuser
            recipe.new = True
        else:
            publicuser = UserPrefs.all().filter('name =', username).get()

            if not publicuser:
                self.abort(404)

            recipe = Recipe.all()\
                           .filter('owner =', publicuser)\
                           .filter('slug =', recipe_slug)\
                           .get()

            if not recipe:
                self.abort(404)

            if version:
                try:
                    version = int(version)
                except:
                    self.abort(404)

                history = RecipeHistory.get_by_id(version, recipe)

                if not history:
                    self.abort(404)

                recipe.old = True
                recipe.oldname = history.name
                recipe.description = history.description
                recipe.type = history.type
                recipe.category = history.category
                recipe.style = history.style
                recipe.batch_size = history.batch_size
                recipe.boil_size = history.boil_size
                recipe.bottling_temp = history.bottling_temp
                recipe.bottling_pressure = history.bottling_pressure
                recipe._ingredients = history._ingredients

        cloned_from = None
        try:
            cloned_from = recipe.cloned_from
        except Exception, e:
            pass
コード例 #3
0
ファイル: recipes.py プロジェクト: danielgtaylor/malt.io
                'error': 'Permission denied: you are not the recipe owner!'
            })
            return

        # Create a historic version to save
        historic = None
        if not new_recipe:
            historic = recipe.create_historic_version()

        # Update recipe
        recipe.name = recipe_data['name']
        recipe.description = recipe_data['description']
        recipe.category = recipe_data['category']
        recipe.style = recipe_data['style']
        recipe.batch_size = float(recipe_data['batchSize'])
        recipe.boil_size = float(recipe_data['boilSize'])
        recipe.color = int(recipe_data['color'])
        recipe.ibu = float(recipe_data['ibu'])
        recipe.alcohol = float(recipe_data['alcohol'])
        recipe.bottling_temp = float(recipe_data['bottlingTemp'])
        recipe.bottling_pressure = float(recipe_data['bottlingPressure'])
        recipe.mash_efficiency = int(recipe_data['mashEfficiency'])
        recipe.steep_efficiency = int(recipe_data['steepEfficiency'])
        recipe.primary_days = int(recipe_data['primaryDays'])
        recipe.primary_temp = float(recipe_data['primaryTemp'])
        recipe.secondary_days = int(recipe_data['secondaryDays'])
        recipe.secondary_temp = float(recipe_data['secondaryTemp'])
        recipe.tertiary_days = int(recipe_data['tertiaryDays'])
        recipe.tertiary_temp = float(recipe_data['tertiaryTemp'])
        recipe.aging_days = int(recipe_data['agingDays'])
        recipe.mash = recipe_data['mash']
コード例 #4
0
ファイル: recipes.py プロジェクト: pheezer/malt.io
                'Permission denied: you are not the recipe owner!'
            })
            return

        # Create a historic version to save
        historic = None
        if not new_recipe:
            historic = recipe.create_historic_version()

        # Update recipe
        recipe.name = recipe_data['name']
        recipe.description = recipe_data['description']
        recipe.category = recipe_data['category']
        recipe.style = recipe_data['style']
        recipe.batch_size = float(recipe_data['batchSize'])
        recipe.boil_size = float(recipe_data['boilSize'])
        recipe.color = int(recipe_data['color'])
        recipe.ibu = float(recipe_data['ibu'])
        recipe.alcohol = float(recipe_data['alcohol'])
        recipe.bottling_temp = float(recipe_data['bottlingTemp'])
        recipe.bottling_pressure = float(recipe_data['bottlingPressure'])
        recipe.mash_efficiency = int(recipe_data['mashEfficiency'])
        recipe.steep_efficiency = int(recipe_data['steepEfficiency'])
        recipe.primary_days = int(recipe_data['primaryDays'])
        recipe.primary_temp = float(recipe_data['primaryTemp'])
        recipe.secondary_days = int(recipe_data['secondaryDays'])
        recipe.secondary_temp = float(recipe_data['secondaryTemp'])
        recipe.tertiary_days = int(recipe_data['tertiaryDays'])
        recipe.tertiary_temp = float(recipe_data['tertiaryTemp'])
        recipe.aging_days = int(recipe_data['agingDays'])
        recipe.mash = recipe_data['mash']