Пример #1
0
def publishNewsLetter(request,entry_id=None):
    mlogger.debug("publish new newsletters")
    if request.method == "GET" :
        if entry_id is None :
               form = PublishForm(user=request.user)
        else :
               entry=Entry.objects.get(pk=entry_id)
               form = PublishForm(instance=entry,user=request.user)
        return render_to_response('publish/institute_create_new.html',{'form':form},RequestContext(request))
    elif request.method == "POST" :        
        form = PublishForm(request.POST,user=request.user)
        if form.is_valid() :
            entry = form.save(commit=False)
            entry.institute = request.institute
            entry.user = request.user
            entry.save()
            if request.POST['whichbutton'] == "save" :                
                create_message(request,"saved your news letter")           
                return HttpResponseRedirect(reverse('publishnewurl2',kwargs={'entry_id':entry.id})+"?backto=publishhome")
            else:
                if entry.sendemail is not None :                    
                    emaillist = entry.sendemail.getEmailList(request.institute)
                    fullurl = entry.getfullurl(request.institute)
                    deliverEmail('new_newsletter_subject.html','new_newsletter.html',{'institute':request.institute,'entry':entry,'fullurl':fullurl},emaillist)
                
                entry.tags = form.cleaned_data['tags']
                assignUserTagWeights(entry.tags,request.user,settings.CONTRIBUTION_WEIGHT)
                create_message(request,"Successfully created blog post")
                return HttpResponseRedirect(reverse('newsletterurl'))               
        else:
            return render_to_response('publish/institute_create_new.html',{'form':form},RequestContext(request))            
Пример #2
0
def editEntry(request,entry_id):
    mlogger.debug("editing an entry....................")    
    entry = Entry.objects.get(pk=int(entry_id))
    originaltags = entry.tags
    if request.method == "GET":
        form = PublishForm(instance=entry,initial={'tags':' '.join(entry.tags.values_list('name',flat=True))},user=request.user,editmode=entry.id)      
        backto =  request.GET['backto']        
        return render_to_response('publish/institute_create_new.html',{'form':form,'editmode':True,'backto':backto},RequestContext(request))
    elif request.method == "POST":
        form = PublishForm(request.POST, instance=entry,user=request.user)
        if form.is_valid() :
            newentry = form.save(commit=False)            
            newentry.save()
            removeUserTagWeights(originaltags,request.user,settings.CONTRIBUTION_WEIGHT)
            newentry.tags = form.cleaned_data['tags']
            assignUserTagWeights(newentry.tags,request.user,settings.CONTRIBUTION_WEIGHT)            
            if request.POST['whichbutton'] == "save":
                create_message(request,"saved your news letter")
                return HttpResponseRedirect(reverse('editentryurl',kwargs={'entry_id':entry.id})+"?backto="+request.POST['backto'])
            else :            
                if request.POST['backto'] == "publishhome" :
                    create_message(request,"Successfully created blog post")
                    return HttpResponseRedirect(reverse('newsletterurl'))                
                elif request.POST['backto'] == "archive":
                    create_message(request,"Successfully edited the blog post")
                    return HttpResponseRedirect(reverse('archiveurl'))
                else :
                    create_message(request,"Successfully edited the blog post")
                    return HttpResponseRedirect(reverse('mypostsurl'))
        else:
            return render_to_response('publish/institute_create_new.html',{'form':form,'editmode':True,'backto':request.POST['backto']},RequestContext(request))            
