Flare-k

Add oauth

Showing 1000 changed files with 1416 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +# DropBox Project using AWS, Khuloud
2 +
3 +### 경희대학교 Cloud Computing A조
4 +
5 +## 팀원
6 +
7 +- 2017110267 강연욱
8 +
9 +- 2017103972 김성연
10 +
11 +- 2017100907 유정수
12 +
13 +- 2017104025 정수연
14 +
15 +- 2016104173 최재혁
16 +
17 +## 기술 Stack
18 +1. Frontend: nuxt, vuetify
19 +2. Backend : Django
20 +3. Database: DynamoDB
21 +4. A W S : EC2, S3
22 +
23 +## 향후 일정
...\ No newline at end of file ...\ No newline at end of file
1 +# This file must be used with "source bin/activate" *from bash*
2 +# you cannot run it directly
3 +
4 +deactivate () {
5 + # reset old environment variables
6 + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7 + PATH="${_OLD_VIRTUAL_PATH:-}"
8 + export PATH
9 + unset _OLD_VIRTUAL_PATH
10 + fi
11 + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12 + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13 + export PYTHONHOME
14 + unset _OLD_VIRTUAL_PYTHONHOME
15 + fi
16 +
17 + # This should detect bash and zsh, which have a hash command that must
18 + # be called to get it to forget past commands. Without forgetting
19 + # past commands the $PATH changes we made may not be respected
20 + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21 + hash -r
22 + fi
23 +
24 + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25 + PS1="${_OLD_VIRTUAL_PS1:-}"
26 + export PS1
27 + unset _OLD_VIRTUAL_PS1
28 + fi
29 +
30 + unset VIRTUAL_ENV
31 + if [ ! "${1:-}" = "nondestructive" ] ; then
32 + # Self destruct!
33 + unset -f deactivate
34 + fi
35 +}
36 +
37 +# unset irrelevant variables
38 +deactivate nondestructive
39 +
40 +VIRTUAL_ENV="/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env"
41 +export VIRTUAL_ENV
42 +
43 +_OLD_VIRTUAL_PATH="$PATH"
44 +PATH="$VIRTUAL_ENV/bin:$PATH"
45 +export PATH
46 +
47 +# unset PYTHONHOME if set
48 +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
49 +# could use `if (set -u; : $PYTHONHOME) ;` in bash
50 +if [ -n "${PYTHONHOME:-}" ] ; then
51 + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
52 + unset PYTHONHOME
53 +fi
54 +
55 +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
56 + _OLD_VIRTUAL_PS1="${PS1:-}"
57 + if [ "x(env) " != x ] ; then
58 + PS1="(env) ${PS1:-}"
59 + else
60 + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
61 + # special case for Aspen magic directories
62 + # see http://www.zetadev.com/software/aspen/
63 + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
64 + else
65 + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
66 + fi
67 + fi
68 + export PS1
69 +fi
70 +
71 +# This should detect bash and zsh, which have a hash command that must
72 +# be called to get it to forget past commands. Without forgetting
73 +# past commands the $PATH changes we made may not be respected
74 +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
75 + hash -r
76 +fi
1 +# This file must be used with "source bin/activate.csh" *from csh*.
2 +# You cannot run it directly.
3 +# Created by Davide Di Blasi <davidedb@gmail.com>.
4 +# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
5 +
6 +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
7 +
8 +# Unset irrelevant variables.
9 +deactivate nondestructive
10 +
11 +setenv VIRTUAL_ENV "/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env"
12 +
13 +set _OLD_VIRTUAL_PATH="$PATH"
14 +setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15 +
16 +
17 +set _OLD_VIRTUAL_PROMPT="$prompt"
18 +
19 +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20 + if ("env" != "") then
21 + set env_name = "env"
22 + else
23 + if (`basename "VIRTUAL_ENV"` == "__") then
24 + # special case for Aspen magic directories
25 + # see http://www.zetadev.com/software/aspen/
26 + set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
27 + else
28 + set env_name = `basename "$VIRTUAL_ENV"`
29 + endif
30 + endif
31 + set prompt = "[$env_name] $prompt"
32 + unset env_name
33 +endif
34 +
35 +alias pydoc python -m pydoc
36 +
37 +rehash
1 +# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
2 +# you cannot run it directly
3 +
4 +function deactivate -d "Exit virtualenv and return to normal shell environment"
5 + # reset old environment variables
6 + if test -n "$_OLD_VIRTUAL_PATH"
7 + set -gx PATH $_OLD_VIRTUAL_PATH
8 + set -e _OLD_VIRTUAL_PATH
9 + end
10 + if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11 + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12 + set -e _OLD_VIRTUAL_PYTHONHOME
13 + end
14 +
15 + if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16 + functions -e fish_prompt
17 + set -e _OLD_FISH_PROMPT_OVERRIDE
18 + functions -c _old_fish_prompt fish_prompt
19 + functions -e _old_fish_prompt
20 + end
21 +
22 + set -e VIRTUAL_ENV
23 + if test "$argv[1]" != "nondestructive"
24 + # Self destruct!
25 + functions -e deactivate
26 + end
27 +end
28 +
29 +# unset irrelevant variables
30 +deactivate nondestructive
31 +
32 +set -gx VIRTUAL_ENV "/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env"
33 +
34 +set -gx _OLD_VIRTUAL_PATH $PATH
35 +set -gx PATH "$VIRTUAL_ENV/bin" $PATH
36 +
37 +# unset PYTHONHOME if set
38 +if set -q PYTHONHOME
39 + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
40 + set -e PYTHONHOME
41 +end
42 +
43 +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
44 + # fish uses a function instead of an env var to generate the prompt.
45 +
46 + # save the current fish_prompt function as the function _old_fish_prompt
47 + functions -c fish_prompt _old_fish_prompt
48 +
49 + # with the original prompt function renamed, we can override with our own.
50 + function fish_prompt
51 + # Save the return status of the last command
52 + set -l old_status $status
53 +
54 + # Prompt override?
55 + if test -n "(env) "
56 + printf "%s%s" "(env) " (set_color normal)
57 + else
58 + # ...Otherwise, prepend env
59 + set -l _checkbase (basename "$VIRTUAL_ENV")
60 + if test $_checkbase = "__"
61 + # special case for Aspen magic directories
62 + # see http://www.zetadev.com/software/aspen/
63 + printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
64 + else
65 + printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
66 + end
67 + end
68 +
69 + # Restore the return status of the previous command.
70 + echo "exit $old_status" | .
71 + _old_fish_prompt
72 + end
73 +
74 + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
75 +end
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from chardet.cli.chardetect import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from django.core.management import execute_from_command_line
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(execute_from_command_line())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +from django.core import management
3 +
4 +if __name__ == "__main__":
5 + management.execute_from_command_line()
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from setuptools.command.easy_install import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from setuptools.command.easy_install import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +import sys
4 +import json
5 +import argparse
6 +from pprint import pformat
7 +
8 +import jmespath
9 +from jmespath import exceptions
10 +
11 +
12 +def main():
13 + parser = argparse.ArgumentParser()
14 + parser.add_argument('expression')
15 + parser.add_argument('-f', '--filename',
16 + help=('The filename containing the input data. '
17 + 'If a filename is not given then data is '
18 + 'read from stdin.'))
19 + parser.add_argument('--ast', action='store_true',
20 + help=('Pretty print the AST, do not search the data.'))
21 + args = parser.parse_args()
22 + expression = args.expression
23 + if args.ast:
24 + # Only print the AST
25 + expression = jmespath.compile(args.expression)
26 + sys.stdout.write(pformat(expression.parsed))
27 + sys.stdout.write('\n')
28 + return 0
29 + if args.filename:
30 + with open(args.filename, 'r') as f:
31 + data = json.load(f)
32 + else:
33 + data = sys.stdin.read()
34 + data = json.loads(data)
35 + try:
36 + sys.stdout.write(json.dumps(
37 + jmespath.search(expression, data), indent=4, ensure_ascii=False))
38 + sys.stdout.write('\n')
39 + except exceptions.ArityError as e:
40 + sys.stderr.write("invalid-arity: %s\n" % e)
41 + return 1
42 + except exceptions.JMESPathTypeError as e:
43 + sys.stderr.write("invalid-type: %s\n" % e)
44 + return 1
45 + except exceptions.UnknownFunctionError as e:
46 + sys.stderr.write("unknown-function: %s\n" % e)
47 + return 1
48 + except exceptions.ParseError as e:
49 + sys.stderr.write("syntax-error: %s\n" % e)
50 + return 1
51 +
52 +
53 +if __name__ == '__main__':
54 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from pip._internal import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from pip._internal import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from pip._internal import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +python3
...\ No newline at end of file ...\ No newline at end of file
1 +/Users/noblyan/opt/anaconda3/bin/python3
...\ No newline at end of file ...\ No newline at end of file
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing HTML.
9 +"""
10 +
11 +try:
12 + import locale
13 + locale.setlocale(locale.LC_ALL, '')
14 +except:
15 + pass
16 +
17 +from docutils.core import publish_cmdline, default_description
18 +
19 +
20 +description = ('Generates (X)HTML documents from standalone reStructuredText '
21 + 'sources. ' + default_description)
22 +
23 +publish_cmdline(writer_name='html', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2html4.py 7994 2016-12-10 17:41:45Z milde $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing (X)HTML.
9 +
10 +The output conforms to XHTML 1.0 transitional
11 +and almost to HTML 4.01 transitional (except for closing empty tags).
12 +"""
13 +
14 +try:
15 + import locale
16 + locale.setlocale(locale.LC_ALL, '')
17 +except:
18 + pass
19 +
20 +from docutils.core import publish_cmdline, default_description
21 +
22 +
23 +description = ('Generates (X)HTML documents from standalone reStructuredText '
24 + 'sources. ' + default_description)
25 +
26 +publish_cmdline(writer_name='html4', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf8 -*-
3 +# :Copyright: © 2015 Günter Milde.
4 +# :License: Released under the terms of the `2-Clause BSD license`_, in short:
5 +#
6 +# Copying and distribution of this file, with or without modification,
7 +# are permitted in any medium without royalty provided the copyright
8 +# notice and this notice are preserved.
9 +# This file is offered as-is, without any warranty.
10 +#
11 +# .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
12 +#
13 +# Revision: $Revision: 7847 $
14 +# Date: $Date: 2015-03-17 18:30:47 +0100 (Di, 17. Mär 2015) $
15 +
16 +"""
17 +A minimal front end to the Docutils Publisher, producing HTML 5 documents.
18 +
19 +The output also conforms to XHTML 1.0 transitional
20 +(except for the doctype declaration).
21 +"""
22 +
23 +try:
24 + import locale # module missing in Jython
25 + locale.setlocale(locale.LC_ALL, '')
26 +except locale.Error:
27 + pass
28 +
29 +from docutils.core import publish_cmdline, default_description
30 +
31 +description = (u'Generates HTML 5 documents from standalone '
32 + u'reStructuredText sources '
33 + + default_description)
34 +
35 +publish_cmdline(writer_name='html5', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2latex.py 5905 2009-04-16 12:04:49Z milde $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing LaTeX.
9 +"""
10 +
11 +try:
12 + import locale
13 + locale.setlocale(locale.LC_ALL, '')
14 +except:
15 + pass
16 +
17 +from docutils.core import publish_cmdline
18 +
19 +description = ('Generates LaTeX documents from standalone reStructuredText '
20 + 'sources. '
21 + 'Reads from <source> (default is stdin) and writes to '
22 + '<destination> (default is stdout). See '
23 + '<http://docutils.sourceforge.net/docs/user/latex.html> for '
24 + 'the full reference.')
25 +
26 +publish_cmdline(writer_name='latex', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# Author:
4 +# Contact: grubert@users.sf.net
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +man.py
9 +======
10 +
11 +This module provides a simple command line interface that uses the
12 +man page writer to output from ReStructuredText source.
13 +"""
14 +
15 +import locale
16 +try:
17 + locale.setlocale(locale.LC_ALL, '')
18 +except:
19 + pass
20 +
21 +from docutils.core import publish_cmdline, default_description
22 +from docutils.writers import manpage
23 +
24 +description = ("Generates plain unix manual documents. " + default_description)
25 +
26 +publish_cmdline(writer=manpage.Writer(), description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2odt.py 5839 2009-01-07 19:09:28Z dkuhlman $
4 +# Author: Dave Kuhlman <dkuhlman@rexx.com>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A front end to the Docutils Publisher, producing OpenOffice documents.
9 +"""
10 +
11 +import sys
12 +try:
13 + import locale
14 + locale.setlocale(locale.LC_ALL, '')
15 +except:
16 + pass
17 +
18 +from docutils.core import publish_cmdline_to_binary, default_description
19 +from docutils.writers.odf_odt import Writer, Reader
20 +
21 +
22 +description = ('Generates OpenDocument/OpenOffice/ODF documents from '
23 + 'standalone reStructuredText sources. ' + default_description)
24 +
25 +
26 +writer = Writer()
27 +reader = Reader()
28 +output = publish_cmdline_to_binary(reader=reader, writer=writer,
29 + description=description)
30 +
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2odt_prepstyles.py 5839 2009-01-07 19:09:28Z dkuhlman $
4 +# Author: Dave Kuhlman <dkuhlman@rexx.com>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +Fix a word-processor-generated styles.odt for odtwriter use: Drop page size
9 +specifications from styles.xml in STYLE_FILE.odt.
10 +"""
11 +
12 +#
13 +# Author: Michael Schutte <michi@uiae.at>
14 +
15 +from lxml import etree
16 +import sys
17 +import zipfile
18 +from tempfile import mkstemp
19 +import shutil
20 +import os
21 +
22 +NAMESPACES = {
23 + "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
24 + "fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
25 +}
26 +
27 +def prepstyle(filename):
28 +
29 + zin = zipfile.ZipFile(filename)
30 + styles = zin.read("styles.xml")
31 +
32 + root = etree.fromstring(styles)
33 + for el in root.xpath("//style:page-layout-properties",
34 + namespaces=NAMESPACES):
35 + for attr in el.attrib:
36 + if attr.startswith("{%s}" % NAMESPACES["fo"]):
37 + del el.attrib[attr]
38 +
39 + tempname = mkstemp()
40 + zout = zipfile.ZipFile(os.fdopen(tempname[0], "w"), "w",
41 + zipfile.ZIP_DEFLATED)
42 +
43 + for item in zin.infolist():
44 + if item.filename == "styles.xml":
45 + zout.writestr(item, etree.tostring(root))
46 + else:
47 + zout.writestr(item, zin.read(item.filename))
48 +
49 + zout.close()
50 + zin.close()
51 + shutil.move(tempname[1], filename)
52 +
53 +
54 +def main():
55 + args = sys.argv[1:]
56 + if len(args) != 1:
57 + print >> sys.stderr, __doc__
58 + print >> sys.stderr, "Usage: %s STYLE_FILE.odt\n" % sys.argv[0]
59 + sys.exit(1)
60 + filename = args[0]
61 + prepstyle(filename)
62 +
63 +if __name__ == '__main__':
64 + main()
65 +
66 +
67 +# vim:tw=78:sw=4:sts=4:et:
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2pseudoxml.py 4564 2006-05-21 20:44:42Z wiemann $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing pseudo-XML.
9 +"""
10 +
11 +try:
12 + import locale
13 + locale.setlocale(locale.LC_ALL, '')
14 +except:
15 + pass
16 +
17 +from docutils.core import publish_cmdline, default_description
18 +
19 +
20 +description = ('Generates pseudo-XML from standalone reStructuredText '
21 + 'sources (for testing purposes). ' + default_description)
22 +
23 +publish_cmdline(description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2s5.py 4564 2006-05-21 20:44:42Z wiemann $
4 +# Author: Chris Liechti <cliechti@gmx.net>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing HTML slides using
9 +the S5 template system.
10 +"""
11 +
12 +try:
13 + import locale
14 + locale.setlocale(locale.LC_ALL, '')
15 +except:
16 + pass
17 +
18 +from docutils.core import publish_cmdline, default_description
19 +
20 +
21 +description = ('Generates S5 (X)HTML slideshow documents from standalone '
22 + 'reStructuredText sources. ' + default_description)
23 +
24 +publish_cmdline(writer_name='s5', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2xetex.py 7847 2015-03-17 17:30:47Z milde $
4 +# Author: Guenter Milde
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing Lua/XeLaTeX code.
9 +"""
10 +
11 +try:
12 + import locale
13 + locale.setlocale(locale.LC_ALL, '')
14 +except:
15 + pass
16 +
17 +from docutils.core import publish_cmdline
18 +
19 +description = ('Generates LaTeX documents from standalone reStructuredText '
20 + 'sources for compilation with the Unicode-aware TeX variants '
21 + 'XeLaTeX or LuaLaTeX. '
22 + 'Reads from <source> (default is stdin) and writes to '
23 + '<destination> (default is stdout). See '
24 + '<http://docutils.sourceforge.net/docs/user/latex.html> for '
25 + 'the full reference.')
26 +
27 +publish_cmdline(writer_name='xetex', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rst2xml.py 4564 2006-05-21 20:44:42Z wiemann $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing Docutils XML.
9 +"""
10 +
11 +try:
12 + import locale
13 + locale.setlocale(locale.LC_ALL, '')
14 +except:
15 + pass
16 +
17 +from docutils.core import publish_cmdline, default_description
18 +
19 +
20 +description = ('Generates Docutils-native XML from standalone '
21 + 'reStructuredText sources. ' + default_description)
22 +
23 +publish_cmdline(writer_name='xml', description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +
3 +# $Id: rstpep2html.py 4564 2006-05-21 20:44:42Z wiemann $
4 +# Author: David Goodger <goodger@python.org>
5 +# Copyright: This module has been placed in the public domain.
6 +
7 +"""
8 +A minimal front end to the Docutils Publisher, producing HTML from PEP
9 +(Python Enhancement Proposal) documents.
10 +"""
11 +
12 +try:
13 + import locale
14 + locale.setlocale(locale.LC_ALL, '')
15 +except:
16 + pass
17 +
18 +from docutils.core import publish_cmdline, default_description
19 +
20 +
21 +description = ('Generates (X)HTML from reStructuredText-format PEP files. '
22 + + default_description)
23 +
24 +publish_cmdline(reader_name='pep', writer_name='pep_html',
25 + description=description)
1 +#!/Users/noblyan/Desktop/4_1/클라우드컴퓨팅/A_Team_Khuloud/A_Team_Khuloud/env/bin/python3
2 +# -*- coding: utf-8 -*-
3 +import re
4 +import sys
5 +
6 +from sqlparse.__main__ import main
7 +
8 +if __name__ == '__main__':
9 + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10 + sys.exit(main())
1 +Copyright (c) Django Software Foundation and individual contributors.
2 +All rights reserved.
3 +
4 +Redistribution and use in source and binary forms, with or without modification,
5 +are permitted provided that the following conditions are met:
6 +
7 + 1. Redistributions of source code must retain the above copyright notice,
8 + this list of conditions and the following disclaimer.
9 +
10 + 2. Redistributions in binary form must reproduce the above copyright
11 + notice, this list of conditions and the following disclaimer in the
12 + documentation and/or other materials provided with the distribution.
13 +
14 + 3. Neither the name of Django nor the names of its contributors may be used
15 + to endorse or promote products derived from this software without
16 + specific prior written permission.
17 +
18 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22 +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 +Metadata-Version: 2.1
2 +Name: Django
3 +Version: 3.0.6
4 +Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
5 +Home-page: https://www.djangoproject.com/
6 +Author: Django Software Foundation
7 +Author-email: foundation@djangoproject.com
8 +License: BSD
9 +Project-URL: Documentation, https://docs.djangoproject.com/
10 +Project-URL: Funding, https://www.djangoproject.com/fundraising/
11 +Project-URL: Source, https://github.com/django/django
12 +Project-URL: Tracker, https://code.djangoproject.com/
13 +Platform: UNKNOWN
14 +Classifier: Development Status :: 5 - Production/Stable
15 +Classifier: Environment :: Web Environment
16 +Classifier: Framework :: Django
17 +Classifier: Intended Audience :: Developers
18 +Classifier: License :: OSI Approved :: BSD License
19 +Classifier: Operating System :: OS Independent
20 +Classifier: Programming Language :: Python
21 +Classifier: Programming Language :: Python :: 3
22 +Classifier: Programming Language :: Python :: 3.6
23 +Classifier: Programming Language :: Python :: 3.7
24 +Classifier: Programming Language :: Python :: 3.8
25 +Classifier: Programming Language :: Python :: 3 :: Only
26 +Classifier: Topic :: Internet :: WWW/HTTP
27 +Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
28 +Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
29 +Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
30 +Classifier: Topic :: Software Development :: Libraries :: Python Modules
31 +Requires-Python: >=3.6
32 +Requires-Dist: pytz
33 +Requires-Dist: sqlparse (>=0.2.2)
34 +Requires-Dist: asgiref (~=3.2)
35 +Provides-Extra: argon2
36 +Requires-Dist: argon2-cffi (>=16.1.0) ; extra == 'argon2'
37 +Provides-Extra: bcrypt
38 +Requires-Dist: bcrypt ; extra == 'bcrypt'
39 +
40 +======
41 +Django
42 +======
43 +
44 +Django is a high-level Python Web framework that encourages rapid development
45 +and clean, pragmatic design. Thanks for checking it out.
46 +
47 +All documentation is in the "``docs``" directory and online at
48 +https://docs.djangoproject.com/en/stable/. If you're just getting started,
49 +here's how we recommend you read the docs:
50 +
51 +* First, read ``docs/intro/install.txt`` for instructions on installing Django.
52 +
53 +* Next, work through the tutorials in order (``docs/intro/tutorial01.txt``,
54 + ``docs/intro/tutorial02.txt``, etc.).
55 +
56 +* If you want to set up an actual deployment server, read
57 + ``docs/howto/deployment/index.txt`` for instructions.
58 +
59 +* You'll probably want to read through the topical guides (in ``docs/topics``)
60 + next; from there you can jump to the HOWTOs (in ``docs/howto``) for specific
61 + problems, and check out the reference (``docs/ref``) for gory details.
62 +
63 +* See ``docs/README`` for instructions on building an HTML version of the docs.
64 +
65 +Docs are updated rigorously. If you find any problems in the docs, or think
66 +they should be clarified in any way, please take 30 seconds to fill out a
67 +ticket here: https://code.djangoproject.com/newticket
68 +
69 +To get more help:
70 +
71 +* Join the ``#django`` channel on irc.freenode.net. Lots of helpful people hang
72 + out there. See https://en.wikipedia.org/wiki/Wikipedia:IRC/Tutorial if you're
73 + new to IRC.
74 +
75 +* Join the django-users mailing list, or read the archives, at
76 + https://groups.google.com/group/django-users.
77 +
78 +To contribute to Django:
79 +
80 +* Check out https://docs.djangoproject.com/en/dev/internals/contributing/ for
81 + information about getting involved.
82 +
83 +To run Django's test suite:
84 +
85 +* Follow the instructions in the "Unit tests" section of
86 + ``docs/internals/contributing/writing-code/unit-tests.txt``, published online at
87 + https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests
88 +
89 +
This diff could not be displayed because it is too large.
1 +Wheel-Version: 1.0
2 +Generator: bdist_wheel (0.33.1)
3 +Root-Is-Purelib: true
4 +Tag: py3-none-any
5 +
1 +[console_scripts]
2 +django-admin = django.core.management:execute_from_command_line
3 +
1 +r"""
2 + _ ___ __ __ .___________. __ __
3 + /\| |/\ / \ | | | | | || | | |
4 + \ ` ' / / ^ \ | | | | `---| |----`| |__| |
5 +|_ _| / /_\ \ | | | | | | | __ |
6 + / , . \ / _____ \ | `--' | | | | | | |
7 + \/|_|\//__/ \__\ \______/ |__| |__| |__|
8 +
9 +"""
10 +
11 +VERSION = (0, 41, 0, 'final', 0)
12 +
13 +__title__ = 'django-allauth'
14 +__version_info__ = VERSION
15 +__version__ = '.'.join(map(str, VERSION[:3])) + ('-{}{}'.format(
16 + VERSION[3], VERSION[4] or '') if VERSION[3] != 'final' else '')
17 +__author__ = 'Raymond Penners'
18 +__license__ = 'MIT'
19 +__copyright__ = 'Copyright 2010-2019 Raymond Penners and contributors'
1 +default_app_config = 'allauth.account.apps.AccountConfig'
1 +from django.contrib import admin
2 +
3 +from . import app_settings
4 +from .adapter import get_adapter
5 +from .models import EmailAddress, EmailConfirmation
6 +
7 +
8 +class EmailAddressAdmin(admin.ModelAdmin):
9 + list_display = ('email', 'user', 'primary', 'verified')
10 + list_filter = ('primary', 'verified')
11 + search_fields = []
12 + raw_id_fields = ('user',)
13 +
14 + def get_search_fields(self, request):
15 + base_fields = get_adapter(request).get_user_search_fields()
16 + return ['email'] + list(map(lambda a: 'user__' + a, base_fields))
17 +
18 +
19 +class EmailConfirmationAdmin(admin.ModelAdmin):
20 + list_display = ('email_address', 'created', 'sent', 'key')
21 + list_filter = ('sent',)
22 + raw_id_fields = ('email_address',)
23 +
24 +
25 +if not app_settings.EMAIL_CONFIRMATION_HMAC:
26 + admin.site.register(EmailConfirmation, EmailConfirmationAdmin)
27 +admin.site.register(EmailAddress, EmailAddressAdmin)
1 +from django.apps import AppConfig
2 +from django.utils.translation import gettext_lazy as _
3 +
4 +
5 +class AccountConfig(AppConfig):
6 + name = 'allauth.account'
7 + verbose_name = _('Accounts')
1 +from threading import local
2 +
3 +from django.contrib.auth.backends import ModelBackend
4 +
5 +from ..utils import get_user_model
6 +from . import app_settings
7 +from .app_settings import AuthenticationMethod
8 +from .utils import filter_users_by_email, filter_users_by_username
9 +
10 +
11 +_stash = local()
12 +
13 +
14 +class AuthenticationBackend(ModelBackend):
15 +
16 + def authenticate(self, request, **credentials):
17 + ret = None
18 + if app_settings.AUTHENTICATION_METHOD == AuthenticationMethod.EMAIL:
19 + ret = self._authenticate_by_email(**credentials)
20 + elif app_settings.AUTHENTICATION_METHOD \
21 + == AuthenticationMethod.USERNAME_EMAIL:
22 + ret = self._authenticate_by_email(**credentials)
23 + if not ret:
24 + ret = self._authenticate_by_username(**credentials)
25 + else:
26 + ret = self._authenticate_by_username(**credentials)
27 + return ret
28 +
29 + def _authenticate_by_username(self, **credentials):
30 + username_field = app_settings.USER_MODEL_USERNAME_FIELD
31 + username = credentials.get('username')
32 + password = credentials.get('password')
33 +
34 + User = get_user_model()
35 +
36 + if not username_field or username is None or password is None:
37 + return None
38 + try:
39 + # Username query is case insensitive
40 + user = filter_users_by_username(username).get()
41 + if self._check_password(user, password):
42 + return user
43 + except User.DoesNotExist:
44 + return None
45 +
46 + def _authenticate_by_email(self, **credentials):
47 + # Even though allauth will pass along `email`, other apps may
48 + # not respect this setting. For example, when using
49 + # django-tastypie basic authentication, the login is always
50 + # passed as `username`. So let's play nice with other apps
51 + # and use username as fallback
52 + email = credentials.get('email', credentials.get('username'))
53 + if email:
54 + for user in filter_users_by_email(email):
55 + if self._check_password(user, credentials["password"]):
56 + return user
57 + return None
58 +
59 + def _check_password(self, user, password):
60 + ret = user.check_password(password)
61 + if ret:
62 + ret = self.user_can_authenticate(user)
63 + if not ret:
64 + self._stash_user(user)
65 + return ret
66 +
67 + @classmethod
68 + def _stash_user(cls, user):
69 + """Now, be aware, the following is quite ugly, let me explain:
70 +
71 + Even if the user credentials match, the authentication can fail because
72 + Django's default ModelBackend calls user_can_authenticate(), which
73 + checks `is_active`. Now, earlier versions of allauth did not do this
74 + and simply returned the user as authenticated, even in case of
75 + `is_active=False`. For allauth scope, this does not pose a problem, as
76 + these users are properly redirected to an account inactive page.
77 +
78 + This does pose a problem when the allauth backend is used in a
79 + different context where allauth is not responsible for the login. Then,
80 + by not checking on `user_can_authenticate()` users will allow to become
81 + authenticated whereas according to Django logic this should not be
82 + allowed.
83 +
84 + In order to preserve the allauth behavior while respecting Django's
85 + logic, we stash a user for which the password check succeeded but
86 + `user_can_authenticate()` failed. In the allauth authentication logic,
87 + we can then unstash this user and proceed pointing the user to the
88 + account inactive page.
89 + """
90 + global _stash
91 + ret = getattr(_stash, 'user', None)
92 + _stash.user = user
93 + return ret
94 +
95 + @classmethod
96 + def unstash_authenticated_user(cls):
97 + return cls._stash_user(None)
1 +from django.contrib.auth import REDIRECT_FIELD_NAME
2 +from django.contrib.auth.decorators import login_required
3 +from django.shortcuts import render
4 +
5 +from .models import EmailAddress
6 +from .utils import send_email_confirmation
7 +
8 +
9 +def verified_email_required(function=None,
10 + login_url=None,
11 + redirect_field_name=REDIRECT_FIELD_NAME):
12 + """
13 + Even when email verification is not mandatory during signup, there
14 + may be circumstances during which you really want to prevent
15 + unverified users to proceed. This decorator ensures the user is
16 + authenticated and has a verified email address. If the former is
17 + not the case then the behavior is identical to that of the
18 + standard `login_required` decorator. If the latter does not hold,
19 + email verification mails are automatically resend and the user is
20 + presented with a page informing them they needs to verify their email
21 + address.
22 + """
23 + def decorator(view_func):
24 + @login_required(redirect_field_name=redirect_field_name,
25 + login_url=login_url)
26 + def _wrapped_view(request, *args, **kwargs):
27 + if not EmailAddress.objects.filter(user=request.user,
28 + verified=True).exists():
29 + send_email_confirmation(request, request.user)
30 + return render(request,
31 + 'account/verified_email_required.html')
32 + return view_func(request, *args, **kwargs)
33 + return _wrapped_view
34 +
35 + if function:
36 + return decorator(function)
37 + return decorator
1 +from django.core.management.base import BaseCommand
2 +from django.db.models import Count
3 +
4 +from allauth.account.models import EmailAddress
5 +from allauth.account.utils import user_email
6 +from allauth.utils import get_user_model
7 +
8 +
9 +class Command(BaseCommand):
10 + def handle(self, *args, **options):
11 + for user in self.get_users_with_multiple_primary_email():
12 + self.unprimary_extra_primary_emails(user)
13 +
14 + def get_users_with_multiple_primary_email(self):
15 + user_pks = []
16 + for email_address_dict in EmailAddress.objects.filter(
17 + primary=True).values('user').annotate(
18 + Count('user')).filter(user__count__gt=1):
19 + user_pks.append(email_address_dict['user'])
20 + return get_user_model().objects.filter(pk__in=user_pks)
21 +
22 + def unprimary_extra_primary_emails(self, user):
23 + primary_email_addresses = EmailAddress.objects.filter(
24 + user=user,
25 + primary=True)
26 +
27 + for primary_email_address in primary_email_addresses:
28 + if primary_email_address.email == user_email(user):
29 + break
30 + else:
31 + # Didn't find the main email addresses and break the for loop
32 + print(
33 + "WARNING: Multiple primary without a user.email match for"
34 + "user pk %s; (tried: %s, using: %s)") % (
35 + user.pk,
36 + ", ".join([
37 + email_address.email
38 + for email_address
39 + in primary_email_addresses]),
40 + primary_email_address)
41 +
42 + primary_email_addresses.exclude(
43 + pk=primary_email_address.pk).update(primary=False)
1 +from datetime import timedelta
2 +
3 +from django.db import models
4 +from django.db.models import Q
5 +from django.utils import timezone
6 +
7 +from . import app_settings
8 +
9 +
10 +class EmailAddressManager(models.Manager):
11 +
12 + def add_email(self, request, user, email,
13 + confirm=False, signup=False):
14 + email_address, created = self.get_or_create(
15 + user=user, email__iexact=email, defaults={"email": email}
16 + )
17 +
18 + if created and confirm:
19 + email_address.send_confirmation(request, signup=signup)
20 +
21 + return email_address
22 +
23 + def get_primary(self, user):
24 + try:
25 + return self.get(user=user, primary=True)
26 + except self.model.DoesNotExist:
27 + return None
28 +
29 + def get_users_for(self, email):
30 + # this is a list rather than a generator because we probably want to
31 + # do a len() on it right away
32 + return [address.user for address in self.filter(verified=True,
33 + email__iexact=email)]
34 +
35 + def fill_cache_for_user(self, user, addresses):
36 + """
37 + In a multi-db setup, inserting records and re-reading them later
38 + on may result in not being able to find newly inserted
39 + records. Therefore, we maintain a cache for the user so that
40 + we can avoid database access when we need to re-read..
41 + """
42 + user._emailaddress_cache = addresses
43 +
44 + def get_for_user(self, user, email):
45 + cache_key = '_emailaddress_cache'
46 + addresses = getattr(user, cache_key, None)
47 + if addresses is None:
48 + ret = self.get(user=user,
49 + email__iexact=email)
50 + # To avoid additional lookups when e.g.
51 + # EmailAddress.set_as_primary() starts touching self.user
52 + ret.user = user
53 + return ret
54 + else:
55 + for address in addresses:
56 + if address.email.lower() == email.lower():
57 + return address
58 + raise self.model.DoesNotExist()
59 +
60 +
61 +class EmailConfirmationManager(models.Manager):
62 +
63 + def all_expired(self):
64 + return self.filter(self.expired_q())
65 +
66 + def all_valid(self):
67 + return self.exclude(self.expired_q())
68 +
69 + def expired_q(self):
70 + sent_threshold = timezone.now() \
71 + - timedelta(days=app_settings.EMAIL_CONFIRMATION_EXPIRE_DAYS)
72 + return Q(sent__lt=sent_threshold)
73 +
74 + def delete_expired_confirmations(self):
75 + self.all_expired().delete()
1 +# -*- coding: utf-8 -*-
2 +from __future__ import unicode_literals
3 +
4 +from django.db import models, migrations
5 +import django.utils.timezone
6 +from django.conf import settings
7 +
8 +UNIQUE_EMAIL = getattr(settings, 'ACCOUNT_UNIQUE_EMAIL', True)
9 +
10 +
11 +class Migration(migrations.Migration):
12 +
13 + dependencies = [
14 + migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15 + ]
16 +
17 + operations = [
18 + migrations.CreateModel(
19 + name='EmailAddress',
20 + fields=[
21 + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
22 + ('email', models.EmailField(unique=UNIQUE_EMAIL, max_length=75, verbose_name='e-mail address')),
23 + ('verified', models.BooleanField(default=False, verbose_name='verified')),
24 + ('primary', models.BooleanField(default=False, verbose_name='primary')),
25 + ('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
26 + ],
27 + options={
28 + 'verbose_name': 'email address',
29 + 'verbose_name_plural': 'email addresses',
30 + },
31 + bases=(models.Model,),
32 + ),
33 + migrations.CreateModel(
34 + name='EmailConfirmation',
35 + fields=[
36 + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
37 + ('created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='created')),
38 + ('sent', models.DateTimeField(null=True, verbose_name='sent')),
39 + ('key', models.CharField(unique=True, max_length=64, verbose_name='key')),
40 + ('email_address', models.ForeignKey(verbose_name='e-mail address', to='account.EmailAddress', on_delete=models.CASCADE)),
41 + ],
42 + options={
43 + 'verbose_name': 'email confirmation',
44 + 'verbose_name_plural': 'email confirmations',
45 + },
46 + bases=(models.Model,),
47 + ),
48 + ]
49 +
50 + if not UNIQUE_EMAIL:
51 + operations += [
52 + migrations.AlterUniqueTogether(
53 + name='emailaddress',
54 + unique_together=set([('user', 'email')]),
55 + ),
56 + ]
1 +# -*- coding: utf-8 -*-
2 +from __future__ import unicode_literals
3 +
4 +from django.db import models, migrations
5 +from django.conf import settings
6 +
7 +UNIQUE_EMAIL = getattr(settings, 'ACCOUNT_UNIQUE_EMAIL', True)
8 +EMAIL_MAX_LENGTH = getattr(settings, 'ACCOUNT_EMAIL_MAX_LENGTH', 254)
9 +
10 +
11 +class Migration(migrations.Migration):
12 +
13 + dependencies = [
14 + ('account', '0001_initial'),
15 + ]
16 +
17 + operations = [
18 + migrations.AlterField(
19 + model_name='emailaddress',
20 + name='email',
21 + field=models.EmailField(unique=UNIQUE_EMAIL, max_length=EMAIL_MAX_LENGTH, verbose_name='e-mail address'),
22 + ),
23 + ]
24 +
25 + if not UNIQUE_EMAIL:
26 + operations += [
27 + migrations.AlterUniqueTogether(
28 + name='emailaddress',
29 + unique_together=set([('user', 'email')]),
30 + ),
31 + ]
1 +from __future__ import unicode_literals
2 +
3 +import datetime
4 +
5 +from django.core import signing
6 +from django.db import models, transaction
7 +from django.utils import timezone
8 +from django.utils.crypto import get_random_string
9 +from django.utils.translation import gettext_lazy as _
10 +
11 +from .. import app_settings as allauth_app_settings
12 +from . import app_settings, signals
13 +from .adapter import get_adapter
14 +from .managers import EmailAddressManager, EmailConfirmationManager
15 +from .utils import user_email
16 +
17 +
18 +class EmailAddress(models.Model):
19 +
20 + user = models.ForeignKey(allauth_app_settings.USER_MODEL,
21 + verbose_name=_('user'),
22 + on_delete=models.CASCADE)
23 + email = models.EmailField(unique=app_settings.UNIQUE_EMAIL,
24 + max_length=app_settings.EMAIL_MAX_LENGTH,
25 + verbose_name=_('e-mail address'))
26 + verified = models.BooleanField(verbose_name=_('verified'), default=False)
27 + primary = models.BooleanField(verbose_name=_('primary'), default=False)
28 +
29 + objects = EmailAddressManager()
30 +
31 + class Meta:
32 + verbose_name = _("email address")
33 + verbose_name_plural = _("email addresses")
34 + if not app_settings.UNIQUE_EMAIL:
35 + unique_together = [("user", "email")]
36 +
37 + def __str__(self):
38 + return self.email
39 +
40 + def set_as_primary(self, conditional=False):
41 + old_primary = EmailAddress.objects.get_primary(self.user)
42 + if old_primary:
43 + if conditional:
44 + return False
45 + old_primary.primary = False
46 + old_primary.save()
47 + self.primary = True
48 + self.save()
49 + user_email(self.user, self.email)
50 + self.user.save()
51 + return True
52 +
53 + def send_confirmation(self, request=None, signup=False):
54 + if app_settings.EMAIL_CONFIRMATION_HMAC:
55 + confirmation = EmailConfirmationHMAC(self)
56 + else:
57 + confirmation = EmailConfirmation.create(self)
58 + confirmation.send(request, signup=signup)
59 + return confirmation
60 +
61 + def change(self, request, new_email, confirm=True):
62 + """
63 + Given a new email address, change self and re-confirm.
64 + """
65 + with transaction.atomic():
66 + user_email(self.user, new_email)
67 + self.user.save()
68 + self.email = new_email
69 + self.verified = False
70 + self.save()
71 + if confirm:
72 + self.send_confirmation(request)
73 +
74 +
75 +class EmailConfirmation(models.Model):
76 +
77 + email_address = models.ForeignKey(EmailAddress,
78 + verbose_name=_('e-mail address'),
79 + on_delete=models.CASCADE)
80 + created = models.DateTimeField(verbose_name=_('created'),
81 + default=timezone.now)
82 + sent = models.DateTimeField(verbose_name=_('sent'), null=True)
83 + key = models.CharField(verbose_name=_('key'), max_length=64, unique=True)
84 +
85 + objects = EmailConfirmationManager()
86 +
87 + class Meta:
88 + verbose_name = _("email confirmation")
89 + verbose_name_plural = _("email confirmations")
90 +
91 + def __str__(self):
92 + return "confirmation for %s" % self.email_address
93 +
94 + @classmethod
95 + def create(cls, email_address):
96 + key = get_random_string(64).lower()
97 + return cls._default_manager.create(email_address=email_address,
98 + key=key)
99 +
100 + def key_expired(self):
101 + expiration_date = self.sent \
102 + + datetime.timedelta(days=app_settings
103 + .EMAIL_CONFIRMATION_EXPIRE_DAYS)
104 + return expiration_date <= timezone.now()
105 + key_expired.boolean = True
106 +
107 + def confirm(self, request):
108 + if not self.key_expired() and not self.email_address.verified:
109 + email_address = self.email_address
110 + get_adapter(request).confirm_email(request, email_address)
111 + signals.email_confirmed.send(sender=self.__class__,
112 + request=request,
113 + email_address=email_address)
114 + return email_address
115 +
116 + def send(self, request=None, signup=False):
117 + get_adapter(request).send_confirmation_mail(request, self, signup)
118 + self.sent = timezone.now()
119 + self.save()
120 + signals.email_confirmation_sent.send(sender=self.__class__,
121 + request=request,
122 + confirmation=self,
123 + signup=signup)
124 +
125 +
126 +class EmailConfirmationHMAC:
127 +
128 + def __init__(self, email_address):
129 + self.email_address = email_address
130 +
131 + @property
132 + def key(self):
133 + return signing.dumps(
134 + obj=self.email_address.pk,
135 + salt=app_settings.SALT)
136 +
137 + @classmethod
138 + def from_key(cls, key):
139 + try:
140 + max_age = (
141 + 60 * 60 * 24 * app_settings.EMAIL_CONFIRMATION_EXPIRE_DAYS)
142 + pk = signing.loads(
143 + key,
144 + max_age=max_age,
145 + salt=app_settings.SALT)
146 + ret = EmailConfirmationHMAC(EmailAddress.objects.get(pk=pk))
147 + except (signing.SignatureExpired,
148 + signing.BadSignature,
149 + EmailAddress.DoesNotExist):
150 + ret = None
151 + return ret
152 +
153 + def confirm(self, request):
154 + if not self.email_address.verified:
155 + email_address = self.email_address
156 + get_adapter(request).confirm_email(request, email_address)
157 + signals.email_confirmed.send(sender=self.__class__,
158 + request=request,
159 + email_address=email_address)
160 + return email_address
161 +
162 + def send(self, request=None, signup=False):
163 + get_adapter(request).send_confirmation_mail(request, self, signup)
164 + signals.email_confirmation_sent.send(sender=self.__class__,
165 + request=request,
166 + confirmation=self,
167 + signup=signup)
1 +from django.contrib.auth.signals import user_logged_out # noqa
2 +from django.dispatch import Signal
3 +
4 +
5 +user_logged_in = Signal(providing_args=["request", "user"])
6 +
7 +# Typically followed by `user_logged_in` (unless, e-mail verification kicks in)
8 +user_signed_up = Signal(providing_args=["request", "user"])
9 +
10 +password_set = Signal(providing_args=["request", "user"])
11 +password_changed = Signal(providing_args=["request", "user"])
12 +password_reset = Signal(providing_args=["request", "user"])
13 +
14 +email_confirmed = Signal(providing_args=["request", "email_address"])
15 +email_confirmation_sent = Signal(
16 + providing_args=["request", "confirmation", "signup"])
17 +
18 +email_changed = Signal(
19 + providing_args=[
20 + "request", "user",
21 + "from_email_address", "to_email_address"])
22 +email_added = Signal(providing_args=["request", "user", "email_address"])
23 +email_removed = Signal(providing_args=["request", "user", "email_address"])