Merge remote-tracking branch '210.77.77.77/master'
# Conflicts: # .idea/workspace.xml
This commit is contained in:
commit
5001e7a7bf
|
@ -0,0 +1,7 @@
|
|||
.idea/
|
||||
.venv/
|
||||
.media/
|
||||
*/__pycache__/
|
||||
*/*.pyc
|
||||
*/migrations
|
||||
NewMediaMonitoring/local_settings.py
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="django" name="Django">
|
||||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="NewMediaMonitoring/settings.py" />
|
||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
<option name="doNotUseTestRunner" value="false" />
|
||||
<option name="trackFilePattern" value="migrations" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="newmediaDB1@210.77.68.250" uuid="0fffd6d4-73be-43bd-94b0-fcfe2a72c682">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://210.77.68.250:5432/newmediaDB1</jdbc-url>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="db" uuid="305a3c63-fbcc-4242-94cd-8f9b6a0628e5">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:D:\python\p3\NewMediaMonitoring\db.sqlite3</jdbc-url>
|
||||
<driver-properties>
|
||||
<property name="enable_load_extension" value="true" />
|
||||
</driver-properties>
|
||||
<libraries>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/license.txt</url>
|
||||
</library>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/sqlite-jdbc-3.25.1.jar</url>
|
||||
</library>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/license.txt</url>
|
||||
</library>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/sqlite-jdbc-3.25.1.jar</url>
|
||||
</library>
|
||||
</libraries>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (qilianshan)" project-jdk-type="Python SDK" />
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/NewMediaMonitoring.iml" filepath="$PROJECT_DIR$/.idea/NewMediaMonitoring.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -37,6 +37,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_token',
|
||||
'corsheaders',
|
||||
'bootstrap3',
|
||||
'captcha',
|
||||
'dashboard',
|
||||
|
@ -47,11 +49,13 @@ MIDDLEWARE = [
|
|||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django_token.middleware.TokenMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'NewMediaMonitoring.urls'
|
||||
|
@ -79,7 +83,7 @@ WSGI_APPLICATION = 'NewMediaMonitoring.wsgi.application'
|
|||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'newmediaDB1',
|
||||
'USER': 'newmedia',
|
||||
'PASSWORD': 'newmedia2020!@#',
|
||||
|
@ -87,6 +91,7 @@ DATABASES = {
|
|||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
|
||||
|
||||
|
@ -105,6 +110,11 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'django_token.backends.TokenBackend'
|
||||
)
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||
|
||||
|
@ -133,6 +143,10 @@ MEDIA_ROOT = '/var/www/p3/NewMediaMonitoring/media/'
|
|||
AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile'
|
||||
"""用户模块扩展完成"""
|
||||
|
||||
CORS_ORIGIN_ALLOW_ALL = True
|
||||
|
||||
CORS_URLS_REGEX = r'^/polls/.*$'
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError as e:
|
||||
|
|
|
@ -17,6 +17,7 @@ from django.contrib import admin
|
|||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('polls/', include('polls.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('dashboard.urls')),
|
||||
path('captcha/', include('captcha.urls')),
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# install
|
||||
|
||||
```shell
|
||||
pip install -r requirements.txt
|
||||
|
||||
pip install git+https://github.com/RobWeber3/django-token.git
|
||||
|
||||
```
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PollsConfig(AppConfig):
|
||||
name = 'polls'
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,10 @@
|
|||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
path('status_500', views.status_500, name='status_500'),
|
||||
path('status_401', views.status_401, name='status_401'),
|
||||
path('login', views.polls_login, name='polls_login'),
|
||||
]
|
|
@ -0,0 +1,43 @@
|
|||
from django.shortcuts import render
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def index(request):
|
||||
username = request.GET.get('username')
|
||||
password = request.GET.get('password')
|
||||
print(username, password)
|
||||
return JsonResponse({'status': 'error', 'message': '用户名或密码错误'})
|
||||
|
||||
|
||||
def status_500(request):
|
||||
return HttpResponse(status=500)
|
||||
|
||||
|
||||
def status_401(request):
|
||||
return HttpResponse(status=401)
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def polls_login(request):
|
||||
if request.method == 'POST':
|
||||
phone = request.POST.get('phone')
|
||||
password = request.POST.get('password')
|
||||
UserModel = get_user_model()
|
||||
user = UserModel.objects.filter(first_name=phone).first()
|
||||
if not user:
|
||||
return JsonResponse({'status': 'error', 'message': '用户名或密码错误'})
|
||||
|
||||
u = authenticate(request, username=user.username, password=password)
|
||||
if u is not None:
|
||||
login(request, u)
|
||||
print(u)
|
||||
result = dict()
|
||||
return JsonResponse(result)
|
||||
else:
|
||||
return JsonResponse({'status': 'error', 'message': '用户名或密码错误'})
|
||||
else:
|
||||
return JsonResponse({})
|
|
@ -0,0 +1,5 @@
|
|||
Django~=2.2.15
|
||||
django-bootstrap3
|
||||
django-simple-captcha
|
||||
psycopg2-binary
|
||||
django-cors-headers
|
Loading…
Reference in New Issue