示例#1
0
  def make_thread( self ):
    title = u"Welcome to the Luminotes %s forum!" % self.forum_name

    # create a notebook thread to go in the forum
    notebook_id = self.database.next_id( Notebook, commit = False )
    thread_notebook = Notebook.create(
      notebook_id,
      title,
    )
    self.database.save( thread_notebook, commit = False )

    anonymous = self.database.select_one( User, User.sql_load_by_username( u"anonymous" ) )

    # add a single welcome note to the new thread
    note_id = self.database.next_id( Note, commit = False )
    note = Note.create(
      note_id,
      u"""
      <h3>%s</h3> You can discuss any Luminotes %s topics here. This is a public discussion
      forum, so please keep that in mind when posting. And have fun.
      """ % ( title, self.forum_name ),
      notebook_id,
      startup = True,
      rank = 0,
      user_id = anonymous.object_id,
      creation = datetime.now(),
    )
    self.database.save( note, commit = False )

    # load the forum tag, or create one if it doesn't exist
    tag = self.database.select_one( Tag, Tag.sql_load_by_name( u"forum", user_id = anonymous.object_id ) )
    if not tag:
      tag_id = self.database.next_id( Tag, commit = False )
      tag = Tag.create(
        tag_id,
        notebook_id = None, # this tag is not in the namespace of a single notebook
        user_id = anonymous.object_id,
        name = u"forum",
        description = u"discussion forum threads"
      )
      self.database.save( tag, commit = False )

    # associate the forum tag with the previously created notebook thread, and set that
    # association's value to forum_name
    self.database.execute(
      anonymous.sql_save_notebook_tag( notebook_id, tag.object_id, value = self.forum_name ),
      commit = False,
    )

    # give the anonymous user access to the new notebook thread
    self.database.execute(
      anonymous.sql_save_notebook( notebook_id, read_write = True, owner = False, own_notes_only = True ),
      commit = False,
    )
示例#2
0
  def setUp( self ):
    self.object_id = u"17"
    self.notebook_id = u"19"
    self.user_id = u"20"
    self.name = u"mytag"
    self.description = u"this is my tag"
    self.value = u"a value"
    self.delta = timedelta( seconds = 1 )

    self.tag = Tag.create( self.object_id, self.notebook_id, self.user_id, self.name,
                           self.description, self.value )
示例#3
0
    def setUp(self):
        self.object_id = u"17"
        self.notebook_id = u"19"
        self.user_id = u"20"
        self.name = u"mytag"
        self.description = u"this is my tag"
        self.value = u"a value"
        self.delta = timedelta(seconds=1)

        self.tag = Tag.create(self.object_id, self.notebook_id, self.user_id,
                              self.name, self.description, self.value)
    def make_thread(self):
        title = u"Welcome to the Luminotes %s forum!" % self.forum_name

        # create a notebook thread to go in the forum
        notebook_id = self.database.next_id(Notebook, commit=False)
        thread_notebook = Notebook.create(
            notebook_id,
            title,
        )
        self.database.save(thread_notebook, commit=False)

        anonymous = self.database.select_one(
            User, User.sql_load_by_username(u"anonymous"))

        # add a single welcome note to the new thread
        note_id = self.database.next_id(Note, commit=False)
        note = Note.create(
            note_id,
            u"""
      <h3>%s</h3> You can discuss any Luminotes %s topics here. This is a public discussion
      forum, so please keep that in mind when posting. And have fun.
      """ % (title, self.forum_name),
            notebook_id,
            startup=True,
            rank=0,
            user_id=anonymous.object_id,
            creation=datetime.now(),
        )
        self.database.save(note, commit=False)

        # load the forum tag, or create one if it doesn't exist
        tag = self.database.select_one(
            Tag, Tag.sql_load_by_name(u"forum", user_id=anonymous.object_id))
        if not tag:
            tag_id = self.database.next_id(Tag, commit=False)
            tag = Tag.create(
                tag_id,
                notebook_id=
                None,  # this tag is not in the namespace of a single notebook
                user_id=anonymous.object_id,
                name=u"forum",
                description=u"discussion forum threads")
            self.database.save(tag, commit=False)

        # associate the forum tag with the previously created notebook thread, and set that
        # association's value to forum_name
        self.database.execute(
            anonymous.sql_save_notebook_tag(notebook_id,
                                            tag.object_id,
                                            value=self.forum_name),
            commit=False,
        )

        # give the anonymous user access to the new notebook thread
        self.database.execute(
            anonymous.sql_save_notebook(notebook_id,
                                        read_write=True,
                                        owner=False,
                                        own_notes_only=True),
            commit=False,
        )
