Example #1
0
def complete(request,id):
    from django.core.mail import send_mail

    entry = Comment.objects.get(pk=id)
    
    if entry.isDeleted or entry.completed: # no double completes! nor completing deleted things.
        return HttpResponseRedirect(reverse('requests.views.completed',current_app='requests'))
    
    if request.method == 'POST':
        form = ModifyForm(request.POST)
        if form.is_valid():
            if len(form.cleaned_data['completingServer']) > 0:
                try:
                    
                    entry.completed = True
                    entry.completingName = form.cleaned_data['completingName']
                    if len(form.cleaned_data['completingServer']) > 1:
                        entry.completingServer = form.cleaned_data['completingServer'].upper().replace('\\','')
                    else:
                        entry.completingServer = request.META['HTTP_X_FORWARDED_FOR']
                    entry.completerComment = form.cleaned_data['completerComment']
                
                    entry.completedTime = datetime.now()
                    
                    entry.save()
                    recipients = ['*****@*****.**']
                    if entry.email:
                        recipients += [entry.email]
                    message = "From %(host)s:\n\n%(completercomment)s\n\nEnjoy!\n\n This is an automated message; please do not reply to this address" % {'host':entry.completingServer,'completercomment':entry.completerComment}
                    send_mail('Request Completed!',
                    message,
                    '*****@*****.**',
                    recipients,
                    )
                    test = 3
                    return HttpResponseRedirect(reverse('requests.views.completed',current_app='requests'))
                except Exception,e:
                    form.non_field_errors = e
                    test = 2
        else:
            test = 1
Example #2
0
def edit(request,id):
    
    entry = Comment.objects.get(pk=id)
    
    if entry.isDeleted or entry.completed: # no editing completed or deleted things!
        return HttpResponseRedirect(reverse('requests.views.open',args=(1,)))
    
    
    if request.method == "POST":
        form = ModifyForm(request.POST,{'completingServer':"",})
        form.completingServer = ""
        if form.is_valid():
            test = 0
            #from django.db import connection
    
            #cursor = connection.cursor()
            #cursor.execute('LOCK TABLES requests_comment WRITE')
            
            entry.request = form.cleaned_data['request']
            entry.name = form.cleaned_data['name']
            entry.server = form.cleaned_data['server'].upper()
            entry.email = form.cleaned_data['email']
            entry.requestTime=datetime.now()
            
            entry.save()
            #cursor.execute('UNLOCK TABLES')
            return HttpResponseRedirect(reverse('requests.views.open',args=(1,)))
        test = form.errors
    else:
        form = ModifyForm(instance=entry,initial={'completingServer':""})
        test = 1
    
    return render_to_response('requests/modify.html',
                              {
                                'title': 'M2M - Editing Request '+id,
                                'requests':'current',
                                'openReq':'current',
                                'entry':entry,
                                'edit':True,
                                'form':form,
                                'test':test,
                                },context_instance=RequestContext(request)
                              )
Example #3
0
                        recipients += [entry.email]
                    message = "From %(host)s:\n\n%(completercomment)s\n\nEnjoy!\n\n This is an automated message; please do not reply to this address" % {'host':entry.completingServer,'completercomment':entry.completerComment}
                    send_mail('Request Completed!',
                    message,
                    '*****@*****.**',
                    recipients,
                    )
                    test = 3
                    return HttpResponseRedirect(reverse('requests.views.completed',current_app='requests'))
                except Exception,e:
                    form.non_field_errors = e
                    test = 2
        else:
            test = 1
    else:
        form = ModifyForm(instance=entry)
        test = 0
        
    return render_to_response('requests/modify.html',
                              {'title':'M2M - Completing Request '+id,
                               'requests':'current',
                               'closedReq':'current',
                               'entry':entry,
                               'complete':True,
                               'test':test,
                               'form':form,
                               },context_instance=RequestContext(request)
                              )
    
def delete(request,id):
    try: