Beispiel #1
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        user = users.get_current_user()
        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'

            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()

            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()

        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        template_values = {'url': url, 'url_string': url_string, 'user': user}

        template = JINJA_ENVIRONMENT.get_template('add.html')
        self.response.write(template.render(template_values))
Beispiel #2
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        tb = self.request.get('taskBoarddata')
        owner = self.request.get('email')
        unique = tb + "" + owner
        taskTitle = self.request.get('EditButton')
        taskboard_data = ndb.Key('taskBoarddata', unique).get()
        task_data = ndb.Key('taskdata', unique).get()
        taskdata = []

        for i in range(0, len(task_data.Title)):
            if task_data.Title[i] == taskTitle:
                taskdata.append(task_data.Title[i])
                taskdata.append(task_data.Due_Date[i])
        editButtonValue = self.request.get('submit')

        if editButtonValue == 'Edit':
            TaskOldName = self.request.get('TaskOldName')
            TaskNewName = self.request.get('TaskNewName')
            TaskNewDue_Date = self.request.get('TaskNewDue_Date')
            for i in range(0, len(task_data.Title)):
                if task_data.Title[i] == TaskOldName:
                    task_data.Title[i] = TaskNewName
                    task_data.Due_Date[i] = TaskNewDue_Date
                    task_data.put()
                    self.redirect('/invite?taskBoarddata=' + tb + '&email=' +
                                  owner)

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'taskboard_data': taskboard_data,
            'taskdata': taskdata
        }

        template = JINJA_ENVIRONMENT.get_template('editTask.html')
        self.response.write(template.render(template_values))
Beispiel #3
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        TaskBoardNameFromUser = self.request.get('TaskBoardName')
        Unique = TaskBoardNameFromUser+""+user.email()
        data = ndb.Key('MyUser', user.email()).get()

        element = data.taskboard
        in_List = False
        i = 0
        while i < len(element):
            if element[i] == Unique:
                in_List = True
                break
            else:
                in_List = False
                i = i + 1

        if in_List == True:
            self.redirect('/')
        else:
            add_data = taskBoarddata(id=Unique)
            add_data.owner = user.email()
            add_data.email_address.append(user.email())
            add_data.taskBoarddata = TaskBoardNameFromUser
            add_data.put()
            data.taskboard.append(Unique)
            data.put()
            self.redirect('/taskBoard')

        template_values = {
            'url' : url,
            'url_string' : url_string,
            'user' : user,
            'Value_data' : data
            }

        template = JINJA_ENVIRONMENT.get_template('addTaskBoard.html')
        self.response.write(template.render(template_values))
Beispiel #4
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        collection = []
        Caption = []
        length = 0
        userfollower = 0
        userfollowing = 0

        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()

            collection_key = ndb.Key('post',user.email())
            collection_key = collection_key.get()
            if collection_key != None:
                i = len(collection_key.photo_url) - 1
                while i > -1:
                    collection.append(collection_key.photo_url[i])
                    Caption.append(collection_key.caption[i])
                    i = i - 1
                length = len(collection)
            collect = ndb.Key('followerfollowing',user.email()).get()
            if collect != None:
                userfollower = len(collect.follower)
                userfollowing = len(collect.following)
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        template_values = {
             'url' : url,
             'url_string' : url_string,
             'user' : user,
             'collection' : collection,
             'Caption' : Caption,
             'i' : length,
             'userfollower': userfollower,
             'userfollowing': userfollowing,
        }

        template = JINJA_ENVIRONMENT.get_template('login-logout.html')
        self.response.write(template.render(template_values))
Beispiel #5
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''

        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()

            upload = self.get_uploads()[0]
            blobinfo = blobstore.BlobInfo(upload.key())
            image_url = get_serving_url(blobinfo)
            caption = self.request.get('caption')
            collection_key = ndb.Key('post', user.email())
            collection_key = collection_key.get()

            if collection_key == None:
                collection_key = post(id=user.email())
                collection_key.photo_url.append(image_url)
                collection_key.email_address = user.email()
                collection_key.caption.append(caption)
            else:
                collection_key.photo_url.append(image_url)
                collection_key.email_address = user.email()
                collection_key.caption.append(caption)

            collection_key.put()
            self.redirect('/')

        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'collection_key': collection_key,
        }

        template = JINJA_ENVIRONMENT.get_template('photocomment.html')
        self.response.write(template.render(template_values))
