def requests():
    if request.method == 'POST':
        if request.form['request'] == 'isSnaptaFriend':
            r = backend.update(request.form['username'], request.form['auth_token'])

            if r == False:
                return redirect(url_for('logout'))
            session['added_friends_timestamp'] = r['added_friends_timestamp']
            if session['snapta_changed'] == 'false':
                if session['snapta'] == True:
                    return 'friends'
                else:
                    return 'nofriends'
            else:
                if session['snapta'] == True:
                    return 'nofriends'
                else:
                    return 'friends'
        elif request.form['request'] =='isWhisperSubscribed':
            r = backend.update(request.form['username'], request.form['auth_token'])
            if r == False:
                return redirect(url_for('logout'))
            if session['wf_changed'] == 'false':
                if session['whisperfeed'] == True:
                    return 'yes'
                else:
                    return 'no'
            else:
                if session['whisperfeed'] == True:
                    return 'no'
                else:
                    return 'yes'
        elif request.form['request'] == 'isWhisperChanged':
            if session["wf_changed"] == 'true':
                return "yes"
            else:
                return "no"


        elif request.form['request'] == 'makeFriend':   
            r = backend.makeFriend(request.form['username'], request.form['auth_token'], request.form['friend'])
            if r == 200:
                if request.form['friend'] == 'secret_snapta':
                    session['snapta_changed'] = 'true'
                elif request.form['friend'] == 'whisper_feed':
                    session['wf_changed'] = 'true'

                return 'true'
            else:
                return 'false'
        elif request.form['request'] == 'deleteFriend':
            r = backend.deleteFriend(request.form['username'], request.form['auth_token'], request.form['friend'])
            if r == 200:
                if request.form['friend'] == 'secret_snapta':
                    session['snapta_changed'] = 'true'
                elif request.form['friend'] == 'whisper_feed':
                    session['wf_changed'] = 'true'
                return 'true'
            else:
                return 'false'
        elif request.form['request'] == 'getFriends':
            r = backend.update(request.form['username'], request.form['auth_token'])
            if r == False:
                return redirect(url_for('logout'))
            session['added_friends_timestamp'] = r['added_friends_timestamp']
            return jsonify(r)
def updateselected():
    print selectedtuple[0], title.get(), Author.get(), Year.get(), isbn.get()
    backend.update(selectedtuple[0], title.get(), Author.get(), Year.get(),
                   isbn.get())
def update_command():
    backend.update(selected_tuple[0], title_text.get(), author_text.get(),
                   year_text.get(), isbn_text.get())
    list1.delete(0, END)
    for row in backend.view():
        list1.insert(END, row)
Beispiel #4
0
def updateFunction():
    backend.update(selectedTuple[0], titleText.get(), authorText.get(),
                   yearText.get(), ISBNText.get())
Beispiel #5
0
def update_command():
    backend.update(selectedTuple[0], nameText.get(), emailText.get(),
                   phoneText.get())
    contactList.delete(0, END)
    for i in backend.view():
        contactList.insert(END, i)
Beispiel #6
0
 def update(self, table, set, condition):
     bc.update(table, set, condition)
Beispiel #7
0
def update_command():
    #be careful for the next line ---> we are updating using the texts in the entries, not the selected tuple
    backend.update(selected_tuple[0],title_text.get(), author_text.get(), year_text.get(), ISBN_text.get())
    view_command()
def update_command():
    backend.update(selected_tuple[0], title_text.get(), quantity_text.get(),
                   price_text.get())
Beispiel #9
0
def update_command():
    backend.update(
        selected_tuple[0], client_text.get(), email_text.get(),
        phone_text.get(), address_text.get()
    )  #Index number doesn't get deleted/updated but everything else can be.
Beispiel #10
0
def update():
    backend.update(selected_tuple[0], titleText.get(), authorText.get(),
                   yearText.get(), isbnText.get())
    viewAll()
Beispiel #11
0
def to_change_status():
    backend.update(selected_tuple,only_date,Task_Title.get(), Task_Detail.get(),Status.get())
 def update_command(self):
     """Update entry via button."""
     backend.update(self.selected_tuple[0], self.title.get(), self.author.get(), self.year.get(), self.isbn.get(), self.lang.get(), self.placed.get())
Beispiel #13
0
def updateFunction():
    list1.delete(0, END)
    backend.update(selectedTuple[0], e1.get(), e3.get(), e2.get(), e4.get())
    list1.insert(END, (e1.get(), e3.get(), e2.get(), e4.get()))
Beispiel #14
0
def update_command():
    backend.update(selected_tuple[0], title_text.get(), author_text.get(), year_text.get(), isbn_text.get())
Beispiel #15
0
def update(args):
    backend.update(args.task, args.source)
    backend.sync(args.task, args.source)
Beispiel #16
0
 def update_book(self, title, author, date_published, number_of_pages,
                 type_book):
     backend.update(title, author, date_published, number_of_pages,
                    type_book)
Beispiel #17
0
def update_command():
    backend.update(values[0], Title_value.get(), Author_value.get(),
                   Year_value.get(), ISBN_value.get())
Beispiel #18
0
def update():

    backend.update(selected[0], Title.get(), Author.get(), Year.get(),
                   ISBN.get())
def update_command():
    backend.update(selected_row[0], first_name_text.get(),
                   last_name_text.get(), email_text.get(), age_text.get())
Beispiel #20
0
def update_command():
    backend.update(selected_tuple[0], titletext.get(), authortext.get(), yeartext.get(), isbntext.get())
    view_command()
    statusbar.config(text=("Updated", selected_tuple[0], titletext.get(), authortext.get(), yeartext.get(), isbntext.get()))
    statusbar.update_idletasks()
