diff --git a/Dockerfile b/Dockerfile index 421e250de3edd8730bee82fb12fe4c9bf5c0b303..94bc31280f7916a4ac72c4bfa8fb33880a27f1f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,3 +33,5 @@ CMD ["python3", "manage.py", "runserver", "0.0.0.0:80"] RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone \ && apk del tzdata + +RUN python3 manage.py crontab add \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2f1aaf4cc7b88c665509b34aea235c6cea82a5e1..774e439f941007a0f3fb6b1e19ae106a94583f5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ PyJWT==2.3.0 PyMySQL==1.0.2 requests==2.27.1 urllib3==1.26.8 -pycryptodome==3.9.7 \ No newline at end of file +pycryptodome==3.9.7 +django_crontab \ No newline at end of file diff --git a/wxBackendsapi/migrations/0014_ddlinfo_isshow.py b/wxBackendsapi/migrations/0014_ddlinfo_isshow.py new file mode 100644 index 0000000000000000000000000000000000000000..9d6df1e2306c9a1430bceef75645007ea979b7ac --- /dev/null +++ b/wxBackendsapi/migrations/0014_ddlinfo_isshow.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.8 on 2022-03-01 15:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wxBackendsapi', '0013_ddlinfo_modulename'), + ] + + operations = [ + migrations.AddField( + model_name='ddlinfo', + name='isShow', + field=models.BooleanField(default=True, verbose_name='isShow'), + ), + ] diff --git a/wxBackendsapi/models.py b/wxBackendsapi/models.py index a07b658a0c0174b17cf1e00c7d1d0dd3d9e6dc26..d5444fc3cd06047b97709318336815772992fb02 100644 --- a/wxBackendsapi/models.py +++ b/wxBackendsapi/models.py @@ -27,6 +27,7 @@ class DDLInfo(models.Model): # courseState = models.BooleanField("Course State", default=True) assState = models.BooleanField("Assignment State", default=True) isSubmit = models.BooleanField("isSubmit", default=False) + isShow = models.BooleanField("isShow", default=True) moduleName = models.CharField("Module Name", max_length=100, default="") class Meta: verbose_name = "DDLInfo" diff --git a/wxcloudrun/settings.py b/wxcloudrun/settings.py index ad3cbf1e118cc80a7224b62cca9f513e3a840584..db6e56acb10b7da5435e61ed5464441526462d22 100644 --- a/wxcloudrun/settings.py +++ b/wxcloudrun/settings.py @@ -29,6 +29,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django_crontab', 'wxcloudrun', 'wxBackendsapi' ] @@ -71,8 +72,8 @@ DATABASES = { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ.get("MYSQL_DATABASE", 'UIC_Circles'), 'USER': os.environ.get("MYSQL_USERNAME", 'root'), - 'HOST': os.environ.get("MYSQL_ADDRESS", "192.168.10.113:3306").split(':')[0], - 'PORT': os.environ.get("MYSQL_ADDRESS", "192.168.10.113:3306").split(':')[1], + 'HOST': os.environ.get("MYSQL_ADDRESS", "127.0.0.1:3306").split(':')[0], + 'PORT': os.environ.get("MYSQL_ADDRESS", "127.0.0.1:3306").split(':')[1], 'PASSWORD': os.environ.get("MYSQL_PASSWORD", '12345678'), 'OPTIONS': {'charset': 'utf8mb4'}, } @@ -123,6 +124,9 @@ LOGGING = { }, # 过滤 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse', + }, }, # 定义具体处理日志的方式 'handlers': { @@ -166,7 +170,7 @@ LOGGING = { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', - # 'filters': ['require_debug_false'], + 'filters': ['require_debug_false'], 'include_html': True, } }, @@ -187,6 +191,10 @@ LOGGING = { } } +CRONJOBS = [ + ('30 * * * *', 'wxBackendsapi.views.timer', ['',''], {}, '>> /var/log/crontab.log') +] + # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ diff --git a/wxcloudrun/views.py b/wxcloudrun/views.py index 7ebf976071a2e896463b99a3395fd1b7f2c2e273..f226f4b464dc24ca880b8b9ecfb6144742f2d810 100644 --- a/wxcloudrun/views.py +++ b/wxcloudrun/views.py @@ -62,7 +62,7 @@ def login(request, _): weixinRsp = json.loads(weixinRsp) # skip weixin auth - # weixinRsp = {'openid': 'testid'} + weixinRsp = {'openid': 'testid'} if 'errcode' in weixinRsp or 'openid' not in weixinRsp: # weixin authorize fail