Пример #1
0
def registry_insert(modeladmin, request, queryset):
    records_updated = 0
    for record in queryset:
        if record.status == 'Incomplete' or record.status == 'Error':
            create_new_csw.delay(record.id)
            records_updated += 1

    if records_updated > 0:
        messages.success(
            request,
            '{0} records submitted to Registry'.format(records_updated))
Пример #2
0
    def form_valid(self, form):
        context = self.get_context_data()
        cswrecordreference = context['cswrecordreference']
        with transaction.atomic():
            self.object = form.save()
            self.object.user = self.request.user
            self.object.save()

            if cswrecordreference.is_valid():
                cswrecordreference.instance = self.object
                cswrecordreference.save()

            create_new_csw.delay(self.object.id)
        return super(CSWRecordCreate, self).form_valid(form)
Пример #3
0
def insert_csw(request):
    if request.method == 'POST':
        form = CSWRecordForm(request.POST)
        if form.is_valid():
            new_record = form.save()
            new_record.user = request.user
            new_record.save()
            create_new_csw.delay(new_record.id)
            return HttpResponseRedirect(reverse('csw_status'))
    else:
        form = CSWRecordForm()

    return render_to_response("csw/new.html", {
        "form": form,
    },
                              context_instance=RequestContext(request))