Esempio n. 1
0
    def get(self):

        student = models.getStudent(users.get_current_user())

        stock = models.StockImage.query(models.StockImage.name == "ccNavLogo").fetch(1)[0]
        defaultAvatar = models.getServingURL(stock.image, "", True)
        try:
            defaultAvatar = models.getServingURL(student.avatar, 200, True)
        except Exception, e:
            print e
    def get(self):

        student = models.getStudent(users.get_current_user())

        stock = models.StockImage.query(
            models.StockImage.name == "ccNavLogo").fetch(1)[0]
        defaultAvatar = models.getServingURL(stock.image, "", True)
        try:
            defaultAvatar = models.getServingURL(student.avatar, 200, True)
        except Exception, e:
            print e
Esempio n. 3
0
class ShowRecipeHandler(webapp2.RequestHandler):
    def post(self):

        # Recipe Stuff
        #
        recipeID = self.request.get('recipeID')

        recipe_key = ndb.Key(urlsafe=recipeID)
        recipe = recipe_key.get()

        # IMAGES
        image_list = []
        for image in recipe.img:
            try:
                img = BlobInfo.get(image)
                url = models.getServingURL(blobkey=img, size=200, shape=False)
                image_list.append(
                    dict(filename=img.filename, url=url, urlkey=str(image)))
            except Exception, e:
                print e

        # AVATAR
        avatar = dict(filename='No Avatar',
                      url='img/no_image.png',
                      urlkey='NoAvatarInBlobstore')
        try:
            img = BlobInfo.get(recipe.avatar)
            url = models.getServingURL(blobkey=img, size=200, shape=False)
            avatar = dict(filename=img.filename,
                          url=url,
                          urlkey=str(recipe.avatar))
        except Exception, e:
            print e
    def get(self):

        # Get User
        user = users.get_current_user()
        admin = users.is_current_user_admin()

        if models.getProfileStatus(user):
            print(user)
            student = models.getStudent(user)

            if (student == ''):

                image = models.StockImage.query(models.StockImage.name == "ccNavLogo").fetch(1)[0]
                defaultAvatar = models.getServingURL(image.image, "", True)

                template_values = {
                    'user_email': user.email(),
                    'user_ID': user.user_id(),
                    'admin': admin,
                    'profile': models.getProfileStatus(user),
                    'defaultAvatar': defaultAvatar
                }

                template = JE.get_template('templates/new_profile.html')
                self.response.write(template.render(template_values))

            else:
                self.redirect('/profile')

        else:
            self.redirect(users.create_login_url('/'))
Esempio n. 5
0
    def post(self):

        # Get User
        user = users.get_current_user()
        admin = users.is_current_user_admin()
        login_status = models.getLoginStatus(user)
        student = models.getStudent(user)

        if (admin):

            allRecipes = models.Recipe.query().fetch(limit=None, projection=[models.Recipe.name, models.Recipe.urlID])
            allStudents = models.Student.query().fetch(limit=None,
                                                       projection=[models.Student.firstname, models.Student.lastname,
                                                                   models.Student.urlID])

            template_values = {
                'user': user,
                'admin': admin,
                'profile': True,
                'login_status': login_status,
                'avatar_nav_img': models.getServingURL(student.avatar, 200, True),
                'all_recipes': allRecipes,
                'all_students': allStudents
            }

            template = JE.get_template('templates/admin.html')
            self.response.write(template.render(template_values))

        else:
            self.redirect('/profile')
Esempio n. 6
0
    def get(self):

        recipes = models.Recipe.query()
        recipeList = recipes.fetch(limit=30)

        student = models.getStudent(users.get_current_user())

        images = []
        for recipe in recipeList:
            images.append(
                dict(
                    url=models.getServingURL(recipe.avatar, random.randint(2, 6) * 100, False)
                )
            )

        stock = models.StockImage.query(models.StockImage.name == "ccNavLogo").fetch(1)[0]
        defaultAvatar = models.getServingURL(stock.image, "", True)
        try:
            defaultAvatar = models.getServingURL(student.avatar, 200, True)
        except Exception, e:
            print e
