Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
leafcoder committed May 19, 2020
2 parents 03b809b + 0caf290 commit ac24cd6
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 523 deletions.
69 changes: 46 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
<div align="center">

# 新冠肺炎实时接口 {docsify-ignore}

<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/leafcoder/django-covid19/subscription" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Watch leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/watchers/leafcoder/django-covid19?style=social">
</a>
<a class="github-button" href="https://github.com/leafcoder/django-covid19" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Star leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/stars/leafcoder/django-covid19?style=social">
</a>
<a class="github-button" href="https://github.com/leafcoder/django-covid19/fork" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Fork leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/leafcoder/django-covid19?style=social">
</a>

![GitHub release (latest by date)](https://img.shields.io/github/v/release/leafcoder/django-covid19)
![GitHub top language](https://img.shields.io/github/languages/top/leafcoder/django-covid19)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/leafcoder/django-covid19)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/leafcoder/django-covid19)
![GitHub All Releases](https://img.shields.io/github/downloads/leafcoder/django-covid19/total)
# 新冠肺炎实时接口

<p>
<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/leafcoder/django-covid19/subscription" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Watch leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/watchers/leafcoder/django-covid19?style=social">
</a>
<a class="github-button" href="https://github.com/leafcoder/django-covid19" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Star leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/stars/leafcoder/django-covid19?style=social">
</a>
<a class="github-button" href="https://github.com/leafcoder/django-covid19/fork" data-color-scheme="no-preference: light; light: light; dark: dark;" data-show-count="true" aria-label="Fork leafcoder/django-covid19 on GitHub">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/leafcoder/django-covid19?style=social">
</a>
</p>

<p>
<img src="https://img.shields.io/github/v/release/leafcoder/django-covid19" data-origin="https://img.shields.io/github/v/release/leafcoder/django-covid19" alt="GitHub release (latest by date)">
<img src="https://img.shields.io/github/languages/top/leafcoder/django-covid19" data-origin="https://img.shields.io/github/languages/top/leafcoder/django-covid19" alt="GitHub top language">
<img src="https://img.shields.io/github/languages/code-size/leafcoder/django-covid19" data-origin="https://img.shields.io/github/languages/code-size/leafcoder/django-covid19" alt="GitHub code size in bytes">
<img src="https://img.shields.io/github/commit-activity/w/leafcoder/django-covid19" data-origin="https://img.shields.io/github/commit-activity/w/leafcoder/django-covid19" alt="GitHub commit activity">
<img src="https://img.shields.io/github/downloads/leafcoder/django-covid19/total" data-origin="https://img.shields.io/github/downloads/leafcoder/django-covid19/total" alt="GitHub All Releases">
</p>

</div>

# 接口文档
# 项目文档

点击查看 [在线接口文档](https://blog.leafcoder.cn/django-covid19/)
本项目使用开源文档工具 [docsify](https://docsify.js.org) 编写了一份开发文档。

文档将如何安装部署本项目作了详细的描述,开发者可根据自身需求搭建一个属于个人
*新冠肺炎实时接口*,并通过项目提供的爬虫工具实时、定时的更新疫情数据,追踪
疫情的最新情况。

如果开发者本身没有个人的云服务器用来部署本项目,也可以直接调用本项目已部署好
的实时接口,可用于科研、娱乐、教学等各方面。

[![在线文档](docs/images/docs.png)](http://111.231.75.86:8000/docs/)

# 在线大屏

点击查看 [在线数据大屏](http://111.231.75.86/dashboard)
根据已部署的疫情在线接口,并结合使用开源数据大屏项目中的示例代码,本项目提
供了一个使用本项目接口的数据大屏示例。

[![在线数据大屏](docs/images/dashboard.png)](http://111.231.75.86/dashboard)

# 问题相关

有任何问题欢迎在 github 中提 issue,或者在文档页面的最后提交[评论](http://111.231.75.86:8000/docs/#/?id=detail-1),我会尽快解答。

* 推荐使用评论方式提问;
* 推荐使用 isuss 提交 bug;

# 文档预览
# 致各位

![图片](docs/images/docs.png)
如果本项目对你有所帮助,请在[此处](http://111.231.75.86:8000/docs/#/?id=detail-1)留下你的项目地址。
16 changes: 8 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
本项目的数据来源为[`丁香园`](http://ncov.dxy.cn/ncovh5/view/pneumonia),定时获取疫
情数据,保存疫情数据变更情况,以备跟踪研究和数据图表化展示。

# 快速开始 :id=quick-start

请按照以下步骤完成项目的初始化和启动。

!> 注意:请先修改 covid19/settings.py 中 `SCRAPY_CMD`,设置为 scrapy 命令完整路径。
否则,自动更新任务将无法正常运行

## 代码仓库

项目开源,需要源代码可以前往仓库自行获取。

[前往获取源码](https://github.com/leafcoder/django-covid19)

# 线上示例
## 线上示例

使用本项目的接口开发了一个数据大屏的示例页面,代码在项目根目录的 `demo/` 文件夹中。

前往在线示例 [新冠肺炎实时数据大屏](http://111.231.75.86/dashboard)

# 快速开始 :id=quick-start

请按照以下步骤完成项目的初始化和启动。

!> 注意:请先修改 covid19/settings.py 中 `SCRAPY_CMD`,设置为 scrapy 命令完整路径。
否则,自动更新任务将无法正常运行

## 源码下载 :id=download

可以通过 `git clone` 直接将 `master` 分支的代码克隆到本机使用;
Expand Down
Binary file added docs/images/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 3 additions & 56 deletions ncovapi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,14 @@ class BaseAdmin(admin.ModelAdmin):
preserve_filters = True


@admin.register(models.Crawler)
class CrawlerAdmin(BaseAdmin):

list_display = (
'id', 'crawlTime', 'createTime', 'modifyTime'
)


@admin.register(models.Statistics)
class StatisticsAdmin(BaseAdmin):

list_display = (
'id', 'countryType', 'seriousCount', 'currentConfirmedCount',
'confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'
)
search_fields = ('crawler_id', )
list_filter = ('countryType', )


@admin.register(models.Notice)
class NoticeAdmin(BaseAdmin):

list_display = (
'id', 'crawler', 'remarks', 'notes', 'generalRemark'
'globalStatistics', 'domesticStatistics', 'internationalStatistics',
'modifyTime', 'createTime', 'crawlTime'
)

@admin.register(models.WHOArticle)
class WHOArticleAdmin(BaseAdmin):

list_display = ('id', 'title', 'linkUrl', 'imgUrl')

@admin.register(models.Recommend)
class RecommendAdmin(BaseAdmin):

list_display = (
'id', 'title', 'linkUrl', 'imgUrl', 'contentType',
'countryType', 'recordStatus')

@admin.register(models.Timeline)
class TimelineAdmin(BaseAdmin):

list_display = (
'id', 'title', 'summary', 'pubDateStr', 'infoSource', 'sourceUrl')

@admin.register(models.Wiki)
class WikiAdmin(BaseAdmin):

list_display = ('id', 'title', 'linkUrl', 'imgUrl', 'description')

@admin.register(models.GoodsGuide)
class GoodsGuideAdmin(BaseAdmin):

list_display = (
'categoryName', 'title', 'recordStatus', 'contentImgUrls')

@admin.register(models.Rumor)
class RumorAdmin(BaseAdmin):

list_display = (
'title', 'mainSummary', 'summary', 'body',
'sourceUrl', 'score', 'rumorType')
search_fields = ('crawlTime', 'modifyTime')

@admin.register(models.City)
class CityAdmin(BaseAdmin):
Expand Down
16 changes: 15 additions & 1 deletion ncovapi/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ class CityFilter(django_filters.rest_framework.FilterSet):

provinceShortNames = CharInFilter(
field_name='province__provinceShortName', lookup_expr='in')
provinceNames = CharInFilter(
field_name='province__provinceName', lookup_expr='in')
cityNames = CharInFilter(
field_name='cityName', lookup_expr='in')

provinceShortName = django_filters.CharFilter(
field_name='province__provinceShortName', lookup_expr='exact')
provinceName = django_filters.CharFilter(
field_name='province__provinceName', lookup_expr='exact')
cityName = django_filters.CharFilter(
field_name='cityName', lookup_expr='exact')

class Meta:
model = City
fields = ['provinceShortNames', 'cityName']
fields = ['provinceShortName', 'provinceName', 'cityName']


class ProvinceFilter(django_filters.rest_framework.FilterSet):
Expand All @@ -26,6 +35,11 @@ class ProvinceFilter(django_filters.rest_framework.FilterSet):
provinceNames = CharInFilter(
field_name='provinceName', lookup_expr='in')

provinceShortName = django_filters.CharFilter(
field_name='provinceShortName', lookup_expr='exact')
provinceName = django_filters.CharFilter(
field_name='provinceName', lookup_expr='exact')

class Meta:
model = Province
fields = ['provinceName', 'provinceShortName']
Expand Down
Loading

0 comments on commit ac24cd6

Please sign in to comment.