Beispiel #6
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'

            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()

            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()

        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        Add_Data_Key = self.request.get('atti_name') + "" + self.request.get(
            'atti_manufacture') + "" + self.request.get('atti_year')
        AttributeExists = ndb.Key('atti', Add_Data_Key).get()

        if AttributeExists != None:
            self.redirect('/')
        else:
            add_b = atti(id=self.request.get('atti_name') + "" +
                         self.request.get('atti_manufacture') + "" +
                         self.request.get('atti_year'))
            add_b.atti_name = self.request.get('atti_name')
            add_b.atti_manufacture = self.request.get('atti_manufacture')
            add_b.atti_year = int(self.request.get('atti_year'))
            add_b.atti_battery_size = int(
                self.request.get('atti_battery_size'))
            add_b.atti_WLTP_range = int(self.request.get('atti_WLTP_range'))
            add_b.atti_cost = int(self.request.get('atti_cost'))
            add_b.atti_power = int(self.request.get('atti_power'))
            add_b.put()

        template_values = {'url': url, 'url_string': url_string, 'user': user}

        template = JINJA_ENVIRONMENT.get_template('add.html')
        self.response.write(template.render(template_values))
Beispiel #7
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        url_string = ''
        url = ''
        user = users.get_current_user()
        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        Raw_Data = MyUser.query()
        Search_KeyWord = self.request.get('search')
        Result = []
        Found = Raw_Data.filter(MyUser.email_address == Search_KeyWord).fetch()
        if Found == []:
            Found = Raw_Data.filter(MyUser.userId == Search_KeyWord).fetch()
            if Found == []:
                Raw_Data = Raw_Data.fetch()
                for i in range(0,len(Raw_Data)):
                    if Raw_Data[i].email_address.find(Search_KeyWord) != -1:
                        Result.append(Raw_Data[i].email_address)
                    elif Raw_Data[i].userId.find(Search_KeyWord) != -1:
                        Result.append(Raw_Data[i].email_address)
            else:
                Result.append(Found[0].email_address)
        else:
            Result.append(Found[0].email_address)

        template_values = {
             'url' : url,
             'url_string' : url_string,
             'user' : user,
             'Result' : Result,
        }
        template = JINJA_ENVIRONMENT.get_template('search.html')
        self.response.write(template.render(template_values))
Beispiel #8
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        taskBoard = self.request.get('taskBoarddata')
        email = self.request.get('email')
        taskBoard_key = taskBoard + "" + email
        user = users.get_current_user()
        available_email_id = []
        length_task_data = 0

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        available_email_id = MyUser.query().fetch()
        taskboard_data = ndb.Key('taskBoarddata', taskBoard_key).get()
        assigned_users = taskboard_data.email_address
        task_data = ndb.Key('taskdata', taskBoard_key).get()
        if task_data != None:
            length_task_data = len(task_data.Title)

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'available_email_id': available_email_id,
            'taskboard_data': taskboard_data,
            'task_data': task_data,
            'length_task_data': length_task_data,
            'assigned_users': assigned_users
        }

        template = JINJA_ENVIRONMENT.get_template('invite.html')
        self.response.write(template.render(template_values))
Beispiel #9
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        url_string = ''
        url = ''
        userfollower = 0
        userfollowing = 0
        newfollower = ""
        user = users.get_current_user()
        if user:
            email = self.request.get('email_address')
            if email == "":
                email = user.email()
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()
            collect = ndb.Key('followerfollowing', email).get()
            if collect != None:
                if collect.following != None:
                    newfollower = collect.follower
                else:
                    newfollower = []
            else:
                newfollower = []
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'userfollower': userfollower,
            'userfollowing': userfollowing,
            'newfollower': newfollower,
        }

        template = JINJA_ENVIRONMENT.get_template('follower.html')
        self.response.write(template.render(template_values))
