Example #1
0
    def _create_note(self, user, title, content, attachments):

        note = Note(parent=ndb.Key("User", user.nickname()),
                    title=title,
                    content=content)
        note.put()

        if attachments:
            bucket_name = app_identity.get_default_gcs_bucket_name()
            for file_name, file_content in attachments:
                content_t = mimetypes.guess_type(file_name)[0]
                real_path = os.path.join('/', bucket_name, user.user_id(), file_name)

                with cloudstorage.open(real_path, 'w', content_type=content_t,
                                       options={'x-goog-acl': 'public-read'}) as f:
                    f.write(file_content.decode())

                key = blobstore.create_gs_key('/gs' + real_path)
                try:
                    url = images.get_serving_url(key, size=0)
                    thumbnail_url = images.get_serving_url(key, size=150, crop=True)
                except images.TransformationError, images.NotImageError:
                    url = "http://storage.googleapis.com{}".format(real_path)
                    thumbnail_url = None

                f = NoteFile(parent=note.key, name=file_name,
                             url=url, thumbnail_url=thumbnail_url,
                             full_path=real_path)
                f.put()
                note.files.append(f.key)

            note.put()
    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()
Example #3
0
    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()  
Example #4
0
    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'))

        item_titles = self.request.get('checklist_items').split(',')
        for item_title in item_titles:
            if not item_title:
                continue
            item = CheckListItem(title=item_title)
            note.checklist_items.append(item)

        note.put()

        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()

        inc_note_counter()
Example #5
0
    def _create_note(self, user, title, content, attachments):

        note = Note(parent=ndb.Key("User", user.nickname()),
                    title=title,
                    content=content)
        note.put()

        if attachments:
            bucket_name = app_identity.get_default_gcs_bucket_name()
            for file_name, file_content in attachments:
                content_t = mimetypes.guess_type(file_name)[0]
                real_path = os.path.join('/', bucket_name, user.user_id(), file_name)

                with cloudstorage.open(real_path, 'w', content_type=content_t,
                                       options={'x-goog-acl': 'public-read'}) as f:
                    f.write(file_content.decode())

                key = blobstore.create_gs_key('/gs' + real_path)
                try:
                    url = images.get_serving_url(key, size=0)
                    thumbnail_url = images.get_serving_url(key, size=150, crop=True)
                except images.TransformationError, images.NotImageError:
                    url = "http://storage.googleapis.com{}".format(real_path)
                    thumbnail_url = None

                f = NoteFile(parent=note.key, name=file_name,
                             url=url, thumbnail_url=thumbnail_url,
                             full_path=real_path)
                f.put()
                note.files.append(f.key)

            note.put()
Example #6
0
    def post(self):
        user = users.get_current_user()
        if user is None:
            self.error(401)

        self._create_note(user)

        note = Note(title=self.request.get('title'),
                    content=self.request.get('content'))
        note.put()

        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()

        logout_url = users.create_logout_url(self.request.uri)
        template_context = {
            'user': user.nickname(),
            'logout_url': logout_url,
        }
        self.response.out.write(template.render(template_context))

        def _render_template(self, template_name, context=None):
            if context is None:
                context = {}

            user = users.get_current_user()
            ancestor_key = ndb.Key("User", user.nickname())
            qry = Note.owner_query(ancestor_key)
            context['notes'] = qry.fetch()

            template = jinja_env, get_template(template_name)
            return template.render(context)

            self.response.out.write(
                self._render_template('main.html', template_context))

        @ndb.transactional
        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()
 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
Example #8
0
 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'})
Example #9
0
 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)
    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
Example #11
0
 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()
Example #12
0
    def post(self):
        print("Done.")

        note = Note(
                img = self.request.get('img'), 
                describe = self.request.get('desc'),
                )

        note.put()
        
        template = jinja_env.get_template('./templates/map.html')
        self.response.out.write(template.render())
