Пример #1
0
    def delete(self, request):
        """
        Deletes the Note in the model with the particular jid of the note passed in.  Only the jid matters;
        all other fields are ignored.

        If a note with such a JID does not exist, return 404.
        Called with HTTP DELETE
        """
        #ResourceForm = forms.form_for_model(Note, form=self.form_class)
        data = self.receiver.get_put_data(request)
        #form = ResourceForm(data)
        form = NoteForm(data)
        request_user = basicauth_get_user_by_emailaddr(request)
        if not request_user:
            logevent(request, 'Note.delete', 401,
                     jv3.utils.decode_emailaddr(request))
            return self.responder.error(
                request, 401,
                ErrorDict({"autherror":
                           "Incorrect user/password combination"}))

        matching_notes = Note.objects.filter(jid=form.data['jid'],
                                             owner=request_user)

        if len(matching_notes) == 0:
            return self.responder.error(
                request, 404,
                ErrorDict(
                    {"jid": "Note with jid %d not found" % form.data["jid"]}))

        for to_die in matching_notes:
            to_die.delete()

        return HttpResponse(_("Object successfully deleted."),
                            self.responder.mimetype)
Пример #2
0
    def delete(self, request):
        """
        Deletes the Note in the model with the particular jid of the note passed in.  Only the jid matters;
        all other fields are ignored.

        If a note with such a JID does not exist, return 404.
        Called with HTTP DELETE
        """
        #ResourceForm = forms.form_for_model(Note, form=self.form_class)
        data = self.receiver.get_put_data(request)
        #form = ResourceForm(data)
        form = NoteForm(data)
        request_user = basicauth_get_user_by_emailaddr(request);
        if not request_user:
            logevent(request,'Note.delete',401, jv3.utils.decode_emailaddr(request))
            return self.responder.error(request, 401, ErrorDict({"autherror":"Incorrect user/password combination"}))
        
        matching_notes = Note.objects.filter(jid=form.data['jid'],owner=request_user)
        
        if len(matching_notes) == 0:
            return self.responder.error(request, 404, ErrorDict({"jid":"Note with jid %d not found"  % form.data["jid"]}));

        for to_die in matching_notes:
            to_die.delete()

        return HttpResponse(_("Object successfully deleted."), self.responder.mimetype)
Пример #3
0
    def clean_file(self):
        def ffile_path(uploaded_file):
            '''  Converts InMemoryUploadedFile to on-disk file so it will have path. '''
            try:
                return uploaded_file.temporary_file_path()
            except AttributeError:
                fileno, path = tempfile.mkstemp()
                temp_file = os.fdopen(fileno, 'w+b')
                for chunk in uploaded_file.chunks():
                    temp_file.write(chunk)
                temp_file.close()
                return path

        path = ffile_path(self.cleaned_data['file'])
        print path
        print path
        if path == None:
            raise forms.ValidationError('No file selected.')

        try:  # Comprobacion de que el fichero no esta corrupto
            zf = ZipFile(path)
            bad_file = zf.testzip()
            if bad_file:
                raise forms.ValidationError(
                    _('El fichero "%s" del ZIP esta corrupto.') % bad_file)
            zf.close()
        except BadZipfile:
            raise forms.ValidationError('El fichero subido no es un ZIP.')

        return path
Пример #4
0
 def delete(self, request):
     """
     Deletes the model associated with the current entry.
     Usually called by a HTTP request to the entry URI
     with method DELETE.
     """
     self.model.delete()
     return HttpResponse(_("Object successfully deleted."), self.collection.responder.mimetype)
Пример #5
0
 def delete(self, request):
     """
     Deletes the model associated with the current entry.
     Usually called by a HTTP request to the entry URI
     with method DELETE.
     """
     self.model.delete()
     return HttpResponse(_("Object successfully deleted."), self.collection.responder.mimetype)
Пример #6
0
class ReporteAnualForm(FieldSetFormMixin):
    anio = forms.IntegerField(label=_(u'Año'))