Beispiel #10
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        taskBoard = ''
        add = ''
        user = users.get_current_user()
        data = []
        all_values = []

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            all_values = myuser.taskboard
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        i = 0
        while i < len(all_values):
            taskboard_NameValue = ndb.Key('taskBoarddata', all_values[i]).get()
            data.append(taskboard_NameValue)
            i = i + 1

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'Value_data': data
        }

        template = JINJA_ENVIRONMENT.get_template('taskBoard.html')
        self.response.write(template.render(template_values))
Beispiel #11
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        url_string = ''
        url = ''
        collection_key = []
        user = users.get_current_user()
        upload_url = ""

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            upload_url = blobstore.create_upload_url('/photocomment')
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()

            collection_key = ndb.Key('post', user.email())
            collection_key = collection_key.get()
            if collection_key == None:
                collection_key = post(id=user.email())
                collection_key.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'collection_key': collection_key,
            'upload_url': upload_url,
        }

        template = JINJA_ENVIRONMENT.get_template('photocomment.html')
        self.response.write(template.render(template_values))
Beispiel #12
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        user = users.get_current_user()
        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'

            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()

            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()

        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        edit_atti_name = self.request.GET.get('atti_name')
        edit_atti_manufacture = self.request.GET.get('atti_manufacture')
        edit_atti_year = self.request.GET.get('atti_year')
        atti_Key = edit_atti_name + '' + edit_atti_manufacture + '' + edit_atti_year
        details = ndb.Key('atti', atti_Key)
        details = details.get()

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'details': details
        }

        template = JINJA_ENVIRONMENT.get_template('editDelete.html')
        self.response.write(template.render(template_values))
Beispiel #13
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        taskBoard = ''
        addTask = ''
        addTaskBoard = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        TaskBoardName = self.request.get('taskBoarddata')
        OwnerName = self.request.get('email')
        data = ndb.Key('taskBoarddata', TaskBoardName+""+OwnerName).get()

        template_values = {
             'url' : url,
             'url_string' : url_string,
             'user' : user,
             'data' : data
        }

        template = JINJA_ENVIRONMENT.get_template('addTask.html')
        self.response.write(template.render(template_values))
Beispiel #14
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        compare = ''


        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.user_id())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        Comparision_Data = atti.query()

        template_values = {
             'url' : url,
             'url_string' : url_string,
             'user' : user,
             'Compare_Data' : Comparision_Data
        }

        template = JINJA_ENVIRONMENT.get_template('compare.html')
        self.response.write(template.render(template_values))
Beispiel #15
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        TaskBoardName = self.request.get('taskBoarddata')
        OwnerName = self.request.get('email')
        TaskNameFromUser = self.request.get('TaskName')
        Due_Date = self.request.get('Due_Date')
        Unique = TaskBoardName+""+OwnerName # task key
        self.response.write(Unique)
        element = []
        in_List = False

        data = ndb.Key('taskBoarddata',Unique).get()
        TaskData = ndb.Key('taskdata',Unique).get()
        if TaskData != None:
            element = TaskData.Title

            i = 0
            while i < len(element):
                if element[i] == TaskNameFromUser:
                    in_List = True
                    break
                else:
                    in_List = False
                    i = i + 1

        if in_List == True:
            self.redirect('/')
        else:
            if len(element) == 0:
                add_data = taskdata(id=Unique)
                add_data.Title.append(TaskNameFromUser)
                add_data.Due_Date.append(Due_Date)
                add_data.Task_Completion.append("Not Complete")
                add_data.Task_assigned.append("Not Assigned")
                add_data.Date.append("Not Complete")
                add_data.Time.append("Not Complete")
                add_data.put()
                self.redirect('/invite?taskBoarddata='+TaskBoardName+'&email='+OwnerName)
            else:
                add_data = ndb.Key('taskdata',Unique).get()
                add_data.Title.append(TaskNameFromUser)
                add_data.Due_Date.append(Due_Date)
                add_data.Task_Completion.append("Not Complete")
                add_data.Task_assigned.append("Not Assigned")
                add_data.Date.append("Not Complete")
                add_data.Time.append("Not Complete")
                add_data.put()
                self.redirect('/invite?taskBoarddata='+TaskBoardName+'&email='+OwnerName)

        template_values = {
            'url' : url,
            'url_string' : url_string,
            'user' : user,
            'data' : data
            }

        template = JINJA_ENVIRONMENT.get_template('addTask.html')
        self.response.write(template.render(template_values))
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        collection = []
        Caption = []
        length = 0
        userfollower = 0
        userfollowing = 0
        userfollower1 = 0
        userfollowing1 = 0
        newEmail = self.request.get('email_address')
        newUsers = ndb.Key('MyUser',newEmail).get()
        user = users.get_current_user()
        followDecission = "False"
        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                myuser.userId = user.nickname()
                welcome = 'Welcome to the application'
                myuser.put()

            collection_key = ndb.Key('post',newUsers.userId)
            collection_key = collection_key.get()
            if collection_key != None:
                i = len(collection_key.photo_url) - 1
                while i > -1:
                    collection.append(collection_key.photo_url[i])
                    Caption.append(collection_key.caption[i])
                    i = i - 1
                length = len(collection)
            newUserFFList = ndb.Key('followerfollowing',newEmail).get()
            if newUserFFList != None:
                userfollower = len(newUserFFList.follower)
                userfollowing = len(newUserFFList.following)
            oldUsersEmail =  myuser.email_address
            collect = ndb.Key('followerfollowing',oldUsersEmail).get()
            if collect != None:
                for i in collect.following:
                    if i == newEmail:
                        followDecission = 'True'
                        break
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        template_values = {
             'url' : url,
             'url_string' : url_string,
             'user' : user,
             'collection' : collection,
             'Caption' : Caption,
             'length' : length,
             'newUsers' : newUsers,
             'newEmail' : newEmail,
             'userfollower': userfollower,
             'userfollowing': userfollowing,
             'userfollower1': userfollower1,
             'userfollowing1': userfollowing1,
             'followDecission' : followDecission,
        }
        template = JINJA_ENVIRONMENT.get_template('newUsers.html')
        self.response.write(template.render(template_values))
