Exemplo n.º 1
0
 def handle_message(self, event):
     try:
         userJid = UserJid.objects.get(jid=event['jid'])
     except UserJid.DoesNotExist:
         logging.info("Message from unrecognised jid %s/%s '%s'" % (event['jid'], event['resource'], event['message']))
         return
     logging.debug("Creating new task '%s' for user %s from jid %s/%s" %(event['message'], userJid.user.username, event['jid'], event['resource']))
     newTask = Task(name=event['message'], user=userJid.user)
     newTask.save()
Exemplo n.º 2
0
def generateTestData(request):
    """ Not really a view - generate test data for a system.
    """
    projects = {}
    for name in ("Psi", "GTD", "Housework", "Inventing"):
        project = Project(name=name, user=request.user)
        project.save()
        projects[name] = project
    contexts = {}
    for name in ("Home", "Work", "On the road", "Shopping"):
        context = Context(name=name, user=request.user)
        context.save()
        contexts[name] = context
    stuff = {'Do stuff':None, 'Do Psi stuff':projects['Psi'], 'Wash dishes':projects['Housework']}
    for name in stuff:
        task = Task(name=name, project=stuff[name], user=request.user)
        task.save()
    return HttpResponse("Done")
Exemplo n.º 3
0
def createTask(request):
    name = request.POST.get('name', None)
    projectId = request.POST.get('project', None)
    contextId = request.POST.get('context', None)
    if not user_request_okay(request.user, projectId=projectId, contextId=contextId):
        return render_to_response("%s/pagenotfound.html", mergeStandardDict(request, {}, ''))
    if projectId:
        taskProject = Project.objects.get(id=int(projectId))
    else:
        taskProject = None
    if contextId:
        taskContext = Context.objects.get(id=int(contextId))
    else:
        taskContext = None
    newTask = Task(name=name, project=taskProject, context=taskContext, user=request.user)
    newTask.save()
    redirectPath = "%s%d" % (request.POST.get('newtask_path', "/"), newTask.id)
    return HttpResponseRedirect(redirectPath)