Пример #3
0
def postAJob(request):
    mlogger.debug("posting a job.......................")
    if request.method == "GET":
        form = JobForm(user=request.user)
        return render_to_response('jobs/postjob.html', {'form': form},
                                  RequestContext(request))
    elif request.method == "POST":
        form = JobForm(request.POST, user=request.user)
        if form.is_valid():
            j = form.save(commit=False)
            j.postedby = request.user
            j.institute = request.institute
            j.save()

            if j.sendemail is not None:
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html', 'new_job_message.html', {
                    'institute': request.institute,
                    'job': j,
                    'fullurl': fullurl
                }, emaillist)

            #Assign tags to jobs
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags, request.user,
                                 settings.CONTRIBUTION_WEIGHT)
            create_message(request, "Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))
        else:
            return render_to_response('jobs/postjob.html', {'form': form},
                                      RequestContext(request))
Пример #4
0
def postAJob(request):
    mlogger.debug("posting a job.......................")    
    if request.method == "GET":
        form  = JobForm(user=request.user)        
        return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
    elif request.method =="POST":
        form =  JobForm(request.POST,user=request.user)
        if form.is_valid() :
            j=form.save(commit=False)                        
            j.postedby = request.user
            j.institute = request.institute
            j.save()
            
            if j.sendemail is not None :
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html','new_job_message.html',{'institute':request.institute,'job':j,'fullurl':fullurl},emaillist)
                
            #Assign tags to jobs    
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags,request.user,settings.CONTRIBUTION_WEIGHT)          
            create_message(request,"Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))            
        else:
           return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
Пример #5
0
def editEvent(request,eventid):
    eventid = int(eventid)
    event = Event.objects.get(id=eventid)
    originaltags = event.tags
    if request.user.id == event.user.id :
        if request.method == "GET" :
            mlogger.debug("the person who posted the event is editing")
            form = EventForm(instance=event,initial={'tags':' '.join(event.tags.values_list('name',flat=True))},user=request.user)            
            return render_to_response('events/create_event.html',{'form':form,'editmode':True},RequestContext(request))
        elif request.method == "POST":            
            form = EventForm(request.POST,instance=event,user=request.user)
            if form.is_valid() :
                   newevent = form.save(commit=False)
                   newevent.save()                   
                   removeUserTagWeights(originaltags,request.user,settings.CONTRIBUTION_WEIGHT)
                   newevent.tags = form.cleaned_data['tags']
                   assignUserTagWeights(newevent.tags,request.user,settings.CONTRIBUTION_WEIGHT)               
                   if event.sendemail is not None :
                        emaillist = event.sendemail.getEmailList(request.institute)                          
                        deliverEmail('event_created_subject.html','event_created.html',{'institute':request.institute,'event':event,'edit':True,'site':settings.SITE_URL},emaillist)
                    
                   create_message(request,"Successfuly edited the event")
                   return HttpResponseRedirect(reverse('agendaviewurl')) 
            else:      
                   return render_to_response('events/create_event.html',{'form':form,'editmode':True},RequestContext(request))  
            
    else :
        create_message(request,"You are not authorized to edit this event")
        return HttpResponseRedirect(reverse('agendaviewurl'))
Пример #6
0
def editJob(request,jobid):
    jobid = int(jobid)
    job = Job.objects.get(pk=jobid)
    originaltags = job.tags
    if request.user.id == job.postedby.id :
        if request.method == "GET" :
            mlogger.debug("the person who posted the job is editing")
            form = JobForm(instance=job,initial={'tags':' '.join(job.tags.values_list('name',flat=True))},user=request.user)            
            return render_to_response('jobs/postjob.html',{'form':form,'editmode':True},RequestContext(request))
        elif request.method == "POST":            
            form = JobForm(request.POST, instance=job,user=request.user)
            if form.is_valid() :
                newjob = form.save(commit=False)
                newjob.save()
                removeUserTagWeights(originaltags,request.user,settings.CONTRIBUTION_WEIGHT)                
                newjob.tags = form.cleaned_data['tags']
                #what about tags brother                  
                assignUserTagWeights(newjob.tags,request.user,settings.CONTRIBUTION_WEIGHT)                            
                create_message(request,"Successfuly edited your job")
                return HttpResponseRedirect(reverse('displayjoburl'))
            else:
                return render_to_response('jobs/postjob.html',{'form':form,'editmode':True},RequestContext(request))
    else :
        create_message(request,"You are not authorized to edit this job")
        return HttpResponseRedirect(reverse('viewjoburl',kwargs={'jobid':job.id}))
Пример #7
0
def viewJob(request,jobid):
    ''' view the above jobid '''
    j = Job.objects.get(pk=int(jobid))
    if j.postedby is not None :
        if request.user.id != j.postedby.id  :
            assignUserTagWeights(j.tags,request.user,settings.VIEW_WEIGHT)                            
    return render_to_response('jobs/viewjob.html',{'job':j},RequestContext(request))
Пример #8
0
def viewJob(request, jobid):
    ''' view the above jobid '''
    j = Job.objects.get(pk=int(jobid))
    if j.postedby is not None:
        if request.user.id != j.postedby.id:
            assignUserTagWeights(j.tags, request.user, settings.VIEW_WEIGHT)
    return render_to_response('jobs/viewjob.html', {'job': j},
                              RequestContext(request))
Пример #9
0
def viewEvent(request,eventid):
    mlogger.debug("viewing the event %s "%(eventid,))
    eventid = int(eventid)
    event = Event.objects.get(pk=eventid)
    if request.user.id != event.user.id  :
        assignUserTagWeights(event.tags,request.user,settings.VIEW_WEIGHT)          
    if  list(EventAttendance.objects.filter(user__id=request.user.id,event__id=eventid,institute__id=request.institute.id)) :
        attending = True
    else :
        attending = False
    return render_to_response('events/viewevent.html',{'event':event,'attending':attending},RequestContext(request))    
Пример #10
0
def submitTags(request):
    mlogger.debug("Save the tags for this user")
    d = {}    
    tags = request.POST['tags'].strip()    
    #make sure that the tags are of valid string
    e = re.compile(r"[0-9A-Za-z-. ]+",re.IGNORECASE)
    result = e.match(tags)    
    if result is not None  and len(tags) == result.span()[1] :      
        profile = request.user.get_profile()
        removeUserTagWeights(profile.tags,request.user,settings.PROFILE_WEIGHT)
        profile.tags = tags
        assignUserTagWeights(profile.tags,request.user,settings.PROFILE_WEIGHT)
        #send response
    else:
        d['error'] = "Error:Tags should only contain alphanumeric characters, space,hypen('-'),dot('.'). Tags shoud be saperated by space"
             
    json = simplejson.dumps(d)
    return HttpResponse(json)
Пример #11
0
def submitTags(request):
    mlogger.debug("Save the tags for this user")
    d = {}
    tags = request.POST['tags'].strip()
    #make sure that the tags are of valid string
    e = re.compile(r"[0-9A-Za-z-. ]+", re.IGNORECASE)
    result = e.match(tags)
    if result is not None and len(tags) == result.span()[1]:
        profile = request.user.get_profile()
        removeUserTagWeights(profile.tags, request.user,
                             settings.PROFILE_WEIGHT)
        profile.tags = tags
        assignUserTagWeights(profile.tags, request.user,
                             settings.PROFILE_WEIGHT)
        #send response
    else:
        d['error'] = "Error:Tags should only contain alphanumeric characters, space,hypen('-'),dot('.'). Tags shoud be saperated by space"

    json = simplejson.dumps(d)
    return HttpResponse(json)
Пример #12
0
def editJob(request, jobid):
    jobid = int(jobid)
    job = Job.objects.get(pk=jobid)
    originaltags = job.tags
    if request.user.id == job.postedby.id:
        if request.method == "GET":
            mlogger.debug("the person who posted the job is editing")
            form = JobForm(instance=job,
                           initial={
                               'tags':
                               ' '.join(job.tags.values_list('name',
                                                             flat=True))
                           },
                           user=request.user)
            return render_to_response('jobs/postjob.html', {
                'form': form,
                'editmode': True
            }, RequestContext(request))
        elif request.method == "POST":
            form = JobForm(request.POST, instance=job, user=request.user)
            if form.is_valid():
                newjob = form.save(commit=False)
                newjob.save()
                removeUserTagWeights(originaltags, request.user,
                                     settings.CONTRIBUTION_WEIGHT)
                newjob.tags = form.cleaned_data['tags']
                #what about tags brother
                assignUserTagWeights(newjob.tags, request.user,
                                     settings.CONTRIBUTION_WEIGHT)
                create_message(request, "Successfuly edited your job")
                return HttpResponseRedirect(reverse('displayjoburl'))
            else:
                return render_to_response('jobs/postjob.html', {
                    'form': form,
                    'editmode': True
                }, RequestContext(request))
    else:
        create_message(request, "You are not authorized to edit this job")
        return HttpResponseRedirect(
            reverse('viewjoburl', kwargs={'jobid': job.id}))
Пример #13
0
def createEvent(request):
    mlogger.debug("Create new event ..........................")
    if request.method == "GET":
        form = EventForm(user=request.user)
        return render_to_response('events/create_event.html',{'form':form},RequestContext(request))        
    elif request.method == "POST" :
        form = EventForm(request.POST,user=request.user)        
        if form.is_valid() :
            event = form.save(commit=False)
            event.user = request.user
            event.institute = request.institute
            event.save()
            
            event.tags = form.cleaned_data['tags']
            assignUserTagWeights(event.tags,request.user,settings.CONTRIBUTION_WEIGHT)
            
            if event.sendemail is not None :
                emaillist = event.sendemail.getEmailList(request.institute)                
                deliverEmail('event_created_subject.html','event_created.html',{'institute':request.institute,'event':event,'edit':False,'site':settings.SITE_URL},emaillist)
                
            create_message(request,"Succesfully created the event ...............")
            return HttpResponseRedirect(reverse('agendaviewurl'))               
    return render_to_response('events/create_event.html',{'form':form},RequestContext(request))                
Пример #14
0
def displaySinglePaper(request,entry_id):
    mlogger.debug("display single post with comments")
    entry = Entry.objects.get(pk=entry_id)
    if request.user.is_authenticated() and entry.user.id != request.user.id :
        assignUserTagWeights(entry.tags,request.user,settings.VIEW_WEIGHT)
    return render_to_response('publish/faculty_single_post.html',{'entry':entry},RequestContext(request))