Example #1
0
    def post( self ):

        # get the room name from form
        room_name = self.request.get( "room_name" ).strip()
        slug      = Room.convert_name_to_slug( room_name )
        error     = None

        # check that the name and slug are OK
        if not Room.is_name_valid( room_name ):
            error = 'Room name not valid: ' + Room.name_requirements()
        elif Room.is_slug_taken( slug ):
            error = 'Room name is already taken'

        # bail out if there was a problem
        if error:
            return self.display_form( error= error, room_name= room_name )

        # create the room
        room = Room( name=room_name, slug=slug )
        room.put()

        # link room to user
        membership = Membership( room=room, member=self.get_current_member() )
        membership.put()
        
        self.redirect( "/" + room.slug )
Example #2
0
    def get( self, slug ):
        
        room = Room.get_by_slug(slug);

        if not room:
            return self.error(404)

        path = "templates/room.html"

        template_values = {
            "room": room,
        }

        self.render_template(path, template_values)