Beispiel #21
0
def update(message_id):
    data = request.form.to_dict()
    print(data)
    backend.update(message_id, data)
    return redirect('/viewall.html')
Beispiel #22
0
    def post(self):
        """
        Handle a POST request to the API.
        
        Take a list of actions from a POST request, and do the appropriate
        action. See the documentation for this module for more information.
        
        @raise common.InputError: If no search targets are given in the target
        POST variable or if an invalid action is given.
        """
        cpu_start = quota.get_request_cpu_usage()
        
        action = self.request.get("action")
        target = self.request.get("target", "public")
        spectra = self.request.get_all("spectrum") #Some of these will be in session data
        limit = self.request.get("limit", 10)
        offset = self.request.get("offset", 0)
        algorithm = self.request.get("algorithm", "bove")
        guess = self.request.get("guess")
        spectrum_type = self.request.get("type")
        raw = self.request.get("raw", False)
        session = appengine_utilities.sessions.Session()
        user = users.get_current_user()
        response = []
        
        # First check if the user has gone over quota.
        if session.get("cpu_usage") > self.CPU_LIMIT:
            raise common.ServerError("User has gone over quota.")
        
        spectra = [open('jcamp-test.jdx').read()] # Just for testing

        # If not operating on the main project, try getting the private one.
        # But abort if target is not supposed to be a project.
        if target and target != "public":
            target = backend.Project.get(target)
            if target is None:
                raise common.InputError(targets, "Invalid project ID.")
        # Start doing the request
        if action == "compare" and target == "public":
            # Search the database for something.
            for spectrum in spectra:
                # User wants to commit a new search with a file upload.
                result = backend.search(spectrum)
                # Extract relevant information and add to the response.
                response = [(str(i.key()), i.chemical_name, i.error, i.graph_data) for i in result]
        elif action == "compare":
            # Compare multiple spectra uploaded in this session.
            response.append(backend.compare(spectra, algorithm))
        elif action == "browse":
            # Get a list of spectra from the database for browsing
            backend.auth(user, target, "view")
            # Return the database key, name, and chemical type.
            results = [(str(spectrum.key()), spectrum.chemical_name, spectrum.chemical_type)
                       for spectrum in backend.browse(target, limit, offset, guess, spectrum_type)]
            response.extend(results)
        elif action == "add":
            # Add a new spectrum to the database. Supports multiple spectra.
            backend.auth(user, target, "spectrum")
            for spectrum_data in spectra:
                backend.add(spectrum_data, target, False)
        elif action == "bulkadd":
            # Add a new spectrum to the database. Supports multiple spectra.
            if session.key().name() != "uploader":
                raise common.AuthError(user, "Only the uploader can bulkadd.")
            for spectrum_data in spectra:
                backend.add(spectrum_data, target, True)
        elif action == "delete":
            # Delete a spectrum from the database.
            backend.auth(user, target, "spectrum")
            for spectrum_data in spectra:
                backend.delete(spectrum_data, target)
        elif action == "update":
            backend.auth(user, "public", "spectrum")
            backend.update()
        elif action == "projects":
            query = "WHERE :1 IN owners OR :1 IN collaborators OR :1 in viewers"
            response.extend([(proj.key(), proj.name) for proj in Project.gql(query, user)])
        else:
            # Invalid action. Raise an error.
            raise common.InputError(action, "Invalid API action.")
        # Pass it on to self.output for processing.
        self.output(response)
Beispiel #23
0
def update_command():
    backend.update(d, title_text.get(), author_text.get(), year_text.get(),
                   genre_text.get(), rate_text.get(), actor_text.get())
    view_command()
Beispiel #24
0
def update_command():
    # Defintion of the function that triggers backend update function when
    # update button is pushed
    backend.update(selected_tuple[0],title_text.get(),author_text.get(),year_text.get(),
    isbn_text.get())
Beispiel #25
0
def update_command():
    backend.update(selected_tuple[0], entry_title.get(), entry_author.get(),
                   entry_year.get(), entry_id.get())
Beispiel #26
0
def update_command():
    backend.update(int(id_text.get()),status_text.get(),country_text.get(),city_text.get(),startdate_text.get(),enddate_text.get(),\
    team_text.get(),name_text.get(),maintask_text.get(),address_text.get(),telno_text.get())
    view_command()
def update_command():
    backend.update(selected[0], titleText.get(), authorText.get(),
                   yearText.get(), isbnText.get())
    print("It's deleted ")
def update_command():
    """Update entry via button."""
    # global selected_tuple
    backend.update(selected_tuple[0], title_text.get(), author_text.get(),
                   year_text.get(), isbn_text.get())
Beispiel #29
0
def update_button():
    backend.update(id, title.get(), author.get(), year.get(), isbn.get())
    view_button()
Beispiel #30
0
def update_book():
    backend.update(select_tup[0], title_text.get(), author_text.get(),
                   year_text.get(), isbn_text.get())
Beispiel #31
0
def update_command():
    backend.update(select_tuple[0], title_text.get(), course_text.get(),
                   due_text.get(), details_text.get())
def update_command():
    backend.update(selected_tuple[0],title_text.get(),author_text.get(),year_text.get(),isbn_text.get())
Beispiel #33
0
def update_command():
    backend.update(a2_value.get(), a4_value.get(), b2_value.get(),
                   b4_value.get(), selected_item[0])
    c1.delete(0, END)
    [c1.insert(END, item) for item in backend.view()]