Esempio n. 1
0
 def CheckChapter(self, *args):
     from models import Chapter
     bookname = args[0].replace('%20', ' ')
     chapter = args[1].replace('%20', ' ')
     user = users.get_current_user()
     q = Chapter.all().filter('user ==',user).filter('book ==',bookname).filter('title ==',chapter)
     results = q.fetch(1)
     if len(results) == 0:
         chapter = chapter+" "
         q = Chapter.all().filter('user ==',user).filter('book ==',bookname).filter('title ==',chapter)
         results = q.fetch(1)
     for result in results:
         result.state = "Fertig"
         result.put()
         break
     return self.ShowBook(bookname,args[2])
Esempio n. 2
0
 def DeleteClass(self, *args):
     from google.appengine.ext import db
     from models import Task, Class, Book, Chapter
     from google.appengine.api import users
     user = users.get_current_user()
     classname = args[0].replace('%20', ' ')
     #Deleting all Tasks for this Module
     q = Task.all().filter('user ==',user).filter('classname ==',classname)
     results = q.fetch(10)
     for result in results:
         result.delete()
     #Deleting all the Scripts and Chapters from this Module
     qq = Book.all().filter('user ==',user).filter('classname ==',classname)
     books = qq.fetch(10)
     for book in books:
         qqq = Chapter.all().filter('book ==', book.title).filter('user ==',user)
         for chapter in qqq:
             chapter.delete()
         book.delete()
     #Deleting the Module itself
     qqqq = Class.all().filter('user ==',user).filter('name ==',classname)
     results = qqqq.fetch(10)
     for result in results:
         result.delete()
     return self.RefreshClasses()
Esempio n. 3
0
 def ShowBook(self, *args):
     from models import Chapter
     user = users.get_current_user()
     chapters = Chapter.all().filter('user ==',user).filter('book ==',args[0]).order('number')
     done = Chapter.all().filter('user ==',user).filter('book ==',args[0]).filter('state =', "Fertig")
     
     try:
         percent = done.count() * 100 / chapters.count()
     except:
         percent = 0
     template_values = { 'classcolor': args[1],
                         'bookname' : args[0],
                         'percent' : percent,
                         'chapters' : chapters
                          }
     path = os.path.join(os.path.dirname(__file__), "templates", "showindex.html")
     code = template.render(path, template_values).decode('utf-8')
     return code
Esempio n. 4
0
 def DeleteBook(self, *args):
     from google.appengine.ext import db
     from models import Class, Book, Chapter
     from google.appengine.api import users
     user = users.get_current_user()
     classname = args[0].replace('%20', ' ')
     bookname = args[1].replace('%20', ' ')
     qq = Book.all().filter('user ==',user).filter('classname ==',classname).filter('title ==',bookname)
     books = qq.fetch(10)
     for book in books:
         qqq = Chapter.all().filter('book ==', book.title).filter('user ==',user)
         for chapter in qqq:
             chapter.delete()
         book.delete()
         break
     return self.RefreshClasses()