本文整理汇总了Python中models.Note类的典型用法代码示例。如果您正苦于以下问题:Python Note类的具体用法?Python Note怎么用?Python Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Note类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:MaistrenkoAnton,项目名称:cezarcode,代码行数:29,代码来源:views.py
示例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()
开发者ID:PacktPublishing,项目名称:Python-for-Google-App-Engine,代码行数:30,代码来源:main.py
示例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()
开发者ID:vishalsanfran,项目名称:gcloud-apps,代码行数:31,代码来源:main.py
示例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("")
开发者ID:DarylOosten,项目名称:hash-note,代码行数:7,代码来源:hash_notes.py
示例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()
开发者ID:Burrito-Bazooka,项目名称:logos-v2,代码行数:58,代码来源:views.py
示例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()
开发者ID:lite,项目名称:pinche,代码行数:9,代码来源:app.py
示例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]))
开发者ID:rangermeier,项目名称:subkoord,代码行数:9,代码来源:views.py
示例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)
开发者ID:sekenned,项目名称:totb,代码行数:9,代码来源:admin.py
示例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
开发者ID:11samype,项目名称:rose_career_fair,代码行数:9,代码来源:career_fair_api.py
示例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'})
开发者ID:jkpluta,项目名称:jkpluta,代码行数:10,代码来源:notes.py
示例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)
开发者ID:bearzk,项目名称:try_peewee,代码行数:10,代码来源:views.py
示例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}
开发者ID:jie,项目名称:sportsapp,代码行数:26,代码来源:app.py
示例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)
开发者ID:maciejszewczyk,项目名称:leniwy-ojciec-gae,代码行数:11,代码来源:main.py
示例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)
开发者ID:bayang,项目名称:calepin,代码行数:11,代码来源:views.py
示例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
开发者ID:cs130-tec-tracking,项目名称:cs130-tec-tracking,代码行数:11,代码来源:views.py
示例16: test_book_autodelete
def test_book_autodelete(self):
note1 = Note(text='text')
note1.save()
note2 = Note(text='text')
note2.save()
book = Book(title='title')
book.save()
book.notes.add(*[note1, note2])
note1.delete()
self.assertTrue(Book.objects.all())
note2.delete()
self.assertFalse(Book.objects.all())
开发者ID:gowa66,项目名称:Andrey_Gorshunow_test_livarava,代码行数:12,代码来源:tests.py
示例17: createNote
def createNote(request):
username = request.POST['username']
note = request.POST['note']
date_time = helpers.get_datetime(note)
newNote = Note(user=username, text_body=note, time=date_time)# TODO: START and EXPIRATION date objects
newNote.save()
# SHOULD REDIRECT TO LOGIN PAGE
return redirect("index")
开发者ID:TheRealAkhil,项目名称:YoRo,代码行数:12,代码来源:views.py
示例18: _create_note
def _create_note(self,user):
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:
item = CheckListItem(parent=note.key,title=item_title)
item.put()
note.checklist_items.append(item.key)
note.put()
开发者ID:sky5497,项目名称:vantansy,代码行数:12,代码来源:main.py
示例19: save
def save(self, account):
cd = self.cleaned_data
note = Note(
amount=cd['amount'],
timestamp=cd['timestamp'],
description=cd['description'],
category=cd['category'],
account=account
)
note.save()
account.balance = account.balance + cd['amount']
account.save()
开发者ID:belate,项目名称:money,代码行数:12,代码来源:forms.py
示例20: homepage
def homepage():
if request.method == 'POST':
if request.form.get('content'):
# New note
note = Note.create(content = request.form['content'])
# Make a note panel and jsonify
rendered = render_template('note.html', note = note)
return jsonify({'note': rendered, 'success': True})
# no content, return failure
return jsonify({'success': False})
notes = Note.public().limit(50)
return render_template('homepage.html', notes = notes)
开发者ID:raincrash,项目名称:LinkBox,代码行数:14,代码来源:views.py
注:本文中的models.Note类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论