admin.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:oim-cms 作者: parksandwildlife 项目源码 文件源码
def itsystem_dependency_report_all(self, request):
        """Returns a CSV containing all recorded dependencies.
        """
        fields = [
            'IT System', 'System status', 'Dependency', 'Dependency status',
            'Criticality', 'Description']
        # Write data for ITSystemHardware objects to the CSV.
        stream = StringIO()
        wr = unicodecsv.writer(stream, encoding='utf-8')
        wr.writerow(fields)  # CSV header row.
        for i in ITSystemDependency.objects.all():
            wr.writerow([
                i.itsystem.name, i.itsystem.get_status_display(),
                i.dependency.name, i.dependency.get_status_display(),
                i.get_criticality_display(), i.description])

        response = HttpResponse(stream.getvalue(), content_type='text/csv')
        response['Content-Disposition'] = 'attachment; filename=itsystemdependency_all.csv'
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号