Beispiel #17
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()
            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        Atti_Name = self.request.get('atti_name')
        Atti_Manufacture = self.request.get('atti_manufacture')
        Atti_Year_From = self.request.get('atti_year_from')
        Atti_Year_To = self.request.get('atti_year_to')
        Atti_battery_size_from = self.request.get('atti_battery_size_from')
        Atti_battery_size_to = self.request.get('atti_battery_size_to')
        Atti_WLTP_range_from = self.request.get('atti_WLTP_range_from')
        Atti_WLTP_range_to = self.request.get('atti_WLTP_range_to')
        Atti_cost_from = self.request.get('atti_cost_from')
        Atti_cost_to = self.request.get('atti_cost_to')
        Atti_power_from = self.request.get('atti_power_from')
        Atti_power_to = self.request.get('atti_power_to')

        Raw_Data = atti.query()

        if self.isEmpty(Atti_Name) != True and self.isEmpty(
                Atti_Manufacture) != True and self.isEmpty(
                    Atti_Year_From) != True and self.isEmpty(
                        Atti_Year_To) != True:
            Atti_Year_From = int(Atti_Year_From)
            Atti_Year_To = int(Atti_Year_To)
            Data_Query1 = Raw_Data.filter(
                atti.atti_name == Atti_Name
                and atti.atti_manufacture == Atti_Manufacture
                and atti.atti_year >= Atti_Year_From)
            Data_Query2 = Raw_Data.filter(
                atti.atti_name == Atti_Name
                and atti.atti_manufacture == Atti_Manufacture
                and atti.atti_year <= Atti_Year_To)
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))

        elif self.isEmpty(Atti_Name) != True and self.isEmpty(
                Atti_Manufacture) != True:
            Data_Query = Raw_Data.filter(
                atti.atti_name == Atti_Name
                and atti.atti_manufacture == Atti_Manufacture)
            Data = Data_Query.fetch()

        elif (self.isEmpty(Atti_Name) !=
              True) and (self.isEmpty(Atti_Year_From) !=
                         True) and (self.isEmpty(Atti_Year_To) != True):
            Atti_Year_From = int(Atti_Year_From)
            Atti_Year_To = int(Atti_Year_To)
            Data_Query1 = Raw_Data.filter(atti.atti_name == Atti_Name)
            Data_Query2 = Raw_Data.filter(atti.atti_year <= Atti_Year_To)
            Data_Query3 = Raw_Data.filter(atti.atti_year >= Atti_Year_From)
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data_Query3 = Data_Query3.fetch(keys_only=True)
            Data = ndb.get_multi(
                set(Data_Query1).intersection(Data_Query2, Data_Query3))

        elif (self.isEmpty(Atti_Manufacture) !=
              True) and (self.isEmpty(Atti_Year_From) !=
                         True) and (self.isEmpty(Atti_Year_To) != True):
            Atti_Year_From = int(Atti_Year_From)
            Atti_Year_To = int(Atti_Year_To)
            Data_Query1 = Raw_Data.filter(
                atti.atti_manufacture == Atti_Manufacture)
            Data_Query2 = Raw_Data.filter(atti.atti_year >= Atti_Year_From)
            Data_Query3 = Raw_Data.filter(atti.atti_year <= Atti_Year_To)
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data_Query3 = Data_Query3.fetch(keys_only=True)
            Data = ndb.get_multi(
                set(Data_Query1).intersection(Data_Query2, Data_Query3))

        elif self.isEmpty(Atti_Name) != True:
            Data_Query = Raw_Data.filter(atti.atti_name == Atti_Name)
            Data = Data_Query.fetch()

        elif self.isEmpty(Atti_Manufacture) != True:
            Data_Query = Raw_Data.filter(
                atti.atti_manufacture == Atti_Manufacture)
            Data = Data_Query.fetch()

        elif self.isEmpty(Atti_Year_From) != True and self.isEmpty(
                Atti_Year_To) != True:
            Atti_Year_From = int(Atti_Year_From)
            Atti_Year_To = int(Atti_Year_To)
            Data_Query1 = Raw_Data.filter(atti.atti_year >= Atti_Year_From)
            Data_Query2 = Raw_Data.filter(atti.atti_year <= Atti_Year_To)
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))
        else:
            Data = ''

        if self.isEmpty(Atti_battery_size_from) != True and self.isEmpty(
                Atti_battery_size_to) != True:
            Atti_battery_size_from = int(Atti_battery_size_from)
            Atti_battery_size_to = int(Atti_battery_size_to)
            Data_Query1 = Raw_Data.filter(
                atti.atti_battery_size >= int(Atti_battery_size_from))
            Data_Query2 = Raw_Data.filter(
                atti.atti_battery_size <= int(Atti_battery_size_to))
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))

        if self.isEmpty(Atti_WLTP_range_from) != True and self.isEmpty(
                Atti_WLTP_range_to) != True:
            Atti_WLTP_range_from = int(Atti_WLTP_range_from)
            Atti_WLTP_range_to = int(Atti_WLTP_range_to)
            Data_Query1 = Raw_Data.filter(
                atti.atti_WLTP_range >= int(Atti_WLTP_range_from))
            Data_Query2 = Raw_Data.filter(
                atti.atti_WLTP_range <= int(Atti_WLTP_range_to))
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))

        if self.isEmpty(Atti_cost_from) != True and self.isEmpty(
                Atti_cost_to) != True:
            Atti_cost_from = int(Atti_cost_from)
            Atti_cost_to = int(Atti_cost_to)
            Data_Query1 = Raw_Data.filter(
                atti.atti_cost >= int(Atti_cost_from))
            Data_Query2 = Raw_Data.filter(atti.atti_cost <= int(Atti_cost_to))
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))

        if self.isEmpty(Atti_power_from) != True and self.isEmpty(
                Atti_power_to) != True:
            Atti_power_from = int(Atti_power_from)
            Atti_power_to = int(Atti_power_to)
            Data_Query1 = Raw_Data.filter(
                atti.atti_power >= int(Atti_power_from))
            Data_Query2 = Raw_Data.filter(
                atti.atti_power <= int(Atti_power_to))
            Data_Query1 = Data_Query1.fetch(keys_only=True)
            Data_Query2 = Data_Query2.fetch(keys_only=True)
            Data = ndb.get_multi(set(Data_Query1).intersection(Data_Query2))

        if len(Data) != 0:
            Final_Data = Data
        else:
            Final_Data = Raw_Data.fetch()

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'Search_Data': Final_Data
        }

        template = JINJA_ENVIRONMENT.get_template('searchElement.html')
        self.response.write(template.render(template_values))
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        compare = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()
            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        checkboxdata = {}
        checkboxdata = self.request.get_all('checkboxdata')
        ErrorMessage = 0
        Attributes_All_Data = {}
        if len(checkboxdata) < 2:
            ErrorMessage = 1
            Total_Data = []
        else:
            i = 0
            while i < len(checkboxdata):
                Attribute_Data = ndb.Key('atti', checkboxdata[i])
                Attributes_All_Data[i] = Attribute_Data.get()
                i = i + 1
            i = 0
            year = []
            battery = []
            wltp = []
            cost = []
            power = []

            while i < len(checkboxdata):
                year.append(Attributes_All_Data[i].atti_year)
                battery.append(Attributes_All_Data[i].atti_battery_size)
                wltp.append(Attributes_All_Data[i].atti_WLTP_range)
                cost.append(Attributes_All_Data[i].atti_cost)
                power.append(Attributes_All_Data[i].atti_power)
                i = i + 1

            Total_Data = [
                min(year),
                max(year),
                min(battery),
                max(battery),
                min(wltp),
                max(wltp),
                min(cost),
                max(cost),
                min(power),
                max(power)
            ]

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'ErrorMessage': ErrorMessage,
            'Attributes_All_Data': Attributes_All_Data,
            'Total_Data': Total_Data
        }

        template = JINJA_ENVIRONMENT.get_template('compareElements.html')
        self.response.write(template.render(template_values))
