Beispiel #1
0
def audio_add(request):
    """Add new Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - frontend/audio/audio_change.html

    **Logic Description**:

        * Add a new audio which will belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    form = DialerAudioFileForm()
    if request.method == 'POST':
        form = DialerAudioFileForm(request.POST, request.FILES)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            obj.save()
            request.session["msg"] = _('"%(name)s" added.') % \
                {'name': request.POST['name']}
            return HttpResponseRedirect(audio_redirect_url)

    template = 'frontend/audio/audio_change.html'
    data = {
        'form': form,
        'action': 'add',
        'AUDIO_DEBUG': settings.AUDIO_DEBUG,
    }
    return render_to_response(template, data,
                              context_instance=RequestContext(request))
Beispiel #2
0
def audio_change(request, object_id):
    """Update Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - dialer_audio/audio_change.html

    **Logic Description**:

        * Update audio which is belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    obj = get_object_or_404(AudioFile, pk=object_id, user=request.user)
    form = DialerAudioFileForm(request.POST or None, request.FILES or None, instance=obj)

    if form.is_valid():
        if request.POST.get('delete'):
            audio_change(request, object_id)
            return HttpResponseRedirect(audio_redirect_url)
        else:
            form.save()
            return HttpResponseRedirect(audio_redirect_url)
    data = {
        'form': form,
        'action': 'update',
    }
    return render_to_response('dialer_audio/audio_change.html', data, context_instance=RequestContext(request))
