Merge pull request #611 from liangliangyy/dev

datetime->timezone
sh_branch
且听风吟 3 years ago committed by GitHub
commit e3db6576f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +1,8 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches:
branches:
- master
- dev
paths-ignore:
@ -23,7 +12,6 @@ on:
- '**/*.yml'
- '**/*.txt'
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
- dev
@ -34,54 +22,26 @@ on:
- '**/*.yml'
- '**/*.txt'
schedule:
- cron: '33 6 * * 0'
- cron: '30 1 * * 0'
jobs:
analyze:
name: Analyze
CodeQL-Build:
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
uses: github/codeql-action/init@v2
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

@ -42,11 +42,12 @@ jobs:
mysql user: root
mysql password: root
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
@ -93,11 +94,12 @@ jobs:
stack-version: '7.12.1'
plugins: 'https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.1/elasticsearch-analysis-ik-7.12.1.zip'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
@ -122,12 +124,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
push: false

@ -22,19 +22,19 @@ jobs:
run: |
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
push: true

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Docker meta
id: meta
@ -17,16 +17,16 @@ jobs:
with:
images: name/app
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
push: true

@ -1,5 +1,6 @@
import logging
from datetime import datetime
from django.utils import timezone
from djangoblog.utils import cache, get_blog_setting
from .models import Category, Article
@ -33,6 +34,6 @@ def seo_processor(requests):
'ANALYTICS_CODE': setting.analyticscode,
"BEIAN_CODE_GONGAN": setting.gongan_beiancode,
"SHOW_GONGAN_CODE": setting.show_gongan_code,
"CURRENT_YEAR": datetime.now().year}
"CURRENT_YEAR": timezone.now().year}
cache.set(key, value, 60 * 60 * 10)
return value

@ -1,4 +1,3 @@
import datetime
import logging
import os
import uuid
@ -8,6 +7,7 @@ from django.core.paginator import Paginator
from django.http import HttpResponse, HttpResponseForbidden
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
@ -309,7 +309,7 @@ def fileupload(request):
return HttpResponseForbidden()
response = []
for filename in request.FILES:
timestr = datetime.datetime.now().strftime('%Y/%m/%d')
timestr = timezone.now().strftime('%Y/%m/%d')
imgextensions = ['jpg', 'png', 'jpeg', 'bmp']
fname = u''.join(str(filename))
isimage = len([i for i in imgextensions if fname.find(i) >= 0]) > 0

@ -29,7 +29,7 @@ class Comment(models.Model):
'是否显示', default=True, blank=False, null=False)
class Meta:
ordering = ['id']
ordering = ['-id']
verbose_name = "评论"
verbose_name_plural = verbose_name
get_latest_by = 'id'

@ -1,11 +1,10 @@
from datetime import datetime
from django.contrib.auth import get_user_model
from django.contrib.syndication.views import Feed
from django.utils import timezone
from django.utils.feedgenerator import Rss201rev2Feed
from djangoblog.utils import CommonMarkdown
from blog.models import Article
from djangoblog.utils import CommonMarkdown
class DjangoBlogFeed(Feed):
@ -31,7 +30,7 @@ class DjangoBlogFeed(Feed):
return CommonMarkdown.get_markdown(item.body)
def feed_copyright(self):
now = datetime.now()
now = timezone.now()
return "Copyright© {year} 且听风吟".format(year=now.year)
def item_link(self, item):

@ -1,4 +1,3 @@
import datetime
import logging
# Create your views here.
from urllib.parse import urlparse
@ -13,6 +12,7 @@ from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.urls import reverse
from django.utils import timezone
from django.views.generic import FormView
from djangoblog.blog_signals import oauth_user_login_signal
@ -73,8 +73,7 @@ def authorize(request):
user = manager.get_oauth_userinfo()
if user:
if not user.nikename or not user.nikename.strip():
import datetime
user.nikename = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S')
user.nikename = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
try:
temp = OAuthUser.objects.get(type=type, openid=user.openid)
temp.picture = user.picture
@ -102,7 +101,7 @@ def authorize(request):
except ObjectDoesNotExist:
author.username = user.nikename
else:
author.username = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S')
author.username = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
author.source = 'authorize'
author.save()
@ -141,7 +140,7 @@ def emailconfirm(request, id, sign):
if result[1]:
author.source = 'emailconfirm'
author.username = oauthuser.nikename.strip() if oauthuser.nikename.strip(
) else "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S')
) else "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
author.save()
oauthuser.author = author
oauthuser.save()

@ -10,6 +10,7 @@ from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.http import JsonResponse
from django.shortcuts import render
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from .models import OwnTrackLog
@ -45,7 +46,7 @@ def manage_owntrack_log(request):
@login_required
def show_maps(request):
if request.user.is_superuser:
defaultdate = str(datetime.datetime.now().date())
defaultdate = str(timezone.now().date())
date = request.GET.get('date', defaultdate)
context = {
'date': date

Loading…
Cancel
Save