예제 #1
0
파일: views.py 프로젝트: avkameth/bots.v321
def outgoing(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->outgoing
            form = forms.SelectOutgoing()
            return django.shortcuts.render(request, form.template, {'form': form})
        else:                                  #from menu:run->outgoing
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False,'lastrun':bool(viewlib.save_int(request.GET.get('lastrun',0)))} #go to default outgoing-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:        #from SelectOutgoing form
            formin = forms.SelectOutgoing(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            #go to default outgoing-query using parameters from select screen
        elif '2incoming' in request.POST:        #from ViewOutgoing form, using button 'incoming (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='out2in')
            return incoming(request)
        elif '2process' in request.POST:         #from ViewOutgoing form, using button 'process errors (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='2process')
            return process(request)
        elif '2confirm' in request.POST:        #from ViewOutgoing form, using button 'confirm (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='out2confirm')
            return confirm(request)
        else:                                   #from ViewOutgoing form, check this form first
            formin = forms.ViewOutgoing(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            elif '2select' in request.POST:     #from ViewOutgoing form using button change selection
                form = forms.SelectOutgoing(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form': form})
            elif 'retransmit' in request.POST:  #from ViewOutgoing form using star resend
                ta_object = models.ta.objects.get(idta=viewlib.save_int(request.POST[u'retransmit']))
                if ta_object.statust != RESEND:     #can only resend last file
                    ta_object.retransmit = not ta_object.retransmit
                    ta_object.save()
            elif 'resendall' in request.POST:        #from ViewOutgoing form using button 'resend all'
                #select all objects with parameters and set retransmit
                query = models.ta.objects.filter(status=EXTERNOUT)
                outgoingfiles = viewlib.filterquery(query,formin.cleaned_data,paginate=False)
                for outgoingfile in outgoingfiles:       #can only resend last file
                    if outgoingfile.statust != RESEND:
                        outgoingfile.retransmit = not outgoingfile.retransmit
                        outgoingfile.save()
            elif 'noautomaticretry' in request.POST:        #from ViewOutgoing form using star 'no automaticretry'
                ta_object = models.ta.objects.get(idta=viewlib.save_int(request.POST[u'noautomaticretry']))
                if ta_object.statust == ERROR:
                    ta_object.statust = NO_RETRY
                    ta_object.save()
            else:                                    #from ViewIncoming, next page etc 
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal outgoing-query with parameters
    query = models.ta.objects.filter(status=EXTERNOUT)
    pquery = viewlib.filterquery(query,cleaned_data)
    form = forms.ViewOutgoing(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form': form,'queryset':pquery})
예제 #2
0
def document(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->document
            form = forms.SelectDocument()
            return django.shortcuts.render(request, form.template,
                                           {'form': form})
        else:  #from menu:run->document
            cleaned_data = {'page': 1, 'sortedby': 'idta', 'sortedasc': False}
            cleaned_data['lastrun'] = bool(
                viewlib.save_int(request.GET.get('lastrun', 0)))
            cleaned_data['status'] = viewlib.save_int(
                request.GET.get('status', 0))
            #go to default document-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectDocument form
            formin = forms.SelectDocument(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            #go to default document-query using parameters from select screen
        else:
            formin = forms.ViewDocument(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #coming from ViewDocument, change the selection criteria, go to select form
                form = forms.SelectDocument(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            elif 'retransmit' in request.POST:  #coming from ViewDocument, no reportidta
                idta = request.POST[u'retransmit']
                filereport = models.filereport.objects.get(
                    idta=viewlib.save_int(idta))
                filereport.retransmit = not filereport.retransmit
                filereport.save()
            else:  #coming from ViewDocument, next page etc
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal document-query with parameters
    query = models.ta.objects.filter(
        django.db.models.Q(status=SPLITUP)
        | django.db.models.Q(status=TRANSLATED))
    pquery = viewlib.filterquery(query, cleaned_data)
    viewlib.trace_document(pquery)
    form = forms.ViewDocument(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #3
0
파일: views.py 프로젝트: avkameth/bots.v321
def reports(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->reports
            form = forms.SelectReports()     
            return django.shortcuts.render(request, form.template, {'form': form})    #go to the SelectReports form
        else:                                   #from menu:run->report
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False}   #go to default report-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:        #from SelectReports form
            formin = forms.SelectReports(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            #go to default report-query using parameters from select screen
        elif 'report2incoming' in request.POST:       #from ViewReports form using star view incoming
            request.POST = viewlib.preparereport2view(request.POST,viewlib.save_int(request.POST['report2incoming']))
            return incoming(request)
        elif 'report2outgoing' in request.POST:       #from ViewReports form using star view outgoing
            request.POST = viewlib.preparereport2view(request.POST,viewlib.save_int(request.POST['report2outgoing']))
            return outgoing(request)
        elif 'report2process' in request.POST:       #from ViewReports form using star view process errors
            request.POST = viewlib.preparereport2view(request.POST,viewlib.save_int(request.POST['report2process']))
            return process(request)
        elif 'report2errors' in request.POST:       #from ViewReports form using star file errors
            newpost = viewlib.preparereport2view(request.POST,viewlib.save_int(request.POST['report2errors']))
            newpost['statust'] = ERROR
            request.POST = newpost
            return incoming(request)
        elif 'report2commerrors' in request.POST:       #from ViewReports form using star communcation errors
            newpost = viewlib.preparereport2view(request.POST,viewlib.save_int(request.POST['report2commerrors']))
            newpost['statust'] = ERROR
            request.POST = newpost
            return outgoing(request)
        else:                                   #from ViewReports form
            formin = forms.ViewReports(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            elif '2select' in request.POST:               #from ViewReports form using button change selection
                form = forms.SelectReports(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form': form})
            else:                                       #from ViewReports, next page etc 
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal report-query with parameters
    query = models.report.objects.all()
    pquery = viewlib.filterquery(query,cleaned_data)
    form = forms.ViewReports(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form': form,'queryset':pquery})
예제 #4
0
파일: views.py 프로젝트: avkameth/bots.v321
def detail(request,*kw,**kwargs):
    ''' in: the idta, either as parameter in or out.
        in: is idta of incoming file.
        out: idta of outgoing file, need to trace back for incoming file.
        return list of ta's for display in detail template.
        This list is formatted and ordered for display.
        first, get a tree (trace) starting with the incoming ta ;
        than make up the details for the trace
    '''
    if request.method == 'GET':
        if 'inidta' in request.GET: #from incoming screen
            rootta = models.ta.objects.get(idta=viewlib.save_int(request.GET['inidta']))
        else:                       #from outgoing screen: trace back to EXTERNIN first
            rootta = viewlib.django_trace_origin(viewlib.save_int(request.GET['outidta']),{'status':EXTERNIN})[0]
        viewlib.gettrace(rootta)
        detaillist = viewlib.trace2detail(rootta)
        return django.shortcuts.render(request,'bots/detail.html',{'detaillist':detaillist,'rootta':rootta})
예제 #5
0
def detail(request, *kw, **kwargs):
    ''' in: the idta, either as parameter in or out.
        in: is idta of incoming file.
        out: idta of outgoing file, need to trace back for incoming file.
        return list of ta's for display in detail template.
        This list is formatted and ordered for display.
        first, get a tree (trace) starting with the incoming ta ;
        than make up the details for the trace
    '''
    if request.method == 'GET':
        if 'inidta' in request.GET:  #from incoming screen
            rootta = models.ta.objects.get(
                idta=viewlib.save_int(request.GET['inidta']))
        else:  #from outgoing screen: trace back to EXTERNIN first
            rootta = viewlib.django_trace_origin(
                viewlib.save_int(request.GET['outidta']),
                {'status': EXTERNIN})[0]
        viewlib.gettrace(rootta)
        detaillist = viewlib.trace2detail(rootta)
        return django.shortcuts.render(request, 'bots/detail.html', {
            'detaillist': detaillist,
            'rootta': rootta
        })
예제 #6
0
파일: views.py 프로젝트: avkameth/bots.v321
def document(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->document
            form = forms.SelectDocument()
            return django.shortcuts.render(request, form.template, {'form': form})
        else:                                   #from menu:run->document
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False}
            cleaned_data['lastrun'] = bool(viewlib.save_int(request.GET.get('lastrun',0)))
            cleaned_data['status'] = viewlib.save_int(request.GET.get('status',0))
             #go to default document-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:         #from SelectDocument form
            formin = forms.SelectDocument(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            #go to default document-query using parameters from select screen
        else:
            formin = forms.ViewDocument(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            elif '2select' in request.POST:         #coming from ViewDocument, change the selection criteria, go to select form
                form = forms.SelectDocument(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form': form})
            elif 'retransmit' in request.POST:        #coming from ViewDocument, no reportidta
                idta = request.POST[u'retransmit']
                filereport = models.filereport.objects.get(idta=viewlib.save_int(idta))
                filereport.retransmit = not filereport.retransmit
                filereport.save()
            else:                                    #coming from ViewDocument, next page etc
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal document-query with parameters
    query = models.ta.objects.filter(django.db.models.Q(status=SPLITUP)|django.db.models.Q(status=TRANSLATED))
    pquery = viewlib.filterquery(query,cleaned_data)
    viewlib.trace_document(pquery)
    form = forms.ViewDocument(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form': form,'queryset':pquery})
예제 #7
0
def process(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->process
            form = forms.SelectProcess()
            return django.shortcuts.render(request, form.template,
                                           {'form': form})
        else:  #from menu:run->process
            cleaned_data = {
                'page': 1,
                'sortedby': 'idta',
                'sortedasc': False,
                'lastrun': bool(viewlib.save_int(request.GET.get('lastrun',
                                                                 0)))
            }
            #go to default process-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectProcess form
            formin = forms.SelectProcess(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
        elif '2incoming' in request.POST:  #coming from ViewProcess, go to incoming form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='fromprocess')
            return incoming(request)
        elif '2outgoing' in request.POST:  #coming from ViewProcess, go to outgoing form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='fromprocess')
            return outgoing(request)
        else:
            formin = forms.ViewProcess(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #coming from ViewProcess, change the selection criteria, go to select form
                form = forms.SelectProcess(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            else:  #coming from ViewProcess
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal process-query with parameters
    query = models.ta.objects.filter(status=PROCESS, statust=ERROR)
    pquery = viewlib.filterquery(query, cleaned_data)
    form = forms.ViewProcess(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #8
0
파일: views.py 프로젝트: avkameth/bots.v321
def confirm(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->confirm
            form = forms.SelectConfirm()
            return django.shortcuts.render(request, form.template, {'form': form})
        else:                                  #from menu:run->confirm
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False}
             #go to default confirm-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:         #from SelectConfirm form
            formin = forms.SelectConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
        elif '2incoming' in request.POST:        #coming from ViewConfirm, go to incoming form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,soort='confirm2in')
            return incoming(request)
        elif '2outgoing' in request.POST:        #coming from ViewConfirm, go to outgoing form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,soort='confirm2out')
            return outgoing(request)
        elif 'confirm' in request.POST:        #coming ViewConfirm, using star 'Manual confirm'
            ta_object = models.ta.objects.get(idta=viewlib.save_int(request.POST[u'confirm']))
            if ta_object.confirmed == False and ta_object.confirmtype.startswith('ask'):
                ta_object.confirmed = True
                ta_object.confirmidta = '-1'   # to indicate a manual confirmation
                ta_object.save()
                messages.add_message(request, messages.INFO, _(u'Manual confirmed.'))
            else:
                messages.add_message(request, messages.INFO, _(u'Manual confirm not possible.'))
            # then just refresh the current view
            formin = forms.ViewConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
        else:
            formin = forms.ViewConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form':formin})
            elif '2select' in request.POST:         #coming from ViewConfirm, change the selection criteria, go to select form
                form = forms.SelectConfirm(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form':form})
            else:                                    #coming from ViewConfirm, next page etc
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal confirm-query with parameters
    query = models.ta.objects.filter(confirmasked=True)
    pquery = viewlib.filterquery(query,cleaned_data)
    form = forms.ViewConfirm(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form':form, 'queryset':pquery})
예제 #9
0
def reports(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->reports
            form = forms.SelectReports()
            return django.shortcuts.render(
                request, form.template,
                {'form': form})  #go to the SelectReports form
        else:  #from menu:run->report
            cleaned_data = {
                'page': 1,
                'sortedby': 'idta',
                'sortedasc': False
            }  #go to default report-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectReports form
            formin = forms.SelectReports(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            #go to default report-query using parameters from select screen
        elif 'report2incoming' in request.POST:  #from ViewReports form using star view incoming
            request.POST = viewlib.preparereport2view(
                request.POST,
                viewlib.save_int(request.POST['report2incoming']))
            return incoming(request)
        elif 'report2outgoing' in request.POST:  #from ViewReports form using star view outgoing
            request.POST = viewlib.preparereport2view(
                request.POST,
                viewlib.save_int(request.POST['report2outgoing']))
            return outgoing(request)
        elif 'report2process' in request.POST:  #from ViewReports form using star view process errors
            request.POST = viewlib.preparereport2view(
                request.POST, viewlib.save_int(request.POST['report2process']))
            return process(request)
        elif 'report2errors' in request.POST:  #from ViewReports form using star file errors
            newpost = viewlib.preparereport2view(
                request.POST, viewlib.save_int(request.POST['report2errors']))
            newpost['statust'] = ERROR
            request.POST = newpost
            return incoming(request)
        elif 'report2commerrors' in request.POST:  #from ViewReports form using star communcation errors
            newpost = viewlib.preparereport2view(
                request.POST,
                viewlib.save_int(request.POST['report2commerrors']))
            newpost['statust'] = ERROR
            request.POST = newpost
            return outgoing(request)
        else:  #from ViewReports form
            formin = forms.ViewReports(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #from ViewReports form using button change selection
                form = forms.SelectReports(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            else:  #from ViewReports, next page etc
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal report-query with parameters
    query = models.report.objects.all()
    pquery = viewlib.filterquery(query, cleaned_data)
    form = forms.ViewReports(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #10
0
def confirm(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->confirm
            form = forms.SelectConfirm()
            return django.shortcuts.render(request, form.template,
                                           {'form': form})
        else:  #from menu:run->confirm
            cleaned_data = {'page': 1, 'sortedby': 'idta', 'sortedasc': False}
            #go to default confirm-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectConfirm form
            formin = forms.SelectConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
        elif '2incoming' in request.POST:  #coming from ViewConfirm, go to incoming form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='confirm2in')
            return incoming(request)
        elif '2outgoing' in request.POST:  #coming from ViewConfirm, go to outgoing form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='confirm2out')
            return outgoing(request)
        elif 'confirm' in request.POST:  #coming ViewConfirm, using star 'Manual confirm'
            ta_object = models.ta.objects.get(
                idta=viewlib.save_int(request.POST[u'confirm']))
            if ta_object.confirmed == False and ta_object.confirmtype.startswith(
                    'ask'):
                ta_object.confirmed = True
                ta_object.confirmidta = '-1'  # to indicate a manual confirmation
                ta_object.save()
                messages.add_message(request, messages.INFO,
                                     _(u'Manual confirmed.'))
            else:
                messages.add_message(request, messages.INFO,
                                     _(u'Manual confirm not possible.'))
            # then just refresh the current view
            formin = forms.ViewConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
        else:
            formin = forms.ViewConfirm(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #coming from ViewConfirm, change the selection criteria, go to select form
                form = forms.SelectConfirm(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            else:  #coming from ViewConfirm, next page etc
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal confirm-query with parameters
    query = models.ta.objects.filter(confirmasked=True)
    pquery = viewlib.filterquery(query, cleaned_data)
    form = forms.ViewConfirm(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #11
0
def outgoing(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->outgoing
            form = forms.SelectOutgoing()
            return django.shortcuts.render(request, form.template,
                                           {'form': form})
        else:  #from menu:run->outgoing
            cleaned_data = {
                'page': 1,
                'sortedby': 'idta',
                'sortedasc': False,
                'lastrun': bool(viewlib.save_int(request.GET.get('lastrun',
                                                                 0)))
            }  #go to default outgoing-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectOutgoing form
            formin = forms.SelectOutgoing(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            #go to default outgoing-query using parameters from select screen
        elif '2incoming' in request.POST:  #from ViewOutgoing form, using button 'incoming (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='out2in')
            return incoming(request)
        elif '2process' in request.POST:  #from ViewOutgoing form, using button 'process errors (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='2process')
            return process(request)
        elif '2confirm' in request.POST:  #from ViewOutgoing form, using button 'confirm (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='out2confirm')
            return confirm(request)
        else:  #from ViewOutgoing form, check this form first
            formin = forms.ViewOutgoing(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #from ViewOutgoing form using button change selection
                form = forms.SelectOutgoing(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            elif 'retransmit' in request.POST:  #from ViewOutgoing form using star resend
                ta_object = models.ta.objects.get(
                    idta=viewlib.save_int(request.POST[u'retransmit']))
                if ta_object.statust != RESEND:  #can only resend last file
                    ta_object.retransmit = not ta_object.retransmit
                    ta_object.save()
            elif 'resendall' in request.POST:  #from ViewOutgoing form using button 'resend all'
                #select all objects with parameters and set retransmit
                query = models.ta.objects.filter(status=EXTERNOUT)
                outgoingfiles = viewlib.filterquery(query,
                                                    formin.cleaned_data,
                                                    paginate=False)
                for outgoingfile in outgoingfiles:  #can only resend last file
                    if outgoingfile.statust != RESEND:
                        outgoingfile.retransmit = not outgoingfile.retransmit
                        outgoingfile.save()
            elif 'noautomaticretry' in request.POST:  #from ViewOutgoing form using star 'no automaticretry'
                ta_object = models.ta.objects.get(
                    idta=viewlib.save_int(request.POST[u'noautomaticretry']))
                if ta_object.statust == ERROR:
                    ta_object.statust = NO_RETRY
                    ta_object.save()
            else:  #from ViewIncoming, next page etc
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal outgoing-query with parameters
    query = models.ta.objects.filter(status=EXTERNOUT)
    pquery = viewlib.filterquery(query, cleaned_data)
    form = forms.ViewOutgoing(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #12
0
def incoming(request, *kw, **kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:  #from menu:select->incoming
            form = forms.SelectIncoming()
            return django.shortcuts.render(
                request, form.template,
                {'form': form})  #go to the SelectIncoming form
        else:  #from menu:run->incoming
            cleaned_data = {
                'page': 1,
                'sortedby': 'idta',
                'sortedasc': False,
                'lastrun': bool(viewlib.save_int(request.GET.get('lastrun',
                                                                 0)))
            }  #go to default incoming-query using these default parameters
    else:  #request.method == 'POST'
        if 'fromselect' in request.POST:  #from SelectIncoming form
            formin = forms.SelectIncoming(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            #go to default report-query using parameters from select screen
        elif '2outgoing' in request.POST:  #from ViewIncoming form, using button 'outgoing (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='in2out')
            return outgoing(request)
        elif '2process' in request.POST:  #from ViewIncoming form, using button 'process errors (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='2process')
            return process(request)
        elif '2confirm' in request.POST:  #from ViewIncoming form, using button 'confirm (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,
                                                        soort='in2confirm')
            return confirm(request)
        else:  #from ViewIncoming form, check this form first
            formin = forms.ViewIncoming(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template,
                                               {'form': formin})
            elif '2select' in request.POST:  #from ViewIncoming form using button change selection
                form = forms.SelectIncoming(formin.cleaned_data)
                return django.shortcuts.render(request, form.template,
                                               {'form': form})
            elif 'delete' in request.POST:  #from ViewIncoming form using star delete
                if request.user.is_staff or request.user.is_superuser:
                    idta = viewlib.save_int(request.POST[u'delete'])
                    #delete from filereport
                    models.filereport.objects.filter(idta=idta).delete()
                    #get ta_object
                    ta_object = models.ta.objects.get(idta=idta)
                    #delete as much as possible in ta table
                    viewlib.delete_from_ta(ta_object)
                else:
                    notification = _(u'No rights for this operation.')
                    botsglobal.logger.info(notification)
                    messages.add_message(request, messages.INFO, notification)
            elif 'retransmit' in request.POST:  #from ViewIncoming form using star rereceive
                idta = request.POST[u'retransmit']
                filereport = models.filereport.objects.get(
                    idta=viewlib.save_int(idta))
                if filereport.fromchannel:  #for resend files fromchannel has no value. (do not rereceive resend items)
                    filereport.retransmit = not filereport.retransmit
                    filereport.save()
            elif 'rereceiveall' in request.POST:  #from ViewIncoming form using button 'rereceive all'
                #select all objects with parameters and set retransmit
                query = models.filereport.objects.all()
                incomingfiles = viewlib.filterquery(query,
                                                    formin.cleaned_data,
                                                    paginate=False)
                for incomingfile in incomingfiles:  #for resend files fromchannel has no value. (do not rereceive resend items)
                    if incomingfile.fromchannel:
                        incomingfile.retransmit = not incomingfile.retransmit
                        incomingfile.save()
            else:  #from ViewIncoming, next page etc
                viewlib.handlepagination(request.POST, formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal incoming-query with parameters
    query = models.filereport.objects.all()
    pquery = viewlib.filterquery(query, cleaned_data, incoming=True)
    form = forms.ViewIncoming(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {
        'form': form,
        'queryset': pquery
    })
예제 #13
0
파일: views.py 프로젝트: avkameth/bots.v321
def incoming(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->incoming
            form = forms.SelectIncoming()
            return django.shortcuts.render(request, form.template, {'form': form})    #go to the SelectIncoming form
        else:                                  #from menu:run->incoming
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False,'lastrun':bool(viewlib.save_int(request.GET.get('lastrun',0)))} #go to default incoming-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:        #from SelectIncoming form
            formin = forms.SelectIncoming(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            #go to default report-query using parameters from select screen
        elif '2outgoing' in request.POST:        #from ViewIncoming form, using button 'outgoing (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='in2out')
            return outgoing(request)
        elif '2process' in request.POST:        #from ViewIncoming form, using button 'process errors (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='2process')
            return process(request)
        elif '2confirm' in request.POST:        #from ViewIncoming form, using button 'confirm (same selection)'
            request.POST = viewlib.changepostparameters(request.POST,soort='in2confirm')
            return confirm(request)
        else:                                   #from ViewIncoming form, check this form first
            formin = forms.ViewIncoming(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            elif '2select' in request.POST:     #from ViewIncoming form using button change selection
                form = forms.SelectIncoming(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form': form})
            elif 'delete' in request.POST:        #from ViewIncoming form using star delete
                if request.user.is_staff or request.user.is_superuser:
                    idta = viewlib.save_int(request.POST[u'delete'])
                    #delete from filereport
                    models.filereport.objects.filter(idta=idta).delete()
                    #get ta_object
                    ta_object = models.ta.objects.get(idta=idta)
                    #delete as much as possible in ta table
                    viewlib.delete_from_ta(ta_object)
                else:
                    notification = _(u'No rights for this operation.')
                    botsglobal.logger.info(notification)
                    messages.add_message(request, messages.INFO, notification)
            elif 'retransmit' in request.POST:        #from ViewIncoming form using star rereceive
                idta = request.POST[u'retransmit']
                filereport = models.filereport.objects.get(idta=viewlib.save_int(idta))
                if filereport.fromchannel:   #for resend files fromchannel has no value. (do not rereceive resend items)
                    filereport.retransmit = not filereport.retransmit
                    filereport.save()
            elif 'rereceiveall' in request.POST:        #from ViewIncoming form using button 'rereceive all'
                #select all objects with parameters and set retransmit
                query = models.filereport.objects.all()
                incomingfiles = viewlib.filterquery(query,formin.cleaned_data,paginate=False)
                for incomingfile in incomingfiles:   #for resend files fromchannel has no value. (do not rereceive resend items)
                    if incomingfile.fromchannel:
                        incomingfile.retransmit = not incomingfile.retransmit
                        incomingfile.save()
            else:                                    #from ViewIncoming, next page etc 
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal incoming-query with parameters
    query = models.filereport.objects.all()
    pquery = viewlib.filterquery(query,cleaned_data,incoming=True)
    form = forms.ViewIncoming(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form': form,'queryset':pquery})
예제 #14
0
파일: views.py 프로젝트: avkameth/bots.v321
def process(request,*kw,**kwargs):
    if request.method == 'GET':
        if 'select' in request.GET:             #from menu:select->process
            form = forms.SelectProcess()
            return django.shortcuts.render(request, form.template, {'form': form})
        else:                                   #from menu:run->process
            cleaned_data = {'page':1,'sortedby':'idta','sortedasc':False,'lastrun':bool(viewlib.save_int(request.GET.get('lastrun',0)))}
             #go to default process-query using these default parameters
    else: #request.method == 'POST'
        if 'fromselect' in request.POST:         #from SelectProcess form
            formin = forms.SelectProcess(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
        elif '2incoming' in request.POST:        #coming from ViewProcess, go to incoming form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,soort='fromprocess')
            return incoming(request)
        elif '2outgoing' in request.POST:        #coming from ViewProcess, go to outgoing form using same criteria
            request.POST = viewlib.changepostparameters(request.POST,soort='fromprocess')
            return outgoing(request)
        else:
            formin = forms.ViewProcess(request.POST)
            if not formin.is_valid():
                return django.shortcuts.render(request, formin.template, {'form': formin})
            elif '2select' in request.POST:         #coming from ViewProcess, change the selection criteria, go to select form
                form = forms.SelectProcess(formin.cleaned_data)
                return django.shortcuts.render(request, form.template, {'form': form})
            else:                                    #coming from ViewProcess
                viewlib.handlepagination(request.POST,formin.cleaned_data)
        cleaned_data = formin.cleaned_data
    #normal process-query with parameters
    query = models.ta.objects.filter(status=PROCESS,statust=ERROR)
    pquery = viewlib.filterquery(query,cleaned_data)
    form = forms.ViewProcess(initial=cleaned_data)
    return django.shortcuts.render(request, form.template, {'form': form,'queryset':pquery})