def add(): user = Users("Debabrata", "Patnaik") form = BookmarkForm() form.userform.data = user.getfullname()[:3] # if request.method == "POST": # url = request.form["url"] # user = request.form.get("user","Deb") # store_bookmarks(url, user) # app.logger.debug("Stored URL: " + url) # flash("Stored URL: " + url) # return redirect(url_for('index')) # return render_template("add.html") if form.validate_on_submit(): print form.url.data, form.description.data try: print form.userform except Exception, exc: print exc url = form.url.data description = form.description.data user = form.userform.data store_bookmarks(url, user, description) app.logger.debug("Stored URL: " + url) flash("Stored URL: {}".format(url)) return redirect(url_for("index"))
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data destination = form.destination.data outbound_date = form.outbound_date.data outbound_time = form.outbound_time.data inbound_date = form.inbound_date.data inbound_time = form.inbound_time.data tags = form.tags.data bm = Bookmark(user=current_user, url=url, description=description, destination=destination, tags=tags, outbound_date=outbound_date, outbound_time=outbound_time, inbound_date=inbound_date, inbound_time=inbound_time) db.session.add(bm) db.session.commit() flash("Stored trip '{}'".format(description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add a Trip")
def add_bookmark(): """ Add a bookmark to the database """ add_bookmark = True form = BookmarkForm() if form.validate_on_submit(): bookmark = Bookmark(name=form.name.data, url=form.url.data, description=form.description.data, user_id=current_user.id) try: # add bookmark to the database db.session.add(bookmark) db.session.commit() flash('You have successfully added a new bookmark.') except: # in case bookmark name already exists flash('Error: bookmark name already exists.') # redirect to bookmarks page return redirect(url_for('profile.list_bookmarks')) # load bookmark template return render_template('profile/bookmarks/bookmark.html', action="Add", add_bookmark=add_bookmark, form=form, title="Add Bookmark")
def edit_bookmark(id): """ Edit a bookmark """ add_bookmark = False bookmark = Bookmark.query.get_or_404(id) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): bookmark.name = form.name.data bookmark.url = form.url.data bookmark.description = form.description.data db.session.commit() flash('You have successfully edited the bookmark.') # redirect to the bookmarks page return redirect(url_for('profile.list_bookmarks')) form.description.data = bookmark.description form.url.data = bookmark.url form.name.data = bookmark.name return render_template('profile/bookmarks/bookmark.html', action="Edit", add_bookmark=add_bookmark, form=form, bookmark=bookmark, title="Edit Bookmark")
def add_bookmark(request): """ This view serves and validates a bookmark form. If requested via ajax it also returns the drop bookmark form to replace the add bookmark form. """ if request.method == "POST": form = BookmarkForm(user=request.user, data=request.POST) if form.is_valid(): bookmark = form.save() if not request.is_ajax(): messages.success(request, 'Bookmark added') if request.POST.get('next'): return HttpResponseRedirect(request.POST.get('next')) return HttpResponse('Added') return render_to_response('admin_tools/menu/remove_bookmark_form.html', RequestContext(request, { 'bookmark': bookmark, 'url': bookmark.url, })) else: form = BookmarkForm(user=request.user) return render_to_response('admin_tools/menu/form.html', RequestContext(request, { 'form': form, 'title': 'Add Bookmark', }))
def add_bookmark(request): """ This view serves and validates a bookmark form. If requested via ajax it also returns the drop bookmark form to replace the add bookmark form. """ if request.method == "POST": form = BookmarkForm(user=request.user, data=request.POST) if form.is_valid(): bookmark = form.save() if not request.is_ajax(): request.user.message_set.create(message='Bookmark added') if request.POST.get('next'): return HttpResponseRedirect(request.POST.get('next')) return HttpResponse('Added') return TemplateResponse(request, 'client_admin/menu/remove_bookmark_form.html', context={ 'bookmark': bookmark, 'url': bookmark.url, }) else: form = BookmarkForm(user=request.user) return TemplateResponse(request, 'client_admin/menu/form.html', context={ 'form': form, 'title': 'Add Bookmark', })
def add(): form = BookmarkForm() if form.validate_on_submit(): url, description = form.url.data, form.description.data store_bookmark(url, description) flash(f"stored url: {url}") return redirect(url_for('index')) return render_template('add.html', form=form)
def bookmark_create(request): if request.method == 'POST': form = BookmarkForm(data=request.POST) if form.is_valid(): form.save(owner=request.user) return redirect('game_bookmark_user', username=request.user.username) else: form = BookmarkForm() return render(request, 'game/form.html', {'form': form, 'create': True})
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("Stored bookmark '{}'".format(description)) return redirect(url_for("index")) return render_template("add.html", form=form)
def addBookmark(request): if request.POST: form = BookmarkForm(request.POST) if form.is_valid(): mark = form.save(commit=False) mark.user_id = auth.get_user(request).id mark.save() just_print.delay(mark) return redirect('/bookmarks/')
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("You have successfully bookmarked {}".format(url)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("Stored bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash(f'Stored {description}') app.logger.debug(f'Stored {url} as {description}') return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() # If method=GET OR form-content is invalid, then... if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("Stored bookmark '{}'".format(url)) return redirect(url_for('index')) return render_template('add.html', form=form)
def save_bookmark(request, bookmark_id=False): if request.is_ajax: return ajax_save_bookmark(request, bookmark_id) form = BookmarkForm() bookmark = get_object_or_None(Bookmark, pk=bookmark_id) if bookmark: form = BookmarkForm(instance=bookmark) if not request.user.is_authenticated() or ( not request.user.is_staff and (bookmark.note.author == request.user)): return HttpResponseRedirect(reverse(list, args=(note.id, ))) if request.method == "POST": if bookmark: form = BookmarkForm(request.POST, instance=bookmark) else: form = BookmarkForm(request.POST) if form.is_valid(): if not bookmark: bookmark = Bookmark() bookmark.save() if 'text' in form.cleaned_data: bookmark.text = form.cleaned_data['text'] if 'chart' in form.cleaned_data: bookmark.chart = form.cleaned_data['chart'] if 'tags' in form.cleaned_data: bookmark.tags = form.cleaned_data['tags'] if 'note' in form.cleaned_data: bookmark.note = form.cleaned_data['note'] bookmark.save() return HttpResponseRedirect( reverse(save_bookmark, kwargs={ "bookmark_id": bookmark.id, })) return render_to_response('notes/form_page.html', {'form': form}, context_instance=RequestContext(request))
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data #url = request.form['url'] #getting data from 'form' dictionary(works with request reference) store_bookmark(url, description) flash('Bookmark saved: {}'.format(description)) #app.logger.debug('stored url:' + url) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(url = url, description = description) db.session.add(bm) db.session.commit() flash("Store '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(url=url, description=description) db.session.add(bm) db.session.commit() flash("Stored '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def edit(self, bookmark_id): if not users.get_current_user(): webapp2.abort(401) bookmark = db.get(db.Key.from_path('Bookmark', int(bookmark_id))) form = BookmarkForm(self.get_locale(), self.request.POST, bookmark) if self.request.POST and form.validate(): form.populate_obj(bookmark) bookmark.date = datetime.now() bookmark.put() return self.redirect('/bookmark/list') self.render_template('form.html', {'title': _('Bookmark'), 'form': form, 'name': 'bookmark', 'id': bookmark.key().id()})
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) # app.logger.debug('stored_url: ' + url) flash("store_bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def edit_bookmark(bookmark_id): bookmark = Bookmark.query.get_or_404(bookmark_id) if current_user != bookmark.user: abort(403) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash("Stored '{}'".format(bookmark.description)) return redirect(url_for('user', username=current_user.username)) return render_template('bookmark_form.html', form=form, title="Edit Trip")
def add(): form = BookmarkForm() if form.validate_on_submit(): db.session.add( Bookmark(user=logged_in_user(), url=form.obj.data, description=form.description.data)) db.session.commit() flash("Stored description {}".format(form.description.data)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() # On a GET request, the fields are empty and the form variables are also empty. On a POST request, the variables are full. This will likely only work because the action was "", as that means it referring to a still available form to read the values of if form.validate_on_submit(): # This line also checks to make sure the method is not GET url = form.url.data description = form.description.data bm = models.Bookmark(user=logged_in_user(), url=url, description=description) db.session.add(bm) db.session.commit() flash("Stored '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form) # form=form is sent because the template is actually using the form to populate the DOM with form fields
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description=form.description.data store_bookmark(url,description) # app.logger.debug('stored url %s' % url) flash("Stored bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html',Text="1232",form=form)
def edit_bookmark(bookmark_id): bookmark = Bookmark.query.get_or_404(bookmark_id) if current_user != bookmark.user: abort(403) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash("Stored %s" % bookmark.description) return redirect(url_for('user',username=current_user.username)) return render_template('edit.html',form=form,title='Edit Bookmark')
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(user=logged_in_user(), url=url, description=description) db.session.add(bm) db.session.commit() flash("Stored bookmak '{}'.".format(description)) return redirect(url_for("index")) return render_template("add.html", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = request.form['url'] bm = Bookmark(user=current_user, url=url) db.session.add(bm) db.session.commit() application.logger.debug('URL:' + url) flash("Stored url: {}".format(url)) return redirect(url_for('return_200')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): # url = request.form['url'] # store_bookmark(url) url = form.url.data description = form.description.data store_bookmark(url, description) flash("please find below list of URLs.") flash("Bookmark is :- '{}'".format(url)) return redirect(url_for('hello')) return render_template('Add.html', form=form)
def add_bookmark(): form = BookmarkForm() # checks http request and form if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(url=url, description=description) db.session.add(bm) db.session.commit() flash(f"stored bookmark: {url}") return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data tags = form.tags.data bm = Bookmark(user=current_user,url=url,description=description,tags=tags) db.session.add(bm) db.session.commit() flash("Bookmark Successfully Added") return redirect(url_for('index')) return render_template('add.html',form=form)
def editUrl(bookmarkid): bookmark = bookmarkDB.query.get(bookmarkid) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash("Successfully edited the bookmark") return redirect(url_for("user", userid=current_user.id)) return render_template('addUrlForm.html', form=form, user=current_user, title="Edit bookmark")
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data tags = form.tags.data bm = Bookmark(user=current_user, url=url, description=description, tags=tags) db.session.add(bm) db.session.commit() flash("Stored '{}'".format(bm.description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add a bookmark")
def bookmark_edit(request, pk): bookmark = get_object_or_404(Bookmark, pk=pk) if bookmark.owner != request.user and not request.user.is_superuser: raise PermissionDenied if request.method == 'POST': form = BookmarkForm(instance=bookmark, data=request.POST) if form.is_valid(): form.save() return redirect('game_bookmark_user', username=request.user.username) else: form = BookmarkForm(instance=bookmark) return render(request, 'game/form.html', {'form': form, 'create': False, 'bookmark': bookmark})
def edit_bookmark(id): b = g.user.bid(id) form = BookmarkForm(obj=b) if not b: abort(403) if form.validate_on_submit(): form.populate_obj(b) b.updated = datetime.utcnow() db.session.add(b) db.session.commit() flash("Bookmark %s updated" % (form.title.data), category="info") return redirect(url_for("index")) return render_template("edit.html", title="Edit", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() flash(f'stored bookmark {description}', 'success') return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add form")
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() # app.logger.debug('stored url: ' + url) flash("stored '{}' ".format(description)) return redirect(url_for('index')) return render_template("add.html", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(url=url, description=description, user=current_user) db.session.add(bm) db.session.commit() flash('Stored bookmark: {}'.format(url)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title='Add Bookmark')
def create(request): if request.method == 'POST': # If the form has been submitted... form = BookmarkForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass bookmark = form.save() return HttpResponseRedirect(reverse('bookmark_index')) # Redirect after POST else: form = BookmarkForm() # An unbound form return render_to_response('create.html', RequestContext(request, { 'form': form, }))
def edit_bookmark(id): b = g.user.bid(id) form = BookmarkForm(obj=b) if not b: abort(403) if form.validate_on_submit(): form.populate_obj(b) b.updated = datetime.utcnow() db.session.add(b) db.session.commit() flash('Bookmark %s updated' % (form.title.data), category='info') return redirect(url_for('index')) return render_template('edit.html', title='Edit', form=form)
def edit_bookmark(bookmark_id): bookmark = Bookmark.query.get_or_404(bookmark_id) if current_user != bookmark.user: abort(403) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash('Your bookmark was saved succesfully') return redirect(url_for('main.user', username=current_user.username)) return render_template('bookmark_form.html', form=form, title='Edit Bookmark')
def add_bookmark(): if not session.get('logged_in'): abort(401) form = BookmarkForm(request.form) if request.method == 'POST' and form.validate(): if form.url.data and form.description.data: author = User.query.filter_by(username=session.get('username')).first() bookmark = Bookmark(form.url.data, form.description.data, datetime.utcnow(), author) db.session.add(bookmark) db.session.commit() flash('New bookmark saved successfully') else: flash('URL is required.') return redirect(url_for('show_bookmarks'))
def edit_bookmark(bookmark_id): bookmark = models.Bookmark.query.get_or_404(bookmark_id) print(type(bookmark)) if current_user != bookmark.user: abort(403) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash('Stored {}'.format(bookmark.description), "success") return redirect(url_for('user', username=current_user.username)) return render_template('bookmark_form.html', form=form, title='Edit Bookmark')
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(url=url, description=description, user=current_user) db.session.add(bm) db.session.commit() app.logger.debug('stored url ' + url) flash("Stored '{0}'".format(description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title='Add new bookmark')
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data tags = form.tags.data bm = Bookmark(user=current_user, url=url, description=description, tags=tags) db.session.add(bm) db.session.commit() flash("Bookmark Successfully Added") return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=logged_user(), url=url, description=description) db.session.add( bm) # TODO the object has been aleady added through manage.initdb db.session.commit() flash('Stored bookmark "{}"'.format(url)) app.logger.debug('strored url: ' + url) # @TODO print in debug mode return redirect(url_for('index')) return render_template('add.html', form=form)
def bookmark(request): if not request.user.is_authenticated(): return HttpResponseRedirect('/login/?next=%s' % request.META['HTTP_REFERER']) try: bookmark = Bookmark.objects.get( user=request.user, content_type=request.POST['content_type'], object_id=request.POST['object_id'], ) return HttpResponseRedirect(bookmark.content_object.get_absolute_url()) except Exception, e: bookmark = Bookmark(user=request.user) bookmarkform = BookmarkForm(request.POST, instance=bookmark) bookmark = bookmarkform.save() return HttpResponseRedirect(bookmark.content_object.get_absolute_url())
def create(self, parent_id=None): if not users.get_current_user(): webapp2.abort(401) form = BookmarkForm(self.get_locale(), self.request.POST, None) if self.request.POST and form.validate(): parent = None if form.reference_id.data: parent = db.get(db.Key.from_path('Bookmark', int(form.reference_id.data))) bookmark = Bookmark(author=users.get_current_user(), reference=parent, title=form.title.data, url=form.url.data) bookmark.date = datetime.now() bookmark.put() return self.redirect('/bookmark/list') else: if parent_id: form.reference_id.data = parent_id self.render_template('form.html', {'title': _('Bookmark'), 'form': form, 'name': 'bookmark'})
def edit_bookmark(request, id): bookmark = get_object_or_404(Bookmark, id=id) if request.method == "POST": form = BookmarkForm(user=request.user, data=request.POST, instance=bookmark) if form.is_valid(): form.save() if not request.is_ajax(): request.user.message_set.create(message='Bookmark updated') if request.POST.get('next'): return HttpResponseRedirect(request.POST.get('next')) return HttpResponse('Saved') else: form = BookmarkForm(user=request.user, instance=bookmark) return TemplateResponse(request, 'client_admin/menu/form.html', context={ 'form': form, 'title': 'Edit Bookmark', })
def new_bookmark(): form = BookmarkForm() if form.validate_on_submit(): b = Bookmark() form.populate_obj(b) b.owner_id = g.user.id b.created = datetime.utcnow() b.tags = " ".join([t.strip() for t in form.tags.data.strip().split(",")]).lower() b.clicks = 0 if not form.title.data: soup = BSoup(urlopen(form.url.data)) b.title = soup.title.string db.session.add(b) db.session.commit() flash("New bookmark %s added" % (b.title), category="info") return redirect(url_for("index")) return render_template("new.html", title="New", form=form)
def create_bookmark(request): form = BookmarkForm() if request.method == 'GET' and request.GET: form = BookmarkForm(initial=request.GET) elif request.method == 'POST': form = BookmarkForm(request.POST) if form.is_valid(): data = form.cleaned_data labels = str_to_labels(data.pop('labels')) bookmark = Bookmark(**data) bookmark.author = request.user bookmark.save() bookmark.labels = labels bookmark.save() return HttpResponseRedirect(reverse("bookmarks.views.bookmark_list", args=[])) return render_to_response('bookmarks/bookmark_form.html', {'form': form, 'labels': Label.objects.all()}, context_instance=RequestContext(request))
def new(request): if request.method != 'POST': return redirect('/') user = get_object_or_404(User, id=request.session.get('id', None)) item = get_object_or_404(Item, id=request.POST.get('item', None)) form = BookmarkForm(request.POST) if form.is_valid(): # lists = request.POST.getlist('lists'); list = request.POST.get('list', None) url = request.POST.get('url', None) # 如果文本框和item的url不一致说明用户修改过url 所以跳到404页面 if item.url != url: raise Http404 # return render(request, 'debug.html', {'debug': [item.url, url]}) l = get_object_or_404(List, id=list) private = request.POST.get('private', None) if private: pvalue = 1 else: pvalue = 0 d = form.save(commit=False) d.item = item d.private = pvalue d.user = user d.list = l d.url = item.url d.save() #更新有多少用户收藏了这个书签 item.favorites = item.bookmark_set.exclude(private=1).count() item.save() #更新list bookmark的数量 l.bookmarks = Bookmark.objects.filter(user=user, list=list).count() l.save() user.update_bookmarks() return redirect('/home/') lists = user.list_set.all() return render(request, 'bookmark/new.html', {'form': form, 'lists': lists, 'item': item})
def update(request, bookmark_id): try: bookmark = Bookmark.objects.get(id=bookmark_id) except Bookmark.DoesNotExist: raise Http404 if request.method == 'POST': # If the form has been submitted... form = BookmarkForm(request.POST, instance=bookmark) if form.is_valid(): # All validation rules pass bookmark = form.save() return HttpResponseRedirect(reverse('bookmark_index')) # Redirect after POST else: form = BookmarkForm(instance=bookmark) return render_to_response('update.html', RequestContext(request, { 'form': form, }))
def edit_bookmark(request, id): bookmark = get_object_or_404(Bookmark, id=id) if request.method == "POST": form = BookmarkForm(user=request.user, data=request.POST, instance=bookmark) if form.is_valid(): form.save() if not request.is_ajax(): messages.success(request, 'Bookmark updated') if request.POST.get('next'): return HttpResponseRedirect(request.POST.get('next')) return HttpResponse('Saved') else: form = BookmarkForm(user=request.user, instance=bookmark) return render_to_response('admin_tools/menu/form.html', RequestContext(request, { 'form': form, 'title': 'Edit Bookmark', }))
def add(): form = BookmarkForm() if form.validate_on_submit(): # time_of_day = form.time_of_day.data food_word_1 = form.food_word_1.data food_word_2 = form.food_word_2.data food_word_3 = form.food_word_3.data amount_1 = form.amount_1.data amount_2 = form.amount_2.data amount_3 = form.amount_3.data weather = form.weather.data mood = form.mood.data bm = Bookmark(user=current_user, food_word_1=food_word_1, food_word_2=food_word_2, food_word_3=food_word_3, amount_1=amount_1, amount_2=amount_2, amount_3=amount_3, weather=weather, mood=mood) db.session.add(bm) db.session.commit() # flash("Stored '{}'".format(food_word_1, food_word_2, food_word_3 )) return redirect(url_for('index')) return render_template('add.html', form=form)
def edit_bookmark(request, bookmark_id): bookmark = get_object_or_404(Bookmark, id=bookmark_id) form = BookmarkForm(initial={ 'address': bookmark.address, 'title': bookmark.title, 'labels': labels_to_str(bookmark.labels.all()), 'notes': bookmark.notes, }) if request.method == 'POST': form = BookmarkForm(request.POST) if form.is_valid(): data = form.cleaned_data bookmark.title = data['title'] bookmark.address = data['address'] bookmark.notes = data['notes'] bookmark.labels = str_to_labels(data['labels']) bookmark.save() return HttpResponseRedirect(reverse("bookmarks.views.view_bookmarks", args=[])) return render_to_response('bookmarks/bookmark_form.html', {'form': form, 'bookmark': bookmark}, context_instance=RequestContext(request))
if bookmark.user.id != request.session.get('id', None): raise Http404 if bookmark.item is None: try: item = Item.objects.get(url=bookmark.url) except Exception, e: title = get_bookmark_title(bookmark.url) item = Item(url=bookmark.url, title=title.encode('utf-8'), favorites=1) item.save() bookmark.item = item bookmark.save() item.favorites = item.bookmark_set.count() item.save() form = BookmarkForm(initial={'title':bookmark.title}) if request.method == 'POST': form = BookmarkForm(request.POST) if form.is_valid(): list = get_object_or_404(List, id=request.POST.get('list', None)) if bookmark.item.url != request.POST.get('url', None) or bookmark.item.id != int(request.POST.get('item', None)): raise Http404 bookmark.title = request.POST.get('title') private = request.POST.get('private', None) if private: pvalue = 1 else: pvalue = 0