Beispiel #19
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        taskBoard = ''
        add = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'
            myuser_details = ndb.Key('MyUser', user.email())
            myuser = myuser_details.get()
            if myuser == None:
                myuser = MyUser(id=user.email())
                myuser.email_address = user.email()
                welcome = 'Welcome to the application'
                myuser.put()
        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'
            self.redirect('/')

        call_tb = self.request.get('taskBoarddata')
        call_user = self.request.get('email')
        all_call = call_tb + "" + call_user
        user_select_email = self.request.get('select_email_id')
        taskBoard_a = ndb.Key('taskBoarddata', all_call).get()
        option = self.request.get('submit')
        select_to_remove_email_id = self.request.get(
            'select_to_remove_email_id')

        if option == 'Invite':
            if taskBoard_a.owner == user.email():
                section = False
                if user_select_email != "":
                    new_myuser = ndb.Key('MyUser', user_select_email).get()
                    if new_myuser != None:
                        call = new_myuser.taskboard
                        i = 0
                        while i < len(call):
                            if call[i] == all_call:
                                section = True
                                break
                            else:
                                i = i + 1
                    if section == True:
                        self.redirect('/taskBoard')
                    else:
                        new_myuser.taskboard.append(all_call)
                        new_myuser.put()
                        taskBoard_a.email_address.append(user_select_email)
                        taskBoard_a.put()
                        self.redirect('/invite?taskBoarddata=' + call_tb +
                                      '&email=' + call_user)
                else:
                    self.redirect('/taskBoard')
            else:
                self.redirect('/taskBoard')

        elif option == 'Remove':
            if taskBoard_a.owner == user.email():
                if select_to_remove_email_id != "":
                    new_myuser = ndb.Key('MyUser',
                                         select_to_remove_email_id).get()
                    taskData = ndb.Key('taskdata', all_call).get()
                    if taskData != None:
                        k = 0
                        while k in range(0, len(taskData.Title)):
                            if taskData.Task_assigned[
                                    k] == select_to_remove_email_id:
                                taskData.Task_assigned[k] = "Not Assigned"
                            else:
                                k = k + 1
                    j = 0
                    while j in range(0, len(taskBoard_a.email_address)):
                        if taskBoard_a.email_address[
                                j] == select_to_remove_email_id:
                            del taskBoard_a.email_address[j]
                            break
                        else:
                            j = j + 1
                    i = 0
                    while i in range(0, len(new_myuser.taskboard)):
                        if new_myuser.taskboard[i] == all_call:
                            del new_myuser.taskboard[i]
                            taskData.put()
                            taskBoard_a.put()
                            new_myuser.put()
                            break
                        else:
                            i = i + 1
                    self.redirect('/invite?taskBoarddata=' + call_tb +
                                  '&email=' + call_user)
            else:
                self.redirect('/taskBoard')

        elif option == "Rename":
            tb_new = self.request.get('taskboard_NewName')
            check_exist = ndb.Key('taskBoarddata',
                                  tb_new + "" + call_user).get()
            if check_exist == None:
                task_Old = ndb.Key('taskdata', all_call).get()
                if task_Old != None:
                    task_connect = taskdata(id=tb_new + "" + call_user)
                    task_connect.Title = task_Old.Title
                    task_connect.Due_Date = task_Old.Due_Date
                    task_connect.Task_Completion = task_Old.Task_Completion
                    task_connect.Task_assigned = task_Old.Task_assigned
                    task_connect.Date = task_Old.Date
                    task_connect.Time = task_Old.Time
                    task_connect.put()
                    task_Old.key.delete()

                tb_Old = ndb.Key('taskBoarddata', all_call).get()
                tb_connect = taskBoarddata(id=tb_new + "" + call_user)
                tb_connect.taskBoarddata = tb_new
                tb_connect.email_address = tb_Old.email_address
                email_id = tb_connect.email_address
                tb_connect.owner = tb_Old.owner

                i = 0
                while i in range(0, len(email_id)):
                    user_db = ndb.Key('MyUser', email_id[i]).get()
                    if user_db != None:
                        j = 0
                        while j in range(0, len(user_db.taskboard)):
                            if user_db.taskboard[j] == all_call:
                                user_db.taskboard[j] = tb_new + "" + call_user
                                user_db.put()
                                j = j + 1
                            else:
                                j = j + 1
                        i = i + 1
                    else:
                        i = i + 1
                tb_connect.put()
                tb_Old.key.delete()
                self.redirect('/invite?taskBoarddata=' + tb_new + '&email=' +
                              call_user)
            else:
                self.redirect('/taskBoard')

        available_email_id = MyUser.query().fetch()
        taskboard_data = ndb.Key('taskBoarddata', all_call).get()

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'available_email_id': available_email_id,
            'taskboard_data': taskboard_data
        }

        template = JINJA_ENVIRONMENT.get_template('invite.html')
        self.response.write(template.render(template_values))
