本文整理汇总了Python中models.Note类的典型用法代码示例。如果您正苦于以下问题:Python Note类的具体用法?Python Note怎么用?Python Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Note类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
def index(request):
if request.GET:
new_data = ''
data = request.GET.get('text')
if 'shifr' == request.GET.get('command'):
step = int(request.GET.get('code'))
else:
step = -int(request.GET.get('code'))
capital_letters = [chr(letter) for letter in range(65, 91)]
capital_letters_step = [capital_letters[(i+step+26) % 26] for i in range(0, 26)]
low_letters = [chr(letter) for letter in range(97, 123)]
low_letters_step = [low_letters[(i+step+26) % 26] for i in range(0, 26)]
for letter in data:
if letter in capital_letters:
new_data += capital_letters_step[(ord(letter)-65) % 26]
elif letter in low_letters:
new_data += low_letters_step[(ord(letter)-97) % 26]
else:
new_data += letter
note = Note(shifr=request.GET.get('text'), ROT=int(request.GET.get('code')), label=request.GET.get('label'))
note.save()
return HttpResponse(JsonResponse({'text': new_data }))
else:
form = ShifrForm()
context = {
'form': form,
}
return render(request, 'content.html', context)
示例2: _create_note
def _create_note(self, user, file_name, file_path):
note = Note(parent=ndb.Key("User", user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
#note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
if not item_title:
continue
item = CheckListItem(title=item_title)
#item.put()
#note.checklist_items.append(item.key)
note.checklist_items.append(item)
#item = CheckListItemObject(title=item_title)
#note.checklist_items.append(item)
if file_name and file_path:
url, thumbnail_url = self._get_urls_for(file_name)
f = NoteFile(parent=note.key, name=file_name,
url=url, thumbnail_url=thumbnail_url,
full_path=file_path)
f.put()
note.files.append(f.key)
note.put()
示例3: _create_note
def _create_note(self, user, file_name, file_path):
note = Note(parent=ndb.Key("User", user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
note.put()
# Retrieve csv representing checklist items
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
if not item_title:
continue
# create a checklist instance
item = CheckListItem(parent = note.key, title = item_title)
# store each checklist
item.put()
# after storing it, we can access the key to append it to the note
note.checklist_items.append(item.key)
if file_name and file_path:
url, thumbnail_url = self._get_urls_for(file_name)
f = NoteFile(parent=note.key, name=file_name,
url=url, thumbnail_url=thumbnail_url,
full_path=file_path)
f.put()
note.files.append(f.key)
# update the note entity with the checklist items
note.put()
示例4: post_note
def post_note():
note = Note()
note.message = bottle.request.forms.get("message")
note.hashtags = extract_hashtags(note.message)
persistence.insert_note(note)
bottle.redirect("")
示例5: handle_uploaded_json_file
def handle_uploaded_json_file(f, user):
def convert_date(str_date):
new_str = str_date.replace('+00:00','')
try:
new_dt = datetime.strptime(new_str, '%Y-%m-%d %H:%M:%S.%f')
except ValueError:
new_dt = datetime.strptime(new_str, '%Y-%m-%d %H:%M:%S')
return new_dt
with open('notes.json', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
f.close()
with open('notes.json', 'r') as fh:
json_data = json.load(fh)
fh.close()
version, notes = json_data
# for user in User.objects.all():
# if not Folder.)objects.filter(user = user, name = "Main").exists():
# folder = Folder(name="Main", user = user)
# folder.save()
# if not Folder.objects.filter(user = user, name = ")Trash").exists():
# folder = Folder(name="Trash", user = u)ser)
# folder.save()
for note in notes:
created_at = convert_date(note['created_at'])
title = note['title']
username = note['user']
# TODO: If user is blank we need to assign to a default user. For now just skip.
# Its technically a database integrity violation anyway.
if username is None: continue
user = User.objects.get(username = username)
if not Note.objects.filter(title = title,
created_at = created_at).exists():
new_note = Note()
new_note.title = title
new_note.created_at = created_at
new_note.modified_at = convert_date(note['modified_at'])
new_note.note_type = note['post_type']
new_note.note = note['note']
foldr = note['folder']
try:
folder = Folder.objects.get(name = foldr, user = user)
except Folder.DoesNotExist:
folder = Folder(name = foldr, user = user)
folder.save()
new_note.folder = folder
new_note.user = user
new_note.save()
示例6: create_tables
def create_tables():
from models import User, Message, Note, Relationship, City, Pinche
# User.create_table()
Relationship.create_table()
Note.create_table()
Message.create_table()
City.create_table()
Pinche.create_table()
示例7: note_add
def note_add(request, event_id):
event = get_object_or_404(Event, pk=event_id)
if request.method == 'POST': # If the form has been submitted...
form = NoteForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
note = Note(event=event, user=request.user, note = form.cleaned_data['note'])
note.save()
messages.success(request, _("Saved note"))
return HttpResponseRedirect(reverse('event', args=[event.id]))
示例8: create
def create(self):
if request.method == 'POST':
if request.form.get('message'):
Note.create(
user=auth.get_logged_in_user(),
message=request.form['message'],
)
next = request.form.get('next') or self.dashboard_url()
return redirect(next)
示例9: note_insert
def note_insert(self, note):
if note.from_datastore:
note_with_parent = note
else:
note_with_parent = Note(parent=main.get_parent_key(endpoints.get_current_user()),
note = note.note, company_entity_key = note.company_entity_key)
note_with_parent.put()
return note_with_parent
示例10: create
def create(self):
if not users.get_current_user():
webapp2.abort(401)
form = NoteForm(self.get_locale(), self.request.POST, None)
if self.request.POST and form.validate():
note = Note(author=users.get_current_user(), **form.data)
note.date = datetime.now()
note.put()
return self.redirect('/note/list')
self.render_template('form.html', {'title': _('Note'), 'form': form, 'name': 'note'})
示例11: homepage
def homepage():
if request.method == 'POST':
if request.form.get('content'):
note = Note.create(content=request.form['content'])
rendered = render_template('note.html', note=note)
return redirect(url_for('homepage'))
return jsonify({'success': False})
notes = Note.public().limit(50)
return render_template('homepage.html', notes=notes)
示例12: finish_plan_api
def finish_plan_api():
pk = flask.request.form.get('pk')
user_id = flask.session['user_id']
plan = Plan.fetchone(pk=pk)
if not plan:
raise error.PlanNoteFound()
plan_log = PlanLog()
plan_log.user_id = user_id
plan_log.plan_id = plan.pk
plan_log.create_at = datetime.now()
plan_log.update_at = datetime.now()
plan_log.is_enable = 1
plan_log.save(commit=False)
for item in plan.plan_items:
note = Note()
note.kind_id = item.kind.pk
note.user_id = user_id
note.quantity = item.quantity
note.plan_log_id = plan_log.pk
note.create_at = datetime.now()
note.update_at = datetime.now()
note.save()
return {'pk': pk}
示例13: get
def get(self):
if 'X-AppEngine-Cron' not in self.request.headers:
self.error(403)
przedszkole = iPrzedszkole('<nazwa przedszkola>', '<uzytkownik>', '<haslo>')
menu = przedszkole.jadlospis()
if menu is None:
menu = "Weekend :)"
note = Note(id='jadlospis')
note.kindergartenMenu = menu
note.put()
memcache.set(key='jadlospis', value=note.kindergartenMenu, time=expirationTime)
示例14: homepage
def homepage():
if not session.get('logged_in'):
return redirect(url_for('login'))
if request.method == 'POST':
if request.form.get('content'):
note = Note.create(content=request.form['content'])
flash('New entry posted')
return redirect(url_for('homepage'))
notes = Note.public().paginate(get_page(), 50)
return render_template('homepage.html', notes=notes)
示例15: add_note
def add_note(self, message, user):
if message:
note = Note(activity=self.object)
note.message = message
note.user = user
note.save()
messages.success(self.request, 'Note added successfully.')
return True
else:
messages.error(self.request, 'Message cannot be empty.')
return False