Beispiel #1
0
def SendFeedback(request):
    user = request.user
    profile = user.get_profile()
    form = FeedbackForm()
    if ( request.method == 'POST'):
        form = FeedbackForm(request.POST)
        if ( form.is_valid() ):
            group = form.cleaned_data['to']
            if group is 'Project Reps':
                proj = form.cleaned_data['project']
                emails = []
                userproj = UserProject.objects.filter(project = proj, permissions__id = 1)
                for usr in userproj.user:
                    emails.append(usr.email)
                margs = {}
                margs['subject']  = '[NSS Feedback] ' + 'From: ' + user.username
                margs['message'] = '\n\n\nFeedback: \nProject: ' + proj + '\n\n' + form.cleaned_data['feedback']
                margs['mail_keys'] = emails
                margs['auto_generated'] = True
                nss_send_mail(**margs)
            else:
                margs = {}
                margs['subject']  = '[NSS Feedback] ' + 'From: ' + user.username
                margs['message'] = '\n\n\nFeedback: \n' + form.cleaned_data['feedback']
                margs['mail_keys'] = group
                margs['auto_generated'] = True
                margs['attachment'] = None
                nss_send_mail(**margs)
            return HttpResponseRedirect(reverse(
                'dashboard',
                kwargs = {
                    'user_id': request.user.id,
                },
            ))
    return render_to_response('users/feedback.html', locals(), context_instance = RequestContext(request))
Beispiel #2
0
def contacts(request):
    form = ContactsForm()
    if ( request.method == 'POST'):
        form = ContactsForm(request.POST)
        if ( form.is_valid() ):
            email = []
            email.append('*****@*****.**')
            margs = {}
            margs['subject']  = '[NSS Query from]' + form.cleaned_data['sender'] + '[Subject:]' + form.cleaned_data['subject']
            margs['message'] = '\n\n\Query: \n' + form.cleaned_data['query']
            margs['mail_keys'] = email
            margs['auto_generated'] = True
            nss_send_mail(**margs)
    project_list =  Project.objects.filter(status__text='ongoing')
    contact_list = []
    for i in project_list:
        contact_list.append( { 'project' : i , 'members' : [j.get_profile() for j in i.members.filter(is_active=True)] } )
    return render_to_response('home/Home/Contact.html', locals(), context_instance = RequestContext(request))
Beispiel #3
0
def compose(request):
    currUserProfile = request.user.get_profile()

    if (not currUserProfile.is_managerial()):
        return HttpResponseForbidden('It seems like you do not have the permissions to view this page.')
        
    form = MailerForm()
    mail =[]
    Err = ''
    users = UserProfile.objects.filter(user__is_active = True)
    if (request.method == 'POST'):
        form = MailerForm(request.POST, request.FILES)
        if (form.is_valid()):
            inputs = form.cleaned_data
            if inputs['sender'] == currUserProfile.user.email:
            	try:
                	otherEmails = inputs['others']
                except:
    	            otherEmails = []
    	            
    	       	mail += otherEmails.split(',')
			
    	        nss_send_mail(inputs['subject'], inputs['message'], to = mail,
    	                mail_vols = True if inputs['vols'] else False,
    	                mail_prs = True if inputs['project_reps'] else False,
    	                mail_managerial = True if inputs['managerial_team'] else False,
#    	                mail_superusers = True if inputs['super_users'] else False,
    	                send_individual_mails = True,
    	                sender_email = inputs['sender'], bcc_sender = True,
    	                attachment = inputs['attachment']
    	                )
    	        return HttpResponseRedirect(reverse('dashboard', kwargs = {'user_id': request.user.id,}))
    	    else:
	    		Err = 'Put your email id in sender'
						           
    return render_to_response('mailer/compose.html', locals(), context_instance = RequestContext(request))