def link_theme_to_room(request):
	"""Link a theme to a room that is owned by the user. """
	retval = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
	
	if request.method == "POST":
		theme_id = request.POST.get('theme',None)
		room = request.POST.get('room',None)
		user = request.user.username

		#test if user is room owner
		try:
			password = request.session.get('user_password',None)
			username = request.user.username
			if not xmpp.check_room_owner(username=username,
						     password=password,
						     room=room):
			        #return error that user is not room owner
				retval += "<themelink msg='not room owner'>invalid</themelink>"
			else:
			        #copy theme content to room template

				users_theme = Theme.objects.get(id=int(theme_id),
								owner=request.user)
				file_content = users_theme.content
				
				f = open(settings.THEME_ROOT+"/"+room+"_client.html",'w')
				f.write(file_content)
				f.close()
				retval += "<themelink>success</themelink>"
		
		except Exception, ex:
			retval += "<themelink msg=\""+str(ex)+"\">invalid</themelink>"
Beispiel #2
0
def link_theme_to_room(request):
    """Link a theme to a room that is owned by the user. """
    retval = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"

    if request.method == "POST":
        theme_id = request.POST.get('theme', None)
        room = request.POST.get('room', None)
        user = request.user.username

        #test if user is room owner
        try:
            password = request.session.get('user_password', None)
            username = request.user.username
            if not xmpp.check_room_owner(
                    username=username, password=password, room=room):
                #return error that user is not room owner
                retval += "<themelink msg='not room owner'>invalid</themelink>"
            else:
                #copy theme content to room template

                users_theme = Theme.objects.get(id=int(theme_id),
                                                owner=request.user)
                file_content = users_theme.content

                f = open(settings.THEME_ROOT + "/" + room + "_client.html",
                         'w')
                f.write(file_content)
                f.close()
                retval += "<themelink>success</themelink>"

        except Exception, ex:
            retval += "<themelink msg=\"" + str(ex) + "\">invalid</themelink>"
Beispiel #3
0
    def testRoomConfig(self):
        """ This assumes that you have chat.dev.speeqe.com configured
        as your chat server and the [email protected] user is
        created."""
        retval = xmppy.check_room_owner(username="******",
                                        password="******",
                                        room="test")

        self.failUnless(retval == True)
Beispiel #4
0
    def testRoomConfig(self):
        """ This assumes that you have chat.dev.speeqe.com configured
        as your chat server and the [email protected] user is
        created."""
        retval = xmppy.check_room_owner(username="******",
                                        password="******",
                                        room="test")

        self.failUnless(retval==True)