예제 #1
0
파일: welcome.py 프로젝트: akivab/WeSoSmart
 def post(self):
     um = UserManagement(self)
     user = um.getUser()
     signed_in = um.isLoggedIn()
     template_values = {'signed_in': signed_in, 'um':um}
     template_values['recent_comments'] = Comment.getRecent()
     if(re.match('/settings', self.request.path)):
         pic = self.request.get("user[picture]")
         try:
             if pic:
                 picture = Picture.addPicture(db.Blob(images.resize(pic, 100, 100)))
                 user.picture = picture
                 user.put()
             self.redirect('/complete')
         except Exception, e:
            self.redirect('/error?type="problem with picture!"')
예제 #2
0
파일: welcome.py 프로젝트: akivab/WeSoSmart
    def get(self):
        render_template(None, 'view/footer.html')
        render_template(None, 'view/header.html')
        render_template(None, 'view/scripts.html')
        path = self.request.path;
        um = UserManagement(self)
        signed_in = um.isLoggedIn()

        template_values = {'signed_in': signed_in, 'um':um}
        template_values['recent_comments'] = Comment.getRecent()
        page = "view/"
        if(path == "/"):
            page+="index.html"
            data = UserBooks().getRecent(20)
            template_values['recent_activity']=data
            template_values['is_homepage']=True
            template_values['title']="Home"
        elif(re.match(r'/find', path)):
            page+="find_books.html"
            template_values['title']="Find Books"
        elif(re.match(r'/about', path)):
            page+="about.html"
            template_values['about']=True
        elif(re.match(r'/settings', path)):
            page+="settings.html"
        elif(re.match(r'/search', path)):
            KeyHandler(self).get()
            return
        elif(re.match(r'/recent_listings', path)):
            page+="recent_listings.html"
            template_values['books'] = UserBooks().getRecent(100)
            template_values['title']="Recent Listings"
        elif(re.match(r'/complete',path)):
            page+="complete.html"
            if self.request.get("justsignedup"):
                template_values['justsignedup']=True
            template_values['task']="Mission"
        elif(re.match(r'/error',path)):
            page+="complete.html"
            template_values['reason']=self.request.get("type")
        elif(re.match(r'/profile',path)):
            if(signed_in):
                sh = SubjectHandler(self, template_values)
                sh.path = '/user/'+str(um.getUser().key())
                sh.template_values['profile'] = True
                sh.get()
                return
            else:
                self.redirect('/signup_page?redirect=%s'%self.request.url)
                return
        elif(re.match(r'/messages',path)):
            MessageHandler(self,template_values).get()
            return
        elif(re.match(r'/enroll', path)):
            class_id = self.request.get("class")
            try:
                section_id = Section.get(Key(class_id))
                user_id = um.getUser()
                userclass = UserClasses.gql("WHERE user_id = :1 AND section_id = :2", user_id, section_id).get()
                if not userclass:
                    userclass = UserClasses(user_id=user_id, section_id = section_id, relationship=0)
                    userclass.put()
                self.redirect("/complete")
            except Exception, e:
                self.redirect('/error?type='+str(e))
            return
예제 #3
0
파일: welcome.py 프로젝트: akivab/WeSoSmart
                book = Book.gql("WHERE isbn=:1",book_isbn).get()
                if not book:
                    book = Book(isbn = book_isbn, price = float(book_price))
                    book.put()
                GetBooks().setBookInfo(book)
                book.title = escape(book.title)
                book.author = escape(book.author)
                book.put()
                classbook = ClassBooks.gql("WHERE section_id = :1 AND book_id=:2", section_id, book).get()
                if not classbook:
                    classbook = ClassBooks(section_id = section_id, book_id = book, req = "Recommended")
                    classbook.put()
            self.redirect('/complete')

        elif(re.match(r'/delete_comment',self.request.path)):
            user = UserManagement(self).getUser()
            c = Comment.get(self.request.get("c"))
            if c.user_id.key() == user.key():
                Comment.erase(c)
        elif(re.match(r'/import',self.request.path)):
            ImportHandler(self, template_values).post()
            return

    def get(self):
        render_template(None, 'view/footer.html')
        render_template(None, 'view/header.html')
        render_template(None, 'view/scripts.html')
        path = self.request.path;
        um = UserManagement(self)
        signed_in = um.isLoggedIn()