Beispiel #20
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        url_string = ''
        url = ''
        add = ''
        search = ''
        user = users.get_current_user()

        if user:
            url = users.create_logout_url(self.request.uri)
            url_string = 'logout'

            myuser_key = ndb.Key('MyUser', user.user_id())
            myuser = myuser_key.get()

            if myuser == None:
                welcome = 'Welcome to the application'
                myuser = MyUser(id=user.user_id())
                myuser.email_address = user.email()
                myuser.put()

        else:
            url = users.create_login_url(self.request.uri)
            url_string = 'login'

        if user:
            edit_atti_name = self.request.GET.get('atti_name')
            edit_atti_manufacture = self.request.GET.get('atti_manufacture')
            edit_atti_year = self.request.GET.get('atti_year')
            atti_Key = edit_atti_name + '' + edit_atti_manufacture + '' + edit_atti_year

            if self.request.get('Button') == 'Delete':
                ndb.Key('atti', atti_Key).delete()
                self.redirect('/')
                add_b = ''
            else:
                ndb.Key('atti', atti_Key).delete()
                add_b = atti(id=self.request.get('atti_name_new') + "" +
                             self.request.get('atti_manufacture_new') + "" +
                             self.request.get('atti_year_new'))
                add_b.atti_name = self.request.get('atti_name_new')
                add_b.atti_manufacture = self.request.get(
                    'atti_manufacture_new')
                add_b.atti_year = int(self.request.get('atti_year_new'))
                add_b.atti_battery_size = int(
                    self.request.get('atti_battery_size_new'))
                add_b.atti_WLTP_range = int(
                    self.request.get('atti_WLTP_range_new'))
                add_b.atti_cost = int(self.request.get('atti_cost_new'))
                add_b.atti_power = int(self.request.get('atti_power_new'))
                add_b.put()
        else:
            add_b = ''
            self.redirect('/')

        template_values = {
            'url': url,
            'url_string': url_string,
            'user': user,
            'details': add_b
        }

        template = JINJA_ENVIRONMENT.get_template('editDelete.html')
        self.response.write(template.render(template_values))