Esempio n. 7
0
    def get(self):

        recipes = models.Recipe.query()
        recipeList = recipes.fetch(limit=30)

        student = models.getStudent(users.get_current_user())

        images = []
        for recipe in recipeList:
            images.append(
                dict(url=models.getServingURL(recipe.avatar,
                                              random.randint(2, 6) *
                                              100, False)))

        stock = models.StockImage.query(
            models.StockImage.name == "ccNavLogo").fetch(1)[0]
        defaultAvatar = models.getServingURL(stock.image, "", True)
        try:
            defaultAvatar = models.getServingURL(student.avatar, 200, True)
        except Exception, e:
            print e
    def post(self):
        studentID = self.request.get('studentID')

        student_key = ndb.Key(urlsafe=studentID)
        student = student_key.get()

        # AVATAR
        avatar = dict(filename='No Avatar', url='img/no_image.png', urlkey='NoAvatarInBlobstore')
        try:
            img = BlobInfo.get(student.avatar)
            url = models.getServingURL(blobkey=img, size=300, shape=False)
            avatar = dict(filename=img.filename, url=url, urlkey=str(student.avatar))
        except Exception, e:
            print e
Esempio n. 9
0
    def post(self):
        recipeID = self.request.get('recipeID')
        print(recipeID)

        recipe_key = ndb.Key(urlsafe=recipeID)
        recipe = recipe_key.get()

        # IMAGES
        image_list = []
        for image in recipe.img:
            try:
                img = BlobInfo.get(image)
                url = models.getServingURL(blobkey=img, size=200, shape=False)
                image_list.append(dict(filename=img.filename, url=url, urlkey=str(image)))
            except Exception, e:
                print e
Esempio n. 10
0
    def post(self):
        recipeID = self.request.get('recipeID')
        print(recipeID)

        recipe_key = ndb.Key(urlsafe=recipeID)
        recipe = recipe_key.get()

        # IMAGES
        image_list = []
        for image in recipe.img:
            try:
                img = BlobInfo.get(image)
                url = models.getServingURL(blobkey=img, size=200, shape=False)
                image_list.append(
                    dict(filename=img.filename, url=url, urlkey=str(image)))
            except Exception, e:
                print e
Esempio n. 11
0
    def get(self):

        # Get User
        user = users.get_current_user()
        admin = users.is_current_user_admin()
        login_status = models.getLoginStatus(user)

        if (admin):

            student = models.getStudent(user)
            avatar = models.getServingURL(student.avatar, 200, True)

            recipe_upload_url = blobstore.create_upload_url('/recipe_upload')
            recipe_update_url = blobstore.create_upload_url('/recipe_update')
            stock_image_upload_url = blobstore.create_upload_url(
                '/stock_image_upload')
            allRecipes = models.Recipe.query().fetch(
                limit=None,
                projection=[models.Recipe.name, models.Recipe.urlID])
            allStudents = models.Student.query().fetch(
                limit=None,
                projection=[
                    models.Student.firstname, models.Student.lastname,
                    models.Student.urlID
                ])

            template_values = {
                'user': user,
                'admin': admin,
                'profile': True,
                'login_status': login_status,
                'avatar_nav_img': avatar,
                'recipe_upload_url': recipe_upload_url,
                'recipe_update_url': recipe_update_url,
                'stock_image_upload_url': stock_image_upload_url,
                'all_recipes': allRecipes,
                'all_students': allStudents
            }

            template = JE.get_template('templates/admin.html')
            self.response.write(template.render(template_values))

        else:
            self.redirect('/profile')
Esempio n. 12
0
            'date': recipe.date.isoformat(),
            'category': categories_list,
            'description': recipe.description,
            'prep_time': prep_time,
            'cook_time': cook_time,
            'serves': recipe.serves,
            'img': image_list,
            'avatar': avatar,
            'directions': directions_list,
            'ingredients': ingredient_list,
            'utilities': utilities_list,
            'urlID': recipe.urlID,
            # Student Stuff
            'studentID': studentID,
            'theme' : student.theme,
            'avatar_nav_img': models.getServingURL(student.avatar, 200, True),
            'profile': True,
            'user': users.get_current_user(),
            'login_status': models.getLoginStatus(users.get_current_user()),
            'admin': users.is_current_user_admin(),
            'notes': recipeNotes,
            'favorite': favorite,
        }

        template = JE.get_template('templates/recipe.html')
        self.response.write(template.render(template_values))