Beispiel #3
0
def audio_change(request, object_id):
    """Update Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - frontend/audio/audio_change.html

    **Logic Description**:

        * Update audio which is belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    obj = get_object_or_404(AudioFile, pk=object_id, user=request.user)
    form = DialerAudioFileForm(instance=obj)

    if request.method == 'POST':
        if request.POST.get('delete'):
            return HttpResponseRedirect('/audio/del/%s/' % object_id)

        form = DialerAudioFileForm(request.POST, request.FILES, instance=obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/audio/')

    template = 'frontend/audio/audio_change.html'
    data = {
        'form': form,
        'module': current_view(request),
        'action': 'update',
        'AUDIO_DEBUG': settings.AUDIO_DEBUG,
    }
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
Beispiel #4
0
def audio_add(request):
    """Add new Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - frontend/audio/audio_change.html

    **Logic Description**:

        * Add a new audio which will belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    form = DialerAudioFileForm()
    if request.method == 'POST':
        form = DialerAudioFileForm(request.POST, request.FILES)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            obj.save()
            request.session["msg"] = _('"%(name)s" added.') %\
                {'name': request.POST['name']}
            return HttpResponseRedirect('/audio/')

    template = 'frontend/audio/audio_change.html'
    data = {
        'module': current_view(request),
        'form': form,
        'action': 'add',
        'AUDIO_DEBUG': settings.AUDIO_DEBUG,
    }
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
Beispiel #5
0
def audio_change(request, object_id):
    """Update Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - dialer_audio/audio_change.html

    **Logic Description**:

        * Update audio which is belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    obj = get_object_or_404(AudioFile, pk=object_id, user=request.user)
    form = DialerAudioFileForm(request.POST or None, request.FILES or None, instance=obj)

    if form.is_valid():
        if request.POST.get('delete'):
            audio_change(request, object_id)
            return HttpResponseRedirect(audio_redirect_url)
        else:
            form.save()
            return HttpResponseRedirect(audio_redirect_url)
    data = {
        'form': form,
        'action': 'update',
    }
    return render_to_response('dialer_audio/audio_change.html', data, context_instance=RequestContext(request))
Beispiel #6
0
def audio_change(request, object_id):
    """Update Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - frontend/audio/audio_change.html

    **Logic Description**:

        * Update audio which is belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    obj = get_object_or_404(AudioFile, pk=object_id, user=request.user)
    form = DialerAudioFileForm(instance=obj)    

    if request.method == 'POST':
        if request.POST.get('delete'):        
            return HttpResponseRedirect('/audio/del/%s/' % object_id)
            
        form = DialerAudioFileForm(
            request.POST, request.FILES, instance=obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/audio/')

    template = 'frontend/audio/audio_change.html'
    data = {
        'form': form,
        'module': current_view(request),
        'action': 'update',
        'AUDIO_DEBUG': settings.AUDIO_DEBUG,
    }
    return render_to_response(template, data,
           context_instance=RequestContext(request))
Beispiel #7
0
def audio_add(request):
    """Add new Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - dialer_audio/audio_change.html

    **Logic Description**:

        * Add a new audio which will belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    form = DialerAudioFileForm(request.POST or None, request.FILES or None)
    if form.is_valid():
        form.save(user=request.user)
        request.session["msg"] = _('"%(name)s" added.') % {
            'name': request.POST['name']
        }
        return HttpResponseRedirect(audio_redirect_url)
    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('dialer_audio/audio_change.html',
                              data,
                              context_instance=RequestContext(request))
    def create(self, request):
        """Customize create"""
        queryset = AudioFile.objects.all()
        request.DATA['convert_type'] = settings.CONVERT_TYPE_VALUE
        request.DATA['channel_type'] = settings.CHANNEL_TYPE_VALUE
        request.DATA['freq_type'] = settings.FREQ_TYPE_VALUE
        form = DialerAudioFileForm(request.DATA, request.FILES)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            obj.save()
            queryset = AudioFile.objects.filter(pk=obj.id)

        serializer = AudioFileSerializer(queryset, many=True)
        return Response(serializer.data)
    def create(self, request):
        """Customize create"""
        queryset = AudioFile.objects.all()
        request.DATA['convert_type'] = settings.CONVERT_TYPE_VALUE
        request.DATA['channel_type'] = settings.CHANNEL_TYPE_VALUE
        request.DATA['freq_type'] = settings.FREQ_TYPE_VALUE
        form = DialerAudioFileForm(request.DATA, request.FILES)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            obj.save()
            queryset = AudioFile.objects.filter(pk=obj.id)

        serializer = AudioFileSerializer(queryset, many=True)
        return Response(serializer.data)
    def update(self, request, *args, **kwargs):
        """Customize update"""
        pk = kwargs['pk']
        queryset = AudioFile.objects.filter(id=pk)
        obj = get_object_or_404(AudioFile, id=pk, user=request.user)

        request.DATA['convert_type'] = settings.CONVERT_TYPE_VALUE
        request.DATA['channel_type'] = settings.CHANNEL_TYPE_VALUE
        request.DATA['freq_type'] = settings.FREQ_TYPE_VALUE
        form = DialerAudioFileForm(request.DATA, request.FILES, instance=obj)
        if form.is_valid():
            form.save()
            queryset = AudioFile.objects.filter(id=pk)

        serializer = AudioFileSerializer(queryset, many=True)
        return Response(serializer.data)
    def update(self, request, *args, **kwargs):
        """Customize update"""
        pk = kwargs['pk']
        queryset = AudioFile.objects.filter(id=pk)
        obj = get_object_or_404(AudioFile, id=pk, user=request.user)

        request.DATA['convert_type'] = settings.CONVERT_TYPE_VALUE
        request.DATA['channel_type'] = settings.CHANNEL_TYPE_VALUE
        request.DATA['freq_type'] = settings.FREQ_TYPE_VALUE
        form = DialerAudioFileForm(request.DATA, request.FILES, instance=obj)
        if form.is_valid():
            form.save()
            queryset = AudioFile.objects.filter(id=pk)

        serializer = AudioFileSerializer(queryset, many=True)
        return Response(serializer.data)
Beispiel #12
0
def audio_add(request):
    """Add new Audio for the logged in user

    **Attributes**:

        * ``form`` - SurveyCustomerAudioFileForm
        * ``template`` - dialer_audio/audio_change.html

    **Logic Description**:

        * Add a new audio which will belong to the logged in user
          via the CustomerAudioFileForm & get redirected to the audio list
    """
    form = DialerAudioFileForm(request.POST or None, request.FILES or None)
    if form.is_valid():
        form.save(user=request.user)
        request.session["msg"] = _('"%(name)s" added.') % {'name': request.POST['name']}
        return HttpResponseRedirect(audio_redirect_url)
    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('dialer_audio/audio_change.html', data, context_instance=RequestContext(request))