示例#5
0
    def setUp(self):
        Test_controller.setUp(self)

        self.notebook = Notebook.create(self.database.next_id(Notebook),
                                        u"my notebook",
                                        trash_id=u"foo")
        self.database.save(self.notebook)

        self.anon_notebook = Notebook.create(self.database.next_id(Notebook),
                                             u"Luminotes",
                                             trash_id=u"bar")
        self.database.save(self.anon_notebook)
        self.anon_note = Note.create(
            self.database.next_id(Note),
            u"<h3>my note</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.anon_note)

        self.login_note = Note.create(
            self.database.next_id(Note),
            u"<h3>login</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.login_note)

        self.username = u"mulder"
        self.password = u"trustno1"
        self.email_address = u"*****@*****.**"
        self.user = None
        self.session_id = None

        self.user = User.create(self.database.next_id(User), self.username,
                                self.password, self.email_address)
        self.database.save(self.user)
        self.database.execute(
            self.user.sql_save_notebook(self.notebook.object_id))

        self.anonymous = User.create(self.database.next_id(User), u"anonymous")
        self.database.save(self.anonymous)
        self.database.execute(
            self.anonymous.sql_save_notebook(self.anon_notebook.object_id))

        self.blog_user = User.create(self.database.next_id(User), u"witten",
                                     self.password, self.email_address)
        self.database.save(self.blog_user)

        tag_id = self.database.next_id(Tag)
        self.forum_tag = Tag.create(
            tag_id,
            notebook_id=
            None,  # this tag is not in the namespace of a single notebook
            user_id=self.anonymous.object_id,
            name=u"forum",
            description=u"a discussion forum")
        self.database.save(self.forum_tag)

        self.general_thread = Notebook.create(
            self.database.next_id(Notebook), u"Welcome to the general forum!")
        self.database.save(self.general_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.general_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.general_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"general"), )

        self.support_thread = Notebook.create(
            self.database.next_id(Notebook), u"Welcome to the support forum!")
        self.database.save(self.support_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.support_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.support_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"support"), )

        self.blog_thread = Notebook.create(self.database.next_id(Notebook),
                                           u"Welcome to the blog!")
        self.database.save(self.blog_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.blog_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.blog_user.sql_save_notebook(self.blog_thread.object_id,
                                             read_write=Notebook.READ_WRITE), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.blog_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"forum"), )
示例#6
0
  def setUp( self ):
    Test_controller.setUp( self )

    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" )
    self.database.save( self.notebook )

    self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes", trash_id = u"bar" )
    self.database.save( self.anon_notebook )
    self.anon_note = Note.create(
      self.database.next_id( Note ), u"<h3>my note</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.anon_note )

    self.login_note = Note.create(
      self.database.next_id( Note ), u"<h3>login</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.login_note )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"*****@*****.**"
    self.user = None
    self.session_id = None

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user )
    self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) )

    self.anonymous = User.create( self.database.next_id( User ), u"anonymous" )
    self.database.save( self.anonymous )
    self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id ) )

    self.blog_user = User.create( self.database.next_id( User ), u"witten", self.password, self.email_address )
    self.database.save( self.blog_user )

    tag_id = self.database.next_id( Tag )
    self.forum_tag = Tag.create(
      tag_id,
      notebook_id = None, # this tag is not in the namespace of a single notebook
      user_id = self.anonymous.object_id,
      name = u"forum",
      description = u"a discussion forum"
    )
    self.database.save( self.forum_tag )

    self.general_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the general forum!" )
    self.database.save( self.general_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.general_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.general_thread.object_id, self.forum_tag.object_id, value = u"general" ),
    )

    self.support_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the support forum!" )
    self.database.save( self.support_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.support_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.support_thread.object_id, self.forum_tag.object_id, value = u"support" ),
    )

    self.blog_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the blog!" )
    self.database.save( self.blog_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.blog_user.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.blog_thread.object_id, self.forum_tag.object_id, value = u"forum" ),
    )