class GalleryImageHandler(webapp2.RequestHandler):
    def get(self):
Esempio n. 13
0
            'date': recipe.date.isoformat(),
            'category': categories_list,
            'description': recipe.description,
            'prep_time': prep_time,
            'cook_time': cook_time,
            'serves': recipe.serves,
            'img': image_list,
            'avatar': avatar,
            'directions': directions_list,
            'ingredients': ingredient_list,
            'utilities': utilities_list,
            'urlID': recipe.urlID,
            # Student Stuff
            'studentID': studentID,
            'theme': student.theme,
            'avatar_nav_img': models.getServingURL(student.avatar, 200, True),
            'profile': True,
            'user': users.get_current_user(),
            'login_status': models.getLoginStatus(users.get_current_user()),
            'admin': users.is_current_user_admin(),
            'notes': recipeNotes,
            'favorite': favorite,
        }

        template = JE.get_template('templates/recipe.html')
        self.response.write(template.render(template_values))


class GalleryImageHandler(webapp2.RequestHandler):
    def get(self):
    def get(self):

        # Get User
        user = users.get_current_user()
        admin = users.is_current_user_admin()

        student = models.getStudent(user)

        if student:

            # Student has a Profile
            profile = True
            # Create Recipes List
            recipes = []
            # Get Favorite Recipes List
            favRecipes = student.favRecipes

            # PHONES
            phones = []
            types = ['home', 'cell', 'work']
            for p in student.phone:
                # Remove Existing from types list
                types = [i for i in types if i != p.type]
                # Append to phones list
                phones.append(p)

            for t in types:
                phones.append(dict(
                    type=t,
                    number=''
                ))


            # ADDRESS
            if student.address:
                address = student.address
            else:
                address = [{'type': 'home'}]


            # Loop Through Student Recipes
            for item in student.recipes:
                # Get Recipe Using Key
                recipe_key = ndb.Key(urlsafe=item.urlID)
                recipe = recipe_key.get()
                # Create Categories List
                categories = []

                # Combine Categories into List
                for cat in recipe.category:
                    categories.append(cat)


                # COOK TIME
                cook_time = dict(
                    hours=int(recipe.cook_time / 60),
                    minutes=int(recipe.cook_time % 60)
                )

                # PREP TIME
                prep_time = dict(
                    hours=int(recipe.prep_time / 60),
                    minutes=int(recipe.prep_time % 60)
                )

                # Check if Recipe is a Favorite
                if item.urlID in favRecipes:
                    # Append Recipe Dict to List
                    recipes.append(dict(name=recipe.name, description=recipe.description, urlID=recipe.urlID,
                                        avatar=models.getServingURL(blobkey=recipe.avatar, size='', shape=False),
                                        serves=recipe.serves, cookTime=cook_time, prepTime=prep_time,
                                        categories=categories, favorite=True))
                else:
                    # Append Recipe Dict to List
                    recipes.append(dict(name=recipe.name, description=recipe.description, urlID=recipe.urlID,
                                        avatar=models.getServingURL(blobkey=recipe.avatar, size='', shape=False),
                                        serves=recipe.serves, cookTime=cook_time, prepTime=prep_time,
                                        categories=categories, favorite=False))

            template_values = {
                'user': user,
                'admin': users.is_current_user_admin(),
                'profile': profile,
                'login_status': models.getLoginStatus(user),
                'uploadURL': blobstore.create_upload_url('/update_avatar'),
                'userID': student.userID,
                'urlID': student.urlID,
                'avatar': student.avatar,
                'avatar_img': models.getServingURL(student.avatar, "", False),
                'avatar_nav_img': models.getServingURL(student.avatar, 200, True),
                'date_joined': student.date.strftime('%b %d, %Y'),
                'nickname': student.nickname,
                'firstname': student.firstname,
                'lastname': student.lastname,
                'email': student.email,
                'phone': phones,
                'address': address,
                'recipes': recipes,
                'favRecipes': favRecipes,
                'theme' : student.theme
            }

            template = JE.get_template('templates/profile.html')
            self.response.write(template.render(template_values))

        else:

            self.redirect('/new_profile')