Esempio n. 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
            brews = []
        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)

            brews = recipe.brews.order('-started').fetch(3)

            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.mash_efficiency = history.mash_efficiency
                recipe.steep_efficiency = history.steep_efficiency
                recipe.primary_days = history.primary_days
                recipe.secondary_days = history.secondary_days
                recipe.tertiary_days = history.tertiary_days
                recipe.aging_days = history.aging_days
                recipe._ingredients = history._ingredients

        cloned_from = None
        try:
            cloned_from = recipe.cloned_from
        except Exception, e:
            pass
Esempio n. 2
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
            brews = []
        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)

            brews = recipe.brews.order('-started').fetch(3)

            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.mash_efficiency = history.mash_efficiency
                recipe.steep_efficiency = history.steep_efficiency
                recipe.primary_days = history.primary_days
                recipe.secondary_days = history.secondary_days
                recipe.tertiary_days = history.tertiary_days
                recipe.aging_days = history.aging_days
                recipe._ingredients = history._ingredients

        cloned_from = None
        try:
            cloned_from = recipe.cloned_from
        except Exception, e:
            pass
Esempio n. 3
0
        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']
        recipe.ingredients = recipe_data['ingredients']

        # Update slug
        recipe.slug = generate_usable_slug(recipe)

        changed = False
        if historic:
            # Perform a diff on the new and historic recipes to see if any actual
            # changes were made
            diff = recipe.diff(historic, False)

            # See if any changes were actually made
            if len(diff[0]) != 0 or \
               len(diff[1]) != 0 or \
Esempio n. 4
0
        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']
        recipe.ingredients = recipe_data['ingredients']

        # Update slug
        recipe.slug = generate_usable_slug(recipe)

        changed = False
        if historic:
            # Perform a diff on the new and historic recipes to see if any actual
            # changes were made
            diff = recipe.diff(historic, False)

            # See if any changes were actually made
            if len(diff[0]) != 0 or \
               len(diff[1]) != 0 or \