10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | {% for post in post_list %}
20 | {% if forloop.first %}
21 |
22 | {% else %}
23 |
24 | {% endif %}
25 |

26 |
27 |
{{post.title}}
28 |
{{post.abstract}}
29 |
30 |
31 | {% endfor %}
32 |
33 |
34 |
35 |
36 |
37 | 上一页
38 |
39 |
40 |
41 | 下一页
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |

50 |
创业信息
51 |
知己知彼,百战不殆!
52 |
更多信息
53 |
54 |
55 |
56 |

57 |
创业伙伴
58 |
强强联手,成就霸业!
59 |
更多信息
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | {% endblock %}
70 |
--------------------------------------------------------------------------------
/mysite/InfoRec/templates/info.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block title %}
4 | 创业信息
5 | {% endblock %}
6 |
7 | {% block cssfile %}
8 |
9 | {% endblock %}
10 |
11 | {% block content %}
12 |
13 |
14 |
15 |
32 |
33 | {% if post_list.object_list and post_list.paginator.num_pages > 1 %}
34 |
49 | {% endif %}
50 |
51 |
52 |
60 |
61 |
62 | {% endblock %}
63 |
--------------------------------------------------------------------------------
/mysite/InfoRec/templates/login.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block title %}登陆{% endblock %}
4 |
5 | {% block content %}
6 |
7 |
13 |
14 |
15 |
16 |
17 | {% if state == 'not_exist_or_password_error' %}
18 |
19 |
用户不存在或密码错误
20 |
21 | {% endif %}
22 |
23 |
46 |
47 |
48 |
49 |
50 |
51 | {% endblock %}
52 |
--------------------------------------------------------------------------------
/mysite/InfoRec/templates/partner.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block title %}
4 | 创业伙伴
5 | {% endblock %}
6 |
7 | {% block cssfile %}
8 |
9 | {% endblock %}
10 |
11 | {% block content %}
12 |
13 | 创业伙伴
14 | 集结最广泛的创业伙伴信息
15 |
16 |
17 |
18 |
19 | {% for per in user_list %}
20 |
21 |
22 |

23 |
24 |
{{ per.username }}
25 |
用户名:{{ per.user.username }}
26 |
关注话题:
27 |
28 |
29 |
30 |
31 |
32 |
33 | {% endfor %}
34 |
35 |
36 |
37 |
38 | {% endblock %}
39 |
40 | {% block jsfile %}
41 |
42 | {% endblock %}
43 |
--------------------------------------------------------------------------------
/mysite/InfoRec/templates/register.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}注册{% endblock %}
3 |
4 | {% block content %}
5 |
11 |
12 |
13 |
14 |
15 | {% if state == 'success' %}
16 |
17 |
注册成功!
18 |
19 | {% elif state == 'repeat_error' %}
20 |
21 |
密码重复错误
22 |
23 | {% elif state == 'empty' %}
24 |
25 |
密码不能为空
26 |
27 | {% elif state == 'user_exist' %}
28 |
29 |
用户已经存在
30 |
31 | {% endif %}
32 |
87 |
88 |
89 |
90 | {% endblock %}
91 |
--------------------------------------------------------------------------------
/mysite/InfoRec/templates/tutor.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
--------------------------------------------------------------------------------
/mysite/InfoRec/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/mysite/InfoRec/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 | from django.http import HttpResponse, HttpResponseRedirect
3 | from django.contrib.auth.decorators import user_passes_test, login_required
4 | from django.contrib.auth.models import User
5 | from django.contrib import auth
6 | from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger #分页需要添加包
7 | from django.core.urlresolvers import reverse
8 | from InfoRec.models import myuser, myarticle
9 | from django import forms
10 | import logging
11 | import time
12 |
13 | # Create your views here.
14 |
15 | def home(request):
16 | user = request.user if request.user.is_authenticated() else None
17 | post_list = myarticle.objects.all()[0:3]
18 |
19 | content={
20 | 'post_list':post_list,
21 | 'user':user,
22 | }
23 | return render(request, 'home.html', content)
24 |
25 | def info(request):
26 | user = request.user if request.user.is_authenticated() else None
27 |
28 | posts = myarticle.objects.all()[::-1]
29 | paginator = Paginator(posts, 10)
30 | page = request.GET.get('page')
31 | try:
32 | post_list = paginator.page(page)
33 | except PageNotAnInteger:
34 | post_list = paginator.page(1)
35 | except EmptyPage:
36 | post_list = paginator.paginator(paginator.num_pages)
37 |
38 | content = {
39 | 'post_list':post_list,
40 | 'rec_list':posts[0:10],
41 | 'user':user,
42 | }
43 | return render(request, 'info.html', content);
44 |
45 | def artDetail(request, articleId):
46 | user = request.user if request.user.is_authenticated() else None
47 |
48 | article = myarticle.objects.get(id=articleId)
49 |
50 | logger = logging.getLogger('mylogger')
51 | # logger.setLevel(logging.INFO)
52 |
53 | # fh = logging.FileHandler('./InfoRec/log/test.log')
54 | # fh.setLevel(logging.INFO)
55 |
56 | # formatter = logging.Formatter('%(message)s')
57 | # fh.setFormatter(formatter)
58 |
59 | # logger.addHandler(fh)
60 | # print("%s::%s" % (user.id, articleId))
61 | if user != None :
62 | logger.info("%s::%s::%s" % (user.id, articleId, time.strftime("%Y%m%d%H%M%S",time.localtime(time.time()))))
63 |
64 | posts = myarticle.objects.all()[::-1]
65 | content={
66 | 'article': article,
67 | 'rec_list':posts[0:10],
68 | 'user': user,
69 | }
70 | return render(request, 'artDetail.html', content)
71 |
72 | def partner(request):
73 | user = request.user if request.user.is_authenticated() else None
74 | # print(user)
75 |
76 | user_list = myuser.objects.all()
77 |
78 | content={
79 | 'user_list':user_list,
80 | 'user':user,
81 | }
82 | return render(request, 'partner.html', content);
83 |
84 | def register(request):
85 | if request.user.is_authenticated():
86 | return HttpResponseRedirect(reverse("home"))
87 | state = None
88 | if request.method == "POST":
89 |
90 | username = request.POST.get('username','')
91 | password = request.POST.get('password','')
92 | password_repeat = request.POST.get('password_repeat','')
93 | email_address = request.POST.get('email','')
94 |
95 | if password=='' or password_repeat=='' :
96 | state='empty'
97 | elif password != password_repeat:
98 | state='repeat_error'
99 | elif User.objects.filter(username=username):
100 | state='user_exist'
101 | else:
102 | new_user = User.objects.create_user(username=username, password=password, email=email_address)
103 | new_user.save()
104 | new_myuser = myuser(user=new_user,)
105 | new_myuser.save()
106 | state='success'
107 |
108 | content = {
109 | 'active_menu': 'home',
110 | 'state': state,
111 | 'user': None,
112 | }
113 | return render(request, 'register.html', content)
114 |
115 | def login(request):
116 | if request.user.is_authenticated():
117 | return HttpResponseRedirect(reverse('home'))
118 | state = None
119 | if request.method == "POST":
120 | username = request.POST.get('username','')
121 | password = request.POST.get('password','')
122 | user = auth.authenticate(username=username, password=password)
123 | if user is not None:
124 | auth.login(request, user)
125 | return HttpResponseRedirect(reverse('home'))
126 | else:
127 | state = 'not_exist_or_password_error'
128 |
129 | content={
130 | 'state': state,
131 | 'user': None
132 | }
133 | return render(request, 'login.html', content);
134 |
135 |
136 | def logout(request):
137 | auth.logout(request)
138 | return HttpResponseRedirect(reverse('home'))
139 |
--------------------------------------------------------------------------------
/mysite/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
7 |
8 | from django.core.management import execute_from_command_line
9 |
10 | execute_from_command_line(sys.argv)
11 |
--------------------------------------------------------------------------------
/mysite/mysite/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TomatoFish666/RecSystem/f37e338e841f65e22974a1ac75807be99e0dbc13/mysite/mysite/__init__.py
--------------------------------------------------------------------------------
/mysite/mysite/__pycache__/__init__.cpython-34.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TomatoFish666/RecSystem/f37e338e841f65e22974a1ac75807be99e0dbc13/mysite/mysite/__pycache__/__init__.cpython-34.pyc
--------------------------------------------------------------------------------
/mysite/mysite/__pycache__/settings.cpython-34.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TomatoFish666/RecSystem/f37e338e841f65e22974a1ac75807be99e0dbc13/mysite/mysite/__pycache__/settings.cpython-34.pyc
--------------------------------------------------------------------------------
/mysite/mysite/__pycache__/urls.cpython-34.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TomatoFish666/RecSystem/f37e338e841f65e22974a1ac75807be99e0dbc13/mysite/mysite/__pycache__/urls.cpython-34.pyc
--------------------------------------------------------------------------------
/mysite/mysite/__pycache__/wsgi.cpython-34.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TomatoFish666/RecSystem/f37e338e841f65e22974a1ac75807be99e0dbc13/mysite/mysite/__pycache__/wsgi.cpython-34.pyc
--------------------------------------------------------------------------------
/mysite/mysite/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for mysite project.
3 |
4 | Generated by 'django-admin startproject' using Django 1.8.9.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/1.8/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/1.8/ref/settings/
11 | """
12 |
13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
14 | import os
15 |
16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '*8jujvi=um&o!rhu43l62j6=^nrdxpwcy4q7jkxkf59ve3#m&%'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = (
34 | 'django.contrib.admin',
35 | 'django.contrib.auth',
36 | 'django.contrib.contenttypes',
37 | 'django.contrib.sessions',
38 | 'django.contrib.messages',
39 | 'django.contrib.staticfiles',
40 | 'InfoRec',
41 | )
42 |
43 | MIDDLEWARE_CLASSES = (
44 | 'django.contrib.sessions.middleware.SessionMiddleware',
45 | 'django.middleware.common.CommonMiddleware',
46 | 'django.middleware.csrf.CsrfViewMiddleware',
47 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | 'django.middleware.security.SecurityMiddleware',
52 | )
53 |
54 | ROOT_URLCONF = 'mysite.urls'
55 |
56 | TEMPLATES = [
57 | {
58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
59 | 'DIRS': [],
60 | 'APP_DIRS': True,
61 | 'OPTIONS': {
62 | 'context_processors': [
63 | 'django.template.context_processors.debug',
64 | 'django.template.context_processors.request',
65 | 'django.contrib.auth.context_processors.auth',
66 | 'django.contrib.messages.context_processors.messages',
67 | ],
68 | },
69 | },
70 | ]
71 |
72 | WSGI_APPLICATION = 'mysite.wsgi.application'
73 |
74 |
75 | # Database
76 | # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
77 |
78 | DATABASES = {
79 | 'default': {
80 | 'ENGINE': 'django.db.backends.mysql',
81 | 'NAME': 'InforRec',
82 | 'USER': 'manager',
83 | 'PASSWORD': '123456',
84 | 'HOST': 'localhost',
85 | 'PORT': '3306',
86 | }
87 | }
88 |
89 |
90 | # Internationalization
91 | # https://docs.djangoproject.com/en/1.8/topics/i18n/
92 |
93 | LANGUAGE_CODE = 'en-us'
94 |
95 | # TIME_ZONE = 'UTC'
96 | TIME_ZONE = 'Asia/Shanghai'
97 |
98 | USE_I18N = True
99 |
100 | USE_L10N = True
101 |
102 | USE_TZ = True
103 |
104 |
105 | # Static files (CSS, JavaScript, Images)
106 | # https://docs.djangoproject.com/en/1.8/howto/static-files/
107 |
108 | STATIC_URL = '/static/'
109 |
110 | LOGGING={
111 | 'version':1,
112 | 'disable_existing_loggers': False,
113 | 'handlers':{
114 | 'myhandler':{
115 | 'level': 'INFO',
116 | 'class': 'logging.FileHandler',
117 | 'filename': './InfoRec/log/test.log',
118 | },
119 | },
120 | 'loggers':{
121 | 'mylogger': {
122 | 'handlers': ['myhandler'],
123 | 'level': 'INFO',
124 | 'propagate': True,
125 | },
126 | },
127 | }
128 |
--------------------------------------------------------------------------------
/mysite/mysite/urls.py:
--------------------------------------------------------------------------------
1 | """mysite URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
14 | """
15 | from django.conf.urls import include, url
16 | from django.contrib import admin
17 | from InfoRec import views as InfoRec_views
18 |
19 | urlpatterns = [
20 |
21 | url(r'^$', InfoRec_views.home, name="home"),
22 | url(r'^admin/', include(admin.site.urls)),
23 |
24 | url(r'^info/$', InfoRec_views.info, name="info"),
25 | url(r'^info/(?P
[0-9]+)/$', InfoRec_views.artDetail, name="artDetail"),
26 |
27 | url(r'^partner/$', InfoRec_views.partner, name="partner"),
28 | # url(r'^partner/(?P)/$', InfoRec_views.user, name="user"),
29 |
30 | # url(r'^tutor/$', InfoRec_views. name="tutor"),
31 | # url(r'^tutor/(?P<>)$', InfoRec_views. name=""),
32 |
33 | url(r'^register/$', InfoRec_views.register, name="register"),
34 | url(r'^login/$', InfoRec_views.login, name="login"),
35 | url(r'^logout/$', InfoRec_views.logout, name="logout"),
36 | ]
37 |
--------------------------------------------------------------------------------
/mysite/mysite/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for mysite project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------