Example #13
0
   def post(self):
      user = users.get_current_user()
      if user is None:
         self.error(401)

      self._create_note(user) 

      note = Note(title = self.request.get('title'),content = self.request.get('content'))
      note.put()

      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()

      logout_url = users.create_logout_url(self.request.uri)
      template_context = {
         'user': user.nickname(),
         'logout_url': logout_url,
      }
      self.response.out.write(template.render(template_context))

      def _render_template(self, template_name, context=None):
         if context is None:
            context = {}

         user = users.get_current_user()
         ancestor_key = ndb.Key("User", user.nickname())
         qry = Note.owner_query(ancestor_key)
         context['notes'] = qry.fetch()
 

         template = jinja_env,get_template(template_name)
         return template.render(context)

         self.response.out.write(self._render_template('main.html', template_context))

      @ndb.transactional
      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()
Example #14
0
    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()
Example #15
0
    def get(self):
        if 'X-AppEngine-Cron' not in self.request.headers:
            self.error(403)
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(),
                                      urllib2.HTTPHandler(debuglevel=1))
        req = urllib2.Request(url)
        req.add_header('User-Agent', userAgent)
        opener.open(req)

        data_stage1 = {'pesel': pesel, 'akcja': 'sprawdzpesel'}

        encoded_data_stage1 = urllib.urlencode(data_stage1)
        req = urllib2.Request(url)
        req.add_data(encoded_data_stage1)
        req.add_header('User-Agent', userAgent)
        opener.open(req)

        data_stage2 = {
            'imie': imie,
            'nazwisko': nazwisko,
            'pesel': pesel,
            'akcja': 'login',
            'pin': pin
        }

        encoded_data_stage2 = urllib.urlencode(data_stage2)
        req = urllib2.Request(url)
        req.add_data(encoded_data_stage2)
        req.add_header('User-Agent', userAgent)
        result = opener.open(req).read().decode('iso-8859-2')
        zlobek1 = re.search(
            r"<li>I  wybor ZLOBEK nr <strong>%s</strong>  --> MIEJSCE: <strong> (\d+)</strong>"
            % nursery_no1, result)
        zlobek1 = zlobek1.group(1)
        zlobek2 = re.search(
            r"<li>II wybor ZLOBEK nr <strong>%s</strong> --> MIEJSCE: <strong> (\d+)</strong>"
            % nursery_no2, result)
        zlobek2 = zlobek2.group(1)
        zlobek3 = re.search(
            r"<li>III wybor ZLOBEK nr <strong>{}</strong> --> MIEJSCE: <strong> (\d+)</strong>"
            .format(nursery_no3), result)
        zlobek3 = zlobek3.group(1)

        id_date = datetime.datetime.now().strftime("%Y-%m-%d")
        note = Note(id=id_date,
                    db_nursery_no1=int(zlobek1),
                    db_nursery_no2=int(zlobek2),
                    db_nursery_no3=int(zlobek3))
        note.put()
        logging.info("!! INFO !! CRON on {} Z1:{} Z2:{} Z3:{}".format(
            id_date, zlobek1, zlobek2, zlobek3))
Example #16
0
 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)
Example #17
0
    def _create_note(self, user):
        #create "note" as an object instance of the class "Note".  Included here must be all parts of the class
        #example = User, title, content
        note = Note(parent=ndb.Key("User", user.nickname()),
                    title=self.request.get('title'),
                    content=self.request.get('content'))
        #object name "note" will upload the information to something
        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()
Example #18
0
    def POST(self):
        user = users.get_current_user()
        form = form_add_note()
        object = {}
        if form.validates():
            object["success"] = True
            object["response"] = form.d.note
            note = Note(author=user, name=form.d.note, tags=form.d.ntag_list.split(","))

            note.put()
            object["message"] = "New note has been created"
        else:
            object["success"] = False
            object["errors"] = form.get_errors()
            object["message"] = "Note has not been created"
        return simplejson.dumps(object)
Example #19
0
    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_sales:
            item = CheckListItem(parent=note.key, title=item_title)
            item.put()
            note.checklist_items.append(item.key)

        note.put()

        def get(self):
            user = users.get_current_user()
            if user is not None:
                logout_url = users.create_logout_url(self.request.uri)
                template_context = {
                    'user': user.nickname(),
                    'logout_url': logout_url,
                }
                self.response.out.write(
                    self.render_template('main.html', template_context))
            else:
                login_url = users.create_login_url(self.request.uri)
                self.redirect(login_url)

        def post(self):
            user = users.get_current_user()
            if user is None:
                self.error(401)

            self._create_note(user)

            logout_url = users.create_logout_url(self.request.uri)
            template_context = {
                'user': user.nickname(),
                'logout_url': logout_url,
            }
            self.response.out.write(
                self._render_template('main.html', template_context))
Example #20
0
def list_notes():
    notes = Note.query()
    # Convert body of each note to marked-up markdown
    for note in notes:
        note.body = Markup(markdown.markdown(note.body))
    form = NoteForm()
    if form.validate_on_submit():
        note = Note(title=form.note_title.data,
                    slug=slugify(form.note_title.data),
                    body=form.note_body.data,
                    author=users.get_current_user())
        try:
            note.put()
            note_id = note.key.id()
            flash(u'Note %s saved.' % note_id, 'success')
            return redirect(url_for('list_notes'))
        except CapabilityDisabledError:
            flash(u'Datastore is in read-only mode.', 'info')
            return redirect(url_for('list_notes'))
    return render_template('dynamic_notes.html', notes=notes, form=form)
Example #21
0
    def post(self):
        user = self.user
        if user:
            content = self.request.get('note')
            note = Note()
            note.content = content
            note.user = user.key
            note.put()

            # show confirma   tion of successful post creation
            template_values = {
                'message': 'Note created successfully'
            }

            templates.render_page("notes/created", template_values, self)
        else:
            # error about login
            return

        return
Example #22
0
 def insert(self, note):
     logging.debug('inserting note: %s' % str(note))
     note_model = NoteModel(name=note.name,
                            type=note.type,
                            meeting_id=note.meeting_id,
                            time=note.time,
                            start_time_delta=note.start_time_delta,
                            assignee=note.assignee,
                            description=note.description)
     note_key = note_model.put()
     logging.debug('successfully inserted note, id %d' % note_key.id())
     return note_key.id()
Example #23
0
    def post(self):
        user = users.get_current_user()
        if user is None:
            self.error(401)

        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()

        logout_url = users.create_logout_url(self.request.uri)
        template_context = {
            'user': user.nickname(),
            'logout_url': logout_url,
        }
        self.response.out.write(self._render_template('main.html', template_context))
Example #24
0
    def post(self):
        user = users.get_current_user()

        if user is None:
            self.error(401)

        ancestor_key = ndb.Key("User", user.nickname())
        qry = Note.owner_query(ancestor_key)
        notes = qry.fetch()

        note = Note(parent=ndb.Key("User", user.nickname()),
                    title=self.request.get('title'),
                    content=self.request.get('content'))
        note.put()

        logout_url = users.create_logout_url(self.request.uri)
        template_context = {
            'user': user.nickname(),
            'logout_url': logout_url,
            'note_title': self.request.get('title'),
            'note_content': self.request.get('content'),
        }
        self.response.out.write(
            self._render_template('main.html', template_context))
Example #25
0
 def createNote(self, data):
     note = Note(author=users.get_current_user(), date=datetime.now(), **data)
     note.put()
     return note
Example #26
0
 def post(self):
     user = users.get_current_user()
     if self.request.get("action") == "Add to Notes":
         note = Note(text=self.request.get("notes_string"), owner=user.user_id(), subject=self.request.get("subject-type"), title=self.request.get("notes_title"))
         note.put()
     self.get()