├── .idea
├── SmartClassroom.iml
├── inspectionProfiles
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
└── workspace.xml
├── SmartClassroom
├── __init__.py
├── __init__.pyc
├── __pycache__
│ ├── __init__.cpython-36.pyc
│ ├── consumers.cpython-36.pyc
│ ├── routing.cpython-36.pyc
│ ├── settings.cpython-36.pyc
│ ├── urls.cpython-36.pyc
│ └── wsgi.cpython-36.pyc
├── consumers.py
├── routing.py
├── settings.py
├── settings.pyc
├── urls.py
├── urls.pyc
├── wsgi.py
└── wsgi.pyc
├── db.sqlite3
├── detail
├── __init__.py
├── __init__.pyc
├── __pycache__
│ ├── __init__.cpython-36.pyc
│ ├── admin.cpython-36.pyc
│ ├── apps.cpython-36.pyc
│ ├── models.cpython-36.pyc
│ ├── serializers.cpython-36.pyc
│ └── views.cpython-36.pyc
├── admin.py
├── admin.pyc
├── apps.py
├── apps.pyc
├── migrations
│ ├── 0001_initial.py
│ ├── 0001_initial.pyc
│ ├── 0002_detail_date.py
│ ├── 0002_detail_date.pyc
│ ├── 0003_auto_20170607_1235.py
│ ├── 0004_auto_20170607_1320.py
│ ├── 0005_auto_20170607_1402.py
│ ├── __init__.py
│ ├── __init__.pyc
│ └── __pycache__
│ │ ├── 0001_initial.cpython-36.pyc
│ │ ├── 0002_detail_date.cpython-36.pyc
│ │ ├── 0003_auto_20170607_1235.cpython-36.pyc
│ │ ├── 0004_auto_20170607_1320.cpython-36.pyc
│ │ ├── 0005_auto_20170607_1402.cpython-36.pyc
│ │ └── __init__.cpython-36.pyc
├── models.py
├── models.pyc
├── serializers.py
├── serializers.pyc
├── tests.py
├── views.py
└── views.pyc
├── manage.py
├── message
├── __init__.py
├── __init__.pyc
├── __pycache__
│ ├── __init__.cpython-36.pyc
│ ├── admin.cpython-36.pyc
│ ├── apps.cpython-36.pyc
│ ├── models.cpython-36.pyc
│ ├── serializers.cpython-36.pyc
│ └── views.cpython-36.pyc
├── admin.py
├── admin.pyc
├── apps.py
├── apps.pyc
├── migrations
│ ├── 0001_initial.py
│ ├── __init__.py
│ ├── __init__.pyc
│ └── __pycache__
│ │ ├── 0001_initial.cpython-36.pyc
│ │ └── __init__.cpython-36.pyc
├── models.py
├── models.pyc
├── serializers.py
├── serializers.pyc
├── tests.py
├── views.py
└── views.pyc
├── requirements.txt
├── student
├── __init__.py
├── __init__.pyc
├── __pycache__
│ ├── __init__.cpython-36.pyc
│ ├── admin.cpython-36.pyc
│ ├── apps.cpython-36.pyc
│ ├── models.cpython-36.pyc
│ ├── serializers.cpython-36.pyc
│ └── views.cpython-36.pyc
├── admin.py
├── admin.pyc
├── apps.py
├── apps.pyc
├── migrations
│ ├── 0001_initial.py
│ ├── 0001_initial.pyc
│ ├── 0002_auto_20170525_0213.py
│ ├── 0002_auto_20170525_0213.pyc
│ ├── 0003_remove_status_name.py
│ ├── 0003_remove_status_name.pyc
│ ├── 0004_status_name.py
│ ├── 0004_status_name.pyc
│ ├── 0005_auto_20170525_0234.py
│ ├── 0005_auto_20170525_0234.pyc
│ ├── 0006_auto_20170525_1419.py
│ ├── 0006_auto_20170525_1419.pyc
│ ├── 0007_auto_20170525_1429.py
│ ├── 0007_auto_20170525_1429.pyc
│ ├── 0008_remove_student_times.py
│ ├── 0008_remove_student_times.pyc
│ ├── 0009_auto_20170527_0726.py
│ ├── __init__.py
│ ├── __init__.pyc
│ └── __pycache__
│ │ ├── 0001_initial.cpython-36.pyc
│ │ ├── 0002_auto_20170525_0213.cpython-36.pyc
│ │ ├── 0003_remove_status_name.cpython-36.pyc
│ │ ├── 0004_status_name.cpython-36.pyc
│ │ ├── 0005_auto_20170525_0234.cpython-36.pyc
│ │ ├── 0006_auto_20170525_1419.cpython-36.pyc
│ │ ├── 0007_auto_20170525_1429.cpython-36.pyc
│ │ ├── 0008_remove_student_times.cpython-36.pyc
│ │ ├── 0009_auto_20170527_0726.cpython-36.pyc
│ │ └── __init__.cpython-36.pyc
├── models.py
├── models.pyc
├── serializers.py
├── serializers.pyc
├── tests.py
├── views.py
└── views.pyc
└── user
├── __init__.py
├── __init__.pyc
├── __pycache__
├── __init__.cpython-36.pyc
├── admin.cpython-36.pyc
├── apps.cpython-36.pyc
├── models.cpython-36.pyc
├── serializers.cpython-36.pyc
└── views.cpython-36.pyc
├── admin.py
├── admin.pyc
├── apps.py
├── apps.pyc
├── migrations
├── __init__.py
├── __init__.pyc
└── __pycache__
│ └── __init__.cpython-36.pyc
├── models.py
├── models.pyc
├── serializers.py
├── serializers.pyc
├── tests.py
├── views.py
└── views.pyc
/.idea/SmartClassroom.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
68 |
69 |
70 |
71 |
72 | true
73 | DEFINITION_ORDER
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 | 1496724575167
376 |
377 |
378 | 1496724575167
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
--------------------------------------------------------------------------------
/SmartClassroom/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__init__.py
--------------------------------------------------------------------------------
/SmartClassroom/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__init__.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/consumers.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/consumers.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/routing.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/routing.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/settings.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/settings.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/urls.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/urls.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/__pycache__/wsgi.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/__pycache__/wsgi.cpython-36.pyc
--------------------------------------------------------------------------------
/SmartClassroom/consumers.py:
--------------------------------------------------------------------------------
1 | from student.models import Student
2 | from channels import Group, Channel
3 | from channels.sessions import channel_session
4 |
5 | import json
6 |
7 |
8 | @channel_session
9 | def online_connect(message):
10 | message.reply_channel.send({"accept": True})
11 |
12 |
13 | @channel_session
14 | def online_receive(message):
15 | msg_dict = json.loads(message.content['text'])
16 |
17 | username = msg_dict['username']
18 | message.channel_session['username'] = username
19 |
20 | status = msg_dict['status']
21 | user_id = msg_dict['id']
22 | student = Student.objects.get(id=user_id)
23 | student.status = status
24 | student.save()
25 |
26 |
27 | @channel_session
28 | def online_disconnect(message):
29 | Group(username).discard(message.reply_channel)
30 |
--------------------------------------------------------------------------------
/SmartClassroom/routing.py:
--------------------------------------------------------------------------------
1 | from channels.routing import route
2 | from .consumers import online_connect, online_disconnect, online_receive
3 |
4 |
5 | channel_routing = [
6 | route("websocket.connect", online_connect,
7 | path=r'^/online/$'),
8 | route("websocket.receive", online_receive,
9 | path=r'^/online/$'),
10 | route("websocket.disconnect", online_disconnect,
11 | path=r'^/online/$'),
12 | ]
13 |
--------------------------------------------------------------------------------
/SmartClassroom/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for SmartClassroom project.
3 |
4 | Generated by 'django-admin startproject' using Django 1.11.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/1.11/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/1.11/ref/settings/
11 | """
12 |
13 | import os
14 |
15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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.11/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '_gap$8=%6evglr&1lx_&+b#n+vgsp5mimz!8z$=tfcy)ba80-@'
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 | DJANGO_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 | )
41 |
42 | THIRD_PARTY_APPS = (
43 | 'corsheaders',
44 | 'rest_framework',
45 | 'channels'
46 | )
47 |
48 | LOCAL_APPS = (
49 | 'message.apps.MessageConfig',
50 | 'student.apps.StudentConfig',
51 | 'detail.apps.DetailConfig',
52 | 'user.apps.UserConfig',
53 | )
54 |
55 | INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
56 |
57 | MIDDLEWARE = [
58 | 'corsheaders.middleware.CorsMiddleware',
59 | 'django.middleware.security.SecurityMiddleware',
60 | 'django.contrib.sessions.middleware.SessionMiddleware',
61 | 'django.middleware.common.CommonMiddleware',
62 | 'django.middleware.csrf.CsrfViewMiddleware',
63 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
64 | 'django.contrib.messages.middleware.MessageMiddleware',
65 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
66 | ]
67 |
68 | CORS_ORIGIN_ALLOW_ALL = True
69 |
70 | ROOT_URLCONF = 'SmartClassroom.urls'
71 |
72 | TEMPLATES = [
73 | {
74 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
75 | 'DIRS': [],
76 | 'APP_DIRS': True,
77 | 'OPTIONS': {
78 | 'context_processors': [
79 | 'django.template.context_processors.debug',
80 | 'django.template.context_processors.request',
81 | 'django.contrib.auth.context_processors.auth',
82 | 'django.contrib.messages.context_processors.messages',
83 | ],
84 | },
85 | },
86 | ]
87 |
88 | WSGI_APPLICATION = 'SmartClassroom.wsgi.application'
89 |
90 |
91 | # Database
92 | # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
93 |
94 | DATABASES = {
95 | 'default': {
96 | 'ENGINE': 'django.db.backends.sqlite3',
97 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
98 | }
99 | }
100 |
101 |
102 | # Password validation
103 | # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
104 |
105 | AUTH_PASSWORD_VALIDATORS = [
106 | {
107 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
108 | },
109 | {
110 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
111 | },
112 | {
113 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
114 | },
115 | {
116 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
117 | },
118 | ]
119 |
120 |
121 | # Internationalization
122 | # https://docs.djangoproject.com/en/1.11/topics/i18n/
123 |
124 | LANGUAGE_CODE = 'zh-Hans'
125 |
126 | TIME_ZONE = 'UTC'
127 |
128 | USE_I18N = True
129 |
130 | USE_L10N = True
131 |
132 | USE_TZ = True
133 |
134 |
135 | # Static files (CSS, JavaScript, Images)
136 | # https://docs.djangoproject.com/en/1.11/howto/static-files/
137 |
138 | STATIC_URL = '/static/'
139 |
140 | REST_FRAMEWORK = {
141 | # Use Django's standard `django.contrib.auth` permissions,
142 | # or allow read-only access for unauthenticated users.
143 | 'DEFAULT_PERMISSION_CLASSES': [
144 | 'rest_framework.permissions.AllowAny'
145 | ],
146 | 'TEST_REQUEST_DEFAULT_FORMAT': 'json',
147 | }
148 |
149 | # Channel settings
150 | CHANNEL_LAYERS = {
151 | "default": {
152 | "BACKEND": "asgiref.inmemory.ChannelLayer",
153 | "ROUTING": "SmartClassroom.routing.channel_routing",
154 | },
155 | }
156 |
--------------------------------------------------------------------------------
/SmartClassroom/settings.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/settings.pyc
--------------------------------------------------------------------------------
/SmartClassroom/urls.py:
--------------------------------------------------------------------------------
1 | """SmartClassroom URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/1.11/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. Import the include() function: from django.conf.urls import url, include
14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
15 | """
16 | from django.conf.urls import url, include
17 | from django.contrib import admin
18 | from message.views import MessageViewSet
19 | from student.views import StudentViewSet
20 | from detail.views import DetailViewSet
21 | from user.views import UserViewSet, LoginViewSet
22 | from rest_framework.routers import DefaultRouter
23 |
24 | router = DefaultRouter()
25 | router.register(r'message', MessageViewSet)
26 | router.register(r'student', StudentViewSet, base_name='student')
27 | router.register(r'detail', DetailViewSet, base_name='detail')
28 | router.register(r'user', UserViewSet, base_name='user')
29 | router.register(r'login', LoginViewSet, base_name='user')
30 |
31 | urlpatterns = [
32 | url(r'^', include(router.urls)),
33 | url(r'^admin/', admin.site.urls),
34 | url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
35 | ]
36 |
--------------------------------------------------------------------------------
/SmartClassroom/urls.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/urls.pyc
--------------------------------------------------------------------------------
/SmartClassroom/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for SmartClassroom 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.11/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", "SmartClassroom.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/SmartClassroom/wsgi.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/SmartClassroom/wsgi.pyc
--------------------------------------------------------------------------------
/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/db.sqlite3
--------------------------------------------------------------------------------
/detail/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__init__.py
--------------------------------------------------------------------------------
/detail/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__init__.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/admin.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/apps.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/apps.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/models.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/models.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/serializers.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/serializers.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/__pycache__/views.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/__pycache__/views.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Detail
4 |
5 |
6 | class DetailAdmin(admin.ModelAdmin):
7 | list_display = ('name', 'start', 'duration', 'end', 'ip')
8 | list_editable = ('ip',)
9 | list_filter = ('name',)
10 | empty_value_display = '暂无数据'
11 | list_per_page = 15
12 |
13 |
14 | admin.site.register(Detail, DetailAdmin)
15 |
--------------------------------------------------------------------------------
/detail/admin.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/admin.pyc
--------------------------------------------------------------------------------
/detail/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class DetailConfig(AppConfig):
5 | name = 'detail'
6 |
--------------------------------------------------------------------------------
/detail/apps.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/apps.pyc
--------------------------------------------------------------------------------
/detail/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 14:03
3 | from __future__ import unicode_literals
4 |
5 | from django.conf import settings
6 | from django.db import migrations, models
7 | import django.db.models.deletion
8 |
9 |
10 | class Migration(migrations.Migration):
11 |
12 | initial = True
13 |
14 | dependencies = [
15 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16 | ]
17 |
18 | operations = [
19 | migrations.CreateModel(
20 | name='Detail',
21 | fields=[
22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23 | ('start', models.IntegerField()),
24 | ('duration', models.IntegerField()),
25 | ('end', models.IntegerField()),
26 | ('ip', models.GenericIPAddressField()),
27 | ('name', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
28 | ],
29 | ),
30 | ]
31 |
--------------------------------------------------------------------------------
/detail/migrations/0001_initial.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/0001_initial.pyc
--------------------------------------------------------------------------------
/detail/migrations/0002_detail_date.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-26 07:17
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('detail', '0001_initial'),
12 | ]
13 |
14 | operations = [
15 | migrations.AddField(
16 | model_name='detail',
17 | name='date',
18 | field=models.CharField(blank=True, max_length=16, null=True),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/detail/migrations/0002_detail_date.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/0002_detail_date.pyc
--------------------------------------------------------------------------------
/detail/migrations/0003_auto_20170607_1235.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-06-07 12:35
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('detail', '0002_detail_date'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='detail',
17 | name='duration',
18 | field=models.IntegerField(blank=True, null=True),
19 | ),
20 | migrations.AlterField(
21 | model_name='detail',
22 | name='end',
23 | field=models.IntegerField(blank=True, null=True),
24 | ),
25 | ]
26 |
--------------------------------------------------------------------------------
/detail/migrations/0004_auto_20170607_1320.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-06-07 13:20
3 | from __future__ import unicode_literals
4 |
5 | from django.conf import settings
6 | from django.db import migrations, models
7 | import django.db.models.deletion
8 |
9 |
10 | class Migration(migrations.Migration):
11 |
12 | dependencies = [
13 | ('detail', '0003_auto_20170607_1235'),
14 | ]
15 |
16 | operations = [
17 | migrations.AlterField(
18 | model_name='detail',
19 | name='name',
20 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='detail', to=settings.AUTH_USER_MODEL),
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/detail/migrations/0005_auto_20170607_1402.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-06-07 14:02
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('detail', '0004_auto_20170607_1320'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='detail',
17 | name='name',
18 | field=models.CharField(blank=True, max_length=16, null=True),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/detail/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__init__.py
--------------------------------------------------------------------------------
/detail/migrations/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__init__.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/0001_initial.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/0001_initial.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/0002_detail_date.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/0002_detail_date.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/0003_auto_20170607_1235.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/0003_auto_20170607_1235.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/0004_auto_20170607_1320.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/0004_auto_20170607_1320.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/0005_auto_20170607_1402.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/0005_auto_20170607_1402.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/migrations/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/migrations/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/detail/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import User
3 |
4 |
5 | class Detail(models.Model):
6 | name = models.CharField('姓名', max_length=16, null=True, blank=True)
7 | start = models.IntegerField('签到时间')
8 | duration = models.IntegerField('在线时长', blank=True, null=True)
9 | end = models.IntegerField('签退时间', blank=True, null=True)
10 | ip = models.GenericIPAddressField('登录IP')
11 | date = models.CharField('登录日期', max_length=16, null=True, blank=True)
12 |
13 | def __str__(self):
14 | return self.name
--------------------------------------------------------------------------------
/detail/models.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/models.pyc
--------------------------------------------------------------------------------
/detail/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from .models import Detail
3 | from django.contrib.auth.models import User
4 |
5 |
6 | class DetailSerializer(serializers.ModelSerializer):
7 | class Meta:
8 | model = Detail
9 | fields = '__all__'
10 |
--------------------------------------------------------------------------------
/detail/serializers.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/serializers.pyc
--------------------------------------------------------------------------------
/detail/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/detail/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework import viewsets
2 | from rest_framework.response import Response
3 | from .models import Detail
4 | from .serializers import DetailSerializer
5 |
6 |
7 | class DetailViewSet(viewsets.ModelViewSet):
8 | serializer_class = DetailSerializer
9 |
10 | def get_queryset(self):
11 | queryset = Detail.objects.all().order_by('-id')
12 | name = self.request.query_params.get('name')
13 | date = self.request.query_params.get('date')
14 |
15 | if name:
16 | queryset = queryset.filter(name__contains=name)
17 | elif date:
18 | queryset = queryset.filter(date=date)
19 | return queryset
20 |
--------------------------------------------------------------------------------
/detail/views.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/detail/views.pyc
--------------------------------------------------------------------------------
/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", "SmartClassroom.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError:
10 | # The above import may fail for some other reason. Ensure that the
11 | # issue is really that Django is missing to avoid masking other
12 | # exceptions on Python 2.
13 | try:
14 | import django
15 | except ImportError:
16 | raise ImportError(
17 | "Couldn't import Django. Are you sure it's installed and "
18 | "available on your PYTHONPATH environment variable? Did you "
19 | "forget to activate a virtual environment?"
20 | )
21 | raise
22 | execute_from_command_line(sys.argv)
23 |
--------------------------------------------------------------------------------
/message/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__init__.py
--------------------------------------------------------------------------------
/message/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__init__.pyc
--------------------------------------------------------------------------------
/message/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/message/__pycache__/admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/admin.cpython-36.pyc
--------------------------------------------------------------------------------
/message/__pycache__/apps.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/apps.cpython-36.pyc
--------------------------------------------------------------------------------
/message/__pycache__/models.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/models.cpython-36.pyc
--------------------------------------------------------------------------------
/message/__pycache__/serializers.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/serializers.cpython-36.pyc
--------------------------------------------------------------------------------
/message/__pycache__/views.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/__pycache__/views.cpython-36.pyc
--------------------------------------------------------------------------------
/message/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Message
3 |
4 |
5 | class MessageAdmin(admin.ModelAdmin):
6 | list_display = ('owner', 'content')
7 | list_filter = ('owner',)
8 | list_per_page = 15
9 |
10 | admin.site.register(Message, MessageAdmin)
11 |
--------------------------------------------------------------------------------
/message/admin.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/admin.pyc
--------------------------------------------------------------------------------
/message/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class MessageConfig(AppConfig):
5 | name = 'message'
6 |
--------------------------------------------------------------------------------
/message/apps.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/apps.pyc
--------------------------------------------------------------------------------
/message/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-06-17 11:55
3 | from __future__ import unicode_literals
4 |
5 | from django.conf import settings
6 | from django.db import migrations, models
7 | import django.db.models.deletion
8 |
9 |
10 | class Migration(migrations.Migration):
11 |
12 | initial = True
13 |
14 | dependencies = [
15 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16 | ]
17 |
18 | operations = [
19 | migrations.CreateModel(
20 | name='Message',
21 | fields=[
22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23 | ('content', models.TextField(verbose_name='信息内容')),
24 | ('time', models.IntegerField(verbose_name='发布时间')),
25 | ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='message', to=settings.AUTH_USER_MODEL)),
26 | ],
27 | ),
28 | ]
29 |
--------------------------------------------------------------------------------
/message/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/migrations/__init__.py
--------------------------------------------------------------------------------
/message/migrations/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/migrations/__init__.pyc
--------------------------------------------------------------------------------
/message/migrations/__pycache__/0001_initial.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/migrations/__pycache__/0001_initial.cpython-36.pyc
--------------------------------------------------------------------------------
/message/migrations/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/migrations/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/message/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import User
3 |
4 |
5 | class Message(models.Model):
6 | owner = models.ForeignKey(User, related_name='message')
7 | content = models.TextField('信息内容')
8 | time = models.IntegerField('发布时间')
9 |
10 | def __str__(self):
11 | return self.content
--------------------------------------------------------------------------------
/message/models.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/models.pyc
--------------------------------------------------------------------------------
/message/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from django.contrib.auth.models import User
3 | from .models import Message
4 |
5 |
6 | class OwnerSerializer(serializers.ModelSerializer):
7 |
8 | class Meta:
9 | model = User
10 | fields = ('id', 'username')
11 |
12 |
13 | class MessageSerializer(serializers.ModelSerializer):
14 | owner = OwnerSerializer()
15 |
16 | class Meta:
17 | model = Message
18 | fields = '__all__'
19 |
20 | def create(self, validated_data):
21 | print(self.context['request'].content)
22 | validated_data['owner_id'] = self.context['request'].owner
23 | return Message.objects.create(**validated_data)
--------------------------------------------------------------------------------
/message/serializers.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/serializers.pyc
--------------------------------------------------------------------------------
/message/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/message/views.py:
--------------------------------------------------------------------------------
1 | from .models import Message
2 | from .serializers import MessageSerializer
3 | from rest_framework import viewsets
4 | from rest_framework.response import Response
5 |
6 |
7 | class MessageViewSet(viewsets.ModelViewSet):
8 | queryset = Message.objects.all().order_by('-id')
9 | serializer_class = MessageSerializer
10 |
--------------------------------------------------------------------------------
/message/views.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/message/views.pyc
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | asgiref==1.1.2
2 | attrs==17.2.0
3 | autobahn==17.5.1
4 | Automat==0.6.0
5 | channels==1.1.3
6 | constantly==15.1.0
7 | daphne==1.2.0
8 | Django==1.11.1
9 | django-cors-headers==2.0.2
10 | djangorestframework==3.6.3
11 | incremental==17.5.0
12 | pytz==2017.2
13 | six==1.10.0
14 | Twisted==17.1.0
15 | txaio==2.7.1
16 | zope.interface==4.4.1
17 |
--------------------------------------------------------------------------------
/student/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__init__.py
--------------------------------------------------------------------------------
/student/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__init__.pyc
--------------------------------------------------------------------------------
/student/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/student/__pycache__/admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/admin.cpython-36.pyc
--------------------------------------------------------------------------------
/student/__pycache__/apps.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/apps.cpython-36.pyc
--------------------------------------------------------------------------------
/student/__pycache__/models.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/models.cpython-36.pyc
--------------------------------------------------------------------------------
/student/__pycache__/serializers.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/serializers.cpython-36.pyc
--------------------------------------------------------------------------------
/student/__pycache__/views.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/__pycache__/views.cpython-36.pyc
--------------------------------------------------------------------------------
/student/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Classroom, Duty, Student
3 |
4 |
5 | class ClassroomAdmin(admin.ModelAdmin):
6 | list_display = ('name', 'description')
7 | list_editable = ('description',)
8 | list_filter = ('name', )
9 |
10 |
11 | class DutyAdmin(admin.ModelAdmin):
12 | list_display = ('name', 'description')
13 | list_editable = ('description',)
14 |
15 |
16 | class StudentAdmin(admin.ModelAdmin):
17 | list_display = ('studentID', 'name', 'phone', 'email', 'classroom', 'status', 'duty')
18 | list_editable = ('status',)
19 | empty_value_display = '学生'
20 |
21 |
22 | admin.site.register(Classroom, ClassroomAdmin)
23 | admin.site.register(Duty, DutyAdmin)
24 | admin.site.register(Student, StudentAdmin)
25 |
--------------------------------------------------------------------------------
/student/admin.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/admin.pyc
--------------------------------------------------------------------------------
/student/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class StudentConfig(AppConfig):
5 | name = 'student'
6 |
--------------------------------------------------------------------------------
/student/apps.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/apps.pyc
--------------------------------------------------------------------------------
/student/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-24 10:28
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 | import django.db.models.deletion
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | initial = True
12 |
13 | dependencies = [
14 | ]
15 |
16 | operations = [
17 | migrations.CreateModel(
18 | name='Classroom',
19 | fields=[
20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21 | ('name', models.CharField(max_length=16)),
22 | ('description', models.CharField(max_length=32)),
23 | ],
24 | ),
25 | migrations.CreateModel(
26 | name='Duty',
27 | fields=[
28 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
29 | ('name', models.CharField(max_length=16)),
30 | ('description', models.CharField(max_length=32)),
31 | ],
32 | ),
33 | migrations.CreateModel(
34 | name='Status',
35 | fields=[
36 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
37 | ('name', models.CharField(max_length=16)),
38 | ('description', models.CharField(max_length=32)),
39 | ],
40 | ),
41 | migrations.CreateModel(
42 | name='Student',
43 | fields=[
44 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
45 | ('studentID', models.IntegerField()),
46 | ('name', models.CharField(max_length=256)),
47 | ('phone', models.IntegerField(blank=True, null=True)),
48 | ('email', models.EmailField(blank=True, max_length=254, null=True)),
49 | ('times', models.IntegerField(default=1)),
50 | ('classroom', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='student.Classroom')),
51 | ('duty', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='student.Duty')),
52 | ('status', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='student.Status')),
53 | ],
54 | ),
55 | ]
56 |
--------------------------------------------------------------------------------
/student/migrations/0001_initial.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0001_initial.pyc
--------------------------------------------------------------------------------
/student/migrations/0002_auto_20170525_0213.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 02:13
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0001_initial'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='status',
17 | name='name',
18 | field=models.BooleanField(),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/student/migrations/0002_auto_20170525_0213.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0002_auto_20170525_0213.pyc
--------------------------------------------------------------------------------
/student/migrations/0003_remove_status_name.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 02:14
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0002_auto_20170525_0213'),
12 | ]
13 |
14 | operations = [
15 | migrations.RemoveField(
16 | model_name='status',
17 | name='name',
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/student/migrations/0003_remove_status_name.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0003_remove_status_name.pyc
--------------------------------------------------------------------------------
/student/migrations/0004_status_name.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 02:26
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0003_remove_status_name'),
12 | ]
13 |
14 | operations = [
15 | migrations.AddField(
16 | model_name='status',
17 | name='name',
18 | field=models.BooleanField(default=False),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/student/migrations/0004_status_name.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0004_status_name.pyc
--------------------------------------------------------------------------------
/student/migrations/0005_auto_20170525_0234.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 02:34
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0004_status_name'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='status',
17 | name='name',
18 | field=models.CharField(max_length=16),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/student/migrations/0005_auto_20170525_0234.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0005_auto_20170525_0234.pyc
--------------------------------------------------------------------------------
/student/migrations/0006_auto_20170525_1419.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 14:19
3 | from __future__ import unicode_literals
4 |
5 | from django.conf import settings
6 | from django.db import migrations, models
7 | import django.db.models.deletion
8 |
9 |
10 | class Migration(migrations.Migration):
11 |
12 | dependencies = [
13 | ('student', '0005_auto_20170525_0234'),
14 | ]
15 |
16 | operations = [
17 | migrations.AlterField(
18 | model_name='student',
19 | name='name',
20 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/student/migrations/0006_auto_20170525_1419.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0006_auto_20170525_1419.pyc
--------------------------------------------------------------------------------
/student/migrations/0007_auto_20170525_1429.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-25 14:29
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 | import django.db.models.deletion
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | dependencies = [
12 | ('student', '0006_auto_20170525_1419'),
13 | ]
14 |
15 | operations = [
16 | migrations.AlterField(
17 | model_name='student',
18 | name='duty',
19 | field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='student.Duty'),
20 | ),
21 | ]
22 |
--------------------------------------------------------------------------------
/student/migrations/0007_auto_20170525_1429.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0007_auto_20170525_1429.pyc
--------------------------------------------------------------------------------
/student/migrations/0008_remove_student_times.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-26 06:45
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0007_auto_20170525_1429'),
12 | ]
13 |
14 | operations = [
15 | migrations.RemoveField(
16 | model_name='student',
17 | name='times',
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/student/migrations/0008_remove_student_times.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/0008_remove_student_times.pyc
--------------------------------------------------------------------------------
/student/migrations/0009_auto_20170527_0726.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # Generated by Django 1.11.1 on 2017-05-27 07:26
3 | from __future__ import unicode_literals
4 |
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('student', '0008_remove_student_times'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='student',
17 | name='status',
18 | field=models.IntegerField(),
19 | ),
20 | migrations.DeleteModel(
21 | name='Status',
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/student/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__init__.py
--------------------------------------------------------------------------------
/student/migrations/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__init__.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0001_initial.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0001_initial.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0002_auto_20170525_0213.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0002_auto_20170525_0213.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0003_remove_status_name.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0003_remove_status_name.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0004_status_name.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0004_status_name.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0005_auto_20170525_0234.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0005_auto_20170525_0234.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0006_auto_20170525_1419.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0006_auto_20170525_1419.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0007_auto_20170525_1429.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0007_auto_20170525_1429.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0008_remove_student_times.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0008_remove_student_times.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/0009_auto_20170527_0726.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/0009_auto_20170527_0726.cpython-36.pyc
--------------------------------------------------------------------------------
/student/migrations/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/migrations/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/student/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import User
3 |
4 |
5 | class Classroom(models.Model):
6 | name = models.CharField('班级名称', max_length=16)
7 | description = models.CharField('班级描述', max_length=32, blank=True)
8 |
9 | def __str__(self):
10 | return self.name
11 |
12 |
13 | class Duty(models.Model):
14 | name = models.CharField('职务名称', max_length=16)
15 | description = models.CharField('职务描述', max_length=32, blank=True)
16 |
17 | def __str__(self):
18 | return self.name
19 |
20 |
21 | class Student(models.Model):
22 | STATUS_CHOOSE = (
23 | (0, '离线'),
24 | (1, '在线'),
25 | )
26 | studentID = models.IntegerField('学号')
27 | name = models.ForeignKey(User)
28 | phone = models.IntegerField('电话号码', null=True, blank=True)
29 | email = models.EmailField('邮箱地址', null=True, blank=True)
30 | classroom = models.ForeignKey(Classroom)
31 | status = models.IntegerField('状态', choices=STATUS_CHOOSE)
32 | duty = models.ForeignKey(Duty, null=True, blank=True)
33 |
34 | def __str__(self):
35 | return self.name.username
36 |
--------------------------------------------------------------------------------
/student/models.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/models.pyc
--------------------------------------------------------------------------------
/student/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from django.db import models
3 | from .models import Student, Classroom
4 | from django.contrib.auth.models import User
5 |
6 |
7 | class ClassroomSerializer(serializers.ModelSerializer):
8 |
9 | class Meta:
10 | model = Classroom
11 | fields = ('name',)
12 |
13 |
14 | class UserSerializer(serializers.ModelSerializer):
15 | class Meta:
16 | model = User
17 | fields = ('username',)
18 |
19 |
20 | class StudentSerializer(serializers.ModelSerializer):
21 | name = serializers.StringRelatedField()
22 | classroom = serializers.StringRelatedField()
23 | duty = serializers.StringRelatedField()
24 |
25 | class Meta:
26 | model = Student
27 | fields = '__all__'
28 |
--------------------------------------------------------------------------------
/student/serializers.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/serializers.pyc
--------------------------------------------------------------------------------
/student/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/student/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework import viewsets
2 | from rest_framework.response import Response
3 | from .models import Student
4 | from .serializers import StudentSerializer
5 |
6 |
7 | class StudentViewSet(viewsets.ModelViewSet):
8 | queryset = Student.objects.all().order_by('-id')
9 | serializer_class = StudentSerializer
10 |
--------------------------------------------------------------------------------
/student/views.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/student/views.pyc
--------------------------------------------------------------------------------
/user/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__init__.py
--------------------------------------------------------------------------------
/user/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__init__.pyc
--------------------------------------------------------------------------------
/user/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/user/__pycache__/admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/admin.cpython-36.pyc
--------------------------------------------------------------------------------
/user/__pycache__/apps.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/apps.cpython-36.pyc
--------------------------------------------------------------------------------
/user/__pycache__/models.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/models.cpython-36.pyc
--------------------------------------------------------------------------------
/user/__pycache__/serializers.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/serializers.cpython-36.pyc
--------------------------------------------------------------------------------
/user/__pycache__/views.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/__pycache__/views.cpython-36.pyc
--------------------------------------------------------------------------------
/user/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.contrib.auth.models import Group
3 |
4 | admin.site.unregister(Group)
--------------------------------------------------------------------------------
/user/admin.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/admin.pyc
--------------------------------------------------------------------------------
/user/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class UserConfig(AppConfig):
5 | name = 'user'
6 |
--------------------------------------------------------------------------------
/user/apps.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/apps.pyc
--------------------------------------------------------------------------------
/user/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/migrations/__init__.py
--------------------------------------------------------------------------------
/user/migrations/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/migrations/__init__.pyc
--------------------------------------------------------------------------------
/user/migrations/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/migrations/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/user/models.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/models.py
--------------------------------------------------------------------------------
/user/models.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/models.pyc
--------------------------------------------------------------------------------
/user/serializers.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.models import User
2 | from django.contrib.auth import authenticate, login
3 | from rest_framework import serializers
4 |
5 |
6 | class UserSerializer(serializers.ModelSerializer):
7 |
8 | class Meta:
9 | model = User
10 | fields = ('id', 'username', 'email', 'password')
11 | extra_kwargs = {'password': {'write_only': True}}
12 |
13 | def create(self, validated_data):
14 | user = User(
15 | email=validated_data['email'],
16 | username=validated_data['username']
17 | )
18 | user.set_password(validated_data['password'])
19 | user.save()
20 | return user
21 |
22 |
23 | class LoginSerializer(serializers.ModelSerializer):
24 |
25 | class Meta:
26 | model = User
27 | fields = ('username', 'password')
28 | extra_kwargs = {'password': {'write_only': True}}
29 |
30 | def login(self, validated_data):
31 | print('validated_data', validated_data)
32 | username = validated_data['username']
33 | passwrod = validated_data['password']
34 |
35 | user = authenticate(username=username, passwrod=passwrod)
36 | if user is not None:
37 | print(user)
38 | return user
39 | else:
40 | print('Error')
41 |
--------------------------------------------------------------------------------
/user/serializers.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/serializers.pyc
--------------------------------------------------------------------------------
/user/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/user/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework import viewsets
2 | from django.contrib.auth.models import User
3 | from .serializers import UserSerializer, LoginSerializer
4 |
5 |
6 | class UserViewSet(viewsets.ModelViewSet):
7 | queryset = User.objects.all()
8 | serializer_class = UserSerializer
9 |
10 |
11 | class LoginViewSet(viewsets.ModelViewSet):
12 | queryset = User.objects.all()
13 | serializer_class = LoginSerializer
14 |
--------------------------------------------------------------------------------
/user/views.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandsomeHan515/SmartClassroom-Python/8275af2181fc899c60014b7d0c65665ce7e1d6b5/user/views.pyc
--------------------------------------------------------------------------------