├── .gitignore ├── DERSLER ├── GUN 1 │ └── reversed_dictionary.py ├── GUN 2 │ ├── Melek │ │ ├── Melek │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── settings.cpython-36.pyc │ │ │ │ ├── urls.cpython-36.pyc │ │ │ │ └── wsgi.cpython-36.pyc │ │ │ ├── settings.py │ │ │ ├── urls.py │ │ │ └── wsgi.py │ │ ├── db.sqlite3 │ │ ├── manage.py │ │ ├── manage.sublime-workspace │ │ └── news │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── admin.cpython-36.pyc │ │ │ └── models.cpython-36.pyc │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── __init__.py │ │ │ └── __pycache__ │ │ │ │ ├── 0001_initial.cpython-36.pyc │ │ │ │ └── __init__.cpython-36.pyc │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ ├── pythonic_reverse_dict.py │ ├── reversed_dictionary_normal.py │ └── to-run-django-note.md ├── GUN 3 │ ├── elifinokuzu │ │ ├── db.sqlite3 │ │ ├── dictionary │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── admin.cpython-36.pyc │ │ │ │ └── models.cpython-36.pyc │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── migrations │ │ │ │ ├── 0001_initial.py │ │ │ │ ├── 0002_edge.py │ │ │ │ ├── __init__.py │ │ │ │ └── __pycache__ │ │ │ │ │ ├── 0001_initial.cpython-36.pyc │ │ │ │ │ ├── 0002_edge.cpython-36.pyc │ │ │ │ │ └── __init__.cpython-36.pyc │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── elifinokuzu │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── settings.cpython-36.pyc │ │ │ │ ├── urls.cpython-36.pyc │ │ │ │ └── wsgi.cpython-36.pyc │ │ │ ├── settings.py │ │ │ ├── urls.py │ │ │ └── wsgi.py │ │ └── manage.py │ ├── models.md │ └── probablity.py ├── GUN 4 │ ├── elifinokuzu-not.md │ └── elifinokuzu │ │ ├── db.sqlite3 │ │ ├── dictionary │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── admin.cpython-36.pyc │ │ │ ├── models.cpython-36.pyc │ │ │ └── views.cpython-36.pyc │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_edge.py │ │ │ ├── __init__.py │ │ │ └── __pycache__ │ │ │ │ ├── 0001_initial.cpython-36.pyc │ │ │ │ ├── 0002_edge.cpython-36.pyc │ │ │ │ └── __init__.cpython-36.pyc │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ │ ├── elifinokuzu │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── settings.cpython-36.pyc │ │ │ ├── urls.cpython-36.pyc │ │ │ └── wsgi.cpython-36.pyc │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ │ ├── manage.py │ │ └── templates │ │ ├── home.html │ │ └── node_detail.html ├── GUN 5 │ ├── base-templates.md │ ├── deployment.md │ └── elifinokuzu │ │ ├── dictionary │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_edge.py │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ │ ├── elifinokuzu │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ │ ├── manage.py │ │ └── templates │ │ ├── about.html │ │ ├── base_template.html │ │ ├── home.html │ │ ├── node_detail.html │ │ └── support.html ├── GUN 6 │ ├── authentication.md │ ├── elifinokuzu │ │ ├── accounts │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── migrations │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── dictionary │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ │ ├── 0001_initial.py │ │ │ │ ├── 0002_edge.py │ │ │ │ ├── 0003_auto_20180726_1236.py │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── elifinokuzu │ │ │ ├── __init__.py │ │ │ ├── settings.py │ │ │ ├── urls.py │ │ │ └── wsgi.py │ │ ├── manage.py │ │ ├── static │ │ │ └── layout │ │ │ │ └── styles │ │ │ │ └── base.css │ │ └── templates │ │ │ ├── about.html │ │ │ ├── accounts │ │ │ └── dashboard.html │ │ │ ├── base.html │ │ │ ├── home.html │ │ │ ├── node_detail.html │ │ │ ├── registration │ │ │ ├── login.html │ │ │ └── signup.html │ │ │ ├── submit.html │ │ │ └── support.html │ ├── forms.md │ └── static-css.md ├── GUN 7 │ └── elifinokuzu │ │ ├── accounts │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ │ ├── comments │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── forms.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_auto_20180727_2228.py │ │ │ ├── 0003_auto_20180727_2253.py │ │ │ ├── 0004_auto_20180727_2254.py │ │ │ ├── 0005_auto_20180727_2130.py │ │ │ ├── 0006_auto_20180727_2203.py │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ │ ├── crawler │ │ └── management │ │ │ ├── __init__.py │ │ │ └── commands │ │ │ ├── __init__.py │ │ │ └── crawler.py │ │ ├── dictionary │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── forms.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_edge.py │ │ │ ├── 0003_auto_20180722_1650.py │ │ │ ├── 0004_edge_resource.py │ │ │ ├── 0005_auto_20180727_1146.py │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ │ ├── elifinokuzu │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ │ ├── locale │ │ └── tr │ │ │ └── LC_MESSAGES │ │ │ └── django.po │ │ ├── manage.py │ │ ├── static │ │ ├── favicon.ico │ │ ├── layout │ │ │ └── styles │ │ │ │ └── base.css │ │ └── logo.png │ │ └── templates │ │ ├── about.html │ │ ├── accounts │ │ └── dashboard.html │ │ ├── base.html │ │ ├── comments │ │ └── add_comment_to_node.html │ │ ├── home.html │ │ ├── node_detail.html │ │ ├── registration │ │ ├── login.html │ │ └── signup.html │ │ ├── submit.html │ │ └── support.html ├── GUN 8 │ ├── elifinokuzu │ │ ├── accounts │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── comments │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ │ ├── 0001_initial.py │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── crawler │ │ │ ├── __init__.py │ │ │ └── management │ │ │ │ ├── __init__.py │ │ │ │ └── commands │ │ │ │ ├── __init__.py │ │ │ │ └── crawler.py │ │ ├── dictionary │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ │ ├── 0001_initial.py │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── elifinokuzu │ │ │ ├── .settings.py.swp │ │ │ ├── __init__.py │ │ │ ├── settings.py │ │ │ ├── urls.py │ │ │ └── wsgi.py │ │ ├── locale │ │ │ └── tr │ │ │ │ └── LC_MESSAGES │ │ │ │ └── django.po │ │ ├── manage.py │ │ ├── reports │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ │ ├── 0001_initial.py │ │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── tests.py │ │ │ └── views.py │ │ ├── static │ │ │ ├── favicon.ico │ │ │ ├── layout │ │ │ │ └── styles │ │ │ │ │ └── base.css │ │ │ └── logo.png │ │ └── templates │ │ │ ├── about.html │ │ │ ├── accounts │ │ │ └── dashboard.html │ │ │ ├── base.html │ │ │ ├── comments │ │ │ ├── add_comment_to_edge.html │ │ │ └── add_comment_to_node.html │ │ │ ├── edge_detail.html │ │ │ ├── home.html │ │ │ ├── node_detail.html │ │ │ ├── registration │ │ │ ├── login.html │ │ │ └── signup.html │ │ │ ├── reports │ │ │ ├── report.html │ │ │ └── reportdone.html │ │ │ ├── submit.html │ │ │ └── support.html │ └── logos │ │ ├── 1.svg │ │ ├── ice_cream.svg │ │ └── perfect_logo_ever.svg └── Notlar │ ├── authentication.md │ ├── base-templates.md │ ├── deployment.md │ ├── forms.md │ ├── models.md │ ├── static-css.md │ ├── to-run-django-note.md │ └── views.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | .idea/ -------------------------------------------------------------------------------- /DERSLER/GUN 1/reversed_dictionary.py: -------------------------------------------------------------------------------- 1 | #!usr/bin/env python 2 | sozluk ={'elma': 'apple', 'muz': 'banana', 'uzum': 'grapes', 'havuc': 'carrot'} 3 | print(sozluk) 4 | reverse_sozluk = {i:j for j,i in sozluk.items()} 5 | 6 | print(reverse_sozluk) 7 | print(reverse_sozluk["apple"]) 8 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/Melek/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/Melek/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/Melek/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/Melek/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/Melek/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for Melek project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'jo_r+o&k#d70!*$o1q@u5-q$eqo_$bapx%tt^iy+e=5*mht^l+' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'news', 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'Melek.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'Melek.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 87 | 88 | AUTH_PASSWORD_VALIDATORS = [ 89 | { 90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 91 | }, 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 100 | }, 101 | ] 102 | 103 | 104 | # Internationalization 105 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 106 | 107 | LANGUAGE_CODE = 'en-us' 108 | 109 | TIME_ZONE = 'UTC' 110 | 111 | USE_I18N = True 112 | 113 | USE_L10N = True 114 | 115 | USE_TZ = True 116 | 117 | 118 | # Static files (CSS, JavaScript, Images) 119 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/urls.py: -------------------------------------------------------------------------------- 1 | """Melek URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/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: path('', 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: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | ] 22 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/Melek/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for Melek 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/2.0/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", "Melek.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/db.sqlite3 -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/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", "Melek.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/manage.sublime-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "auto_complete": 3 | { 4 | "selected_items": 5 | [ 6 | ] 7 | }, 8 | "buffers": 9 | [ 10 | ], 11 | "build_system": "", 12 | "build_system_choices": 13 | [ 14 | ], 15 | "build_varint": "", 16 | "command_palette": 17 | { 18 | "height": 0.0, 19 | "last_filter": "", 20 | "selected_items": 21 | [ 22 | ], 23 | "width": 0.0 24 | }, 25 | "console": 26 | { 27 | "height": 0.0, 28 | "history": 29 | [ 30 | ] 31 | }, 32 | "distraction_free": 33 | { 34 | "menu_visible": true, 35 | "show_minimap": false, 36 | "show_open_files": false, 37 | "show_tabs": false, 38 | "side_bar_visible": false, 39 | "status_bar_visible": false 40 | }, 41 | "file_history": 42 | [ 43 | "/home/omerbselvi/Documents/Django-Projeler/Melek/manage.py", 44 | "/usr/share/applications/defaults.list", 45 | "/home/omerbselvi/Desktop/reversed_sozluk.py", 46 | "/home/omerbselvi/Desktop/hi.py", 47 | "/home/omerbselvi/Desktop/hi2.py" 48 | ], 49 | "find": 50 | { 51 | "height": 26.0 52 | }, 53 | "find_in_files": 54 | { 55 | "height": 0.0, 56 | "where_history": 57 | [ 58 | ] 59 | }, 60 | "find_state": 61 | { 62 | "case_sensitive": false, 63 | "find_history": 64 | [ 65 | ], 66 | "highlight": true, 67 | "in_selection": false, 68 | "preserve_case": false, 69 | "regex": false, 70 | "replace_history": 71 | [ 72 | ], 73 | "reverse": false, 74 | "show_context": true, 75 | "use_buffer2": true, 76 | "whole_word": false, 77 | "wrap": true 78 | }, 79 | "groups": 80 | [ 81 | { 82 | "sheets": 83 | [ 84 | ] 85 | } 86 | ], 87 | "incremental_find": 88 | { 89 | "height": 26.0 90 | }, 91 | "input": 92 | { 93 | "height": 0.0 94 | }, 95 | "layout": 96 | { 97 | "cells": 98 | [ 99 | [ 100 | 0, 101 | 0, 102 | 1, 103 | 1 104 | ] 105 | ], 106 | "cols": 107 | [ 108 | 0.0, 109 | 1.0 110 | ], 111 | "rows": 112 | [ 113 | 0.0, 114 | 1.0 115 | ] 116 | }, 117 | "menu_visible": true, 118 | "output.find_results": 119 | { 120 | "height": 0.0 121 | }, 122 | "pinned_build_system": "", 123 | "project": "manage.sublime-project", 124 | "replace": 125 | { 126 | "height": 48.0 127 | }, 128 | "save_all_on_build": true, 129 | "select_file": 130 | { 131 | "height": 0.0, 132 | "last_filter": "", 133 | "selected_items": 134 | [ 135 | ], 136 | "width": 0.0 137 | }, 138 | "select_project": 139 | { 140 | "height": 0.0, 141 | "last_filter": "", 142 | "selected_items": 143 | [ 144 | ], 145 | "width": 0.0 146 | }, 147 | "select_symbol": 148 | { 149 | "height": 0.0, 150 | "last_filter": "", 151 | "selected_items": 152 | [ 153 | ], 154 | "width": 0.0 155 | }, 156 | "selected_group": 0, 157 | "settings": 158 | { 159 | }, 160 | "show_minimap": true, 161 | "show_open_files": false, 162 | "show_tabs": true, 163 | "side_bar_visible": true, 164 | "side_bar_width": 150.0, 165 | "status_bar_visible": true, 166 | "template_settings": 167 | { 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from news.models import NewsItem 3 | # Register your models here. 4 | admin.site.register(NewsItem) -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class NewsConfig(AppConfig): 5 | name = 'news' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-21 15:57 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='NewsItem', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=255)), 19 | ('date_creation', models.DateTimeField(auto_now_add=True)), 20 | ('date_publish', models.DateTimeField(blank=True, null=True)), 21 | ('content', models.TextField()), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 2/Melek/news/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | 5 | class NewsItem(models.Model): 6 | """docstring for NewsItem""" 7 | title = models.CharField(max_length = 255) 8 | date_creation = models.DateTimeField(auto_now_add = True) 9 | date_publish = models.DateTimeField(blank = True, null = True) 10 | content = models.TextField() 11 | 12 | def __str__(self): 13 | return self.title 14 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/Melek/news/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 2/pythonic_reverse_dict.py: -------------------------------------------------------------------------------- 1 | #!usr/bin/env python 2 | fatih = { 3 | "lyk" : "2018", 4 | "gorev" : "hoca", 5 | "key" : "fatih", 6 | "sınıf" : "201", 7 | } 8 | print("Dictionary:", fatih) 9 | print("Dictionary Comprehension:", [key for key,value in fatih.items()]) 10 | print("Reversed Dictionary:", dict((value,key) for key,value in fatih.items())) -------------------------------------------------------------------------------- /DERSLER/GUN 2/reversed_dictionary_normal.py: -------------------------------------------------------------------------------- 1 | #!usr/bin/env python 2 | fatih = { 3 | "lyk" : "2018", 4 | "gorev" : "hoca", 5 | "key" : "fatih", 6 | "sınıf" : "201", 7 | } 8 | tunahan = { 9 | "lyk" : "2018", 10 | "gorev" : "yarım hoca", 11 | "key" : "fatih", 12 | } 13 | 14 | print("Fatih:", fatih) 15 | 16 | keys = fatih.keys() 17 | values = fatih.values() 18 | 19 | first = list(keys) 20 | second = list(values) 21 | 22 | reverseFatih = {} 23 | for i in range(len(first)): 24 | reverseFatih.update({second[i]:first[i],}) 25 | print("Reverse Fatih:", reverseFatih) 26 | print("Tunahan:", tunahan) -------------------------------------------------------------------------------- /DERSLER/GUN 2/to-run-django-note.md: -------------------------------------------------------------------------------- 1 | #### Virtualenv için 2 | *virtualenv --python=python3 * 3 | 4 | *source /bin/activate* 5 | 6 | *virtualenv --python=python3 lyk* 7 | 8 | *source lyk/bin/activate* 9 | 10 | #### Ardından o konuma django kurmak için 11 | *pip install django* 12 | 13 | #### Django projesi oluşturmak için, ama önce klasör dizinini belirle 14 | *django-admin startproject * 15 | 16 | *django-admin startproject Melek* 17 | 18 | #### Startprojectten sonra proje dizinine git sonra; 19 | *python manage.py runserver* 20 | 21 | #### İstenilen Itemın ismini ezmek için models.py a eklenir; 22 | ```python 23 | def __str__(self): 24 | return self.title 25 | ``` 26 | #### App başlatmak için 27 | *python manage.py startapp * 28 | 29 | *python manage.py startapp news* 30 | * Melek/Melek/settings.py dosyasında installed apps güncelle(modeli ekle) 31 | 32 | ```python 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'news', 41 | ] 42 | ``` 43 | admin panelde düzenlemek için news/admin.py dosyasına; 44 | ```python 45 | from news.models import NewsItem 46 | admin.site.register(NewsItem) 47 | ``` 48 | ekle 49 | 50 | #### Migrationsları oluşturma 51 | *python manage.py makemigrations* 52 | #### Migrate işlemi 53 | *pyton manage.py migrate* 54 | #### Superuser oluşturma işlemi 55 | *python manage.py createsuperuser* 56 | #### 80 portundan erişim sağlama 57 | *python manage.py runserver 0.0.0.0:80* 58 | * Global erişişm için Melek/Melek/settings.py dosyasında 59 | 60 | ```python 61 | ALLOWED_HOSTS = ['*'] 62 | ``` 63 | * şeklinde güncellenmeli 64 | #### Shell kullanma örneği 65 | *python manage.py shell* 66 | ```python 67 | from news.models import NewsItem 68 | NewsItem() 69 | NewsItem(title="fikibok") 70 | 71 | haber = NewsItem() 72 | haber.title = "fiki fiki" 73 | haber.content = "emoji" 74 | haber.save() 75 | haber.id 76 | ``` -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/db.sqlite3 -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node,Edge 3 | 4 | 5 | admin.site.register(Node) 6 | admin.site.register(Edge) -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 15:30 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Node', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=255)), 19 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('de', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish')], max_length=255)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/0002_edge.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:13 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('dictionary', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Edge', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('is_directed', models.BooleanField()), 19 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 20 | ('destination', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node')), 21 | ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/0002_edge.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/0002_edge.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/dictionary/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | LANGUAGE_CHOICES = ( 5 | ("tr", "Turkish"), 6 | ("fr", "French"), 7 | ("de", "German"), 8 | ("pl", "Polish"), 9 | ("kr", "Kurdish"), 10 | ("lt", "Latin"), 11 | ("en", "English"), 12 | ("es", "Spanish"), 13 | ("ar", "Arabic"), 14 | ) 15 | 16 | EDGE_TYPE_CHOICES = ( 17 | ("derives_from", "Derives from"), 18 | ("symbol_of", "Symbol of"), 19 | ("compound_of", "Compound of"), 20 | ) 21 | 22 | class Node(models.Model): 23 | """ 24 | Node (düğüm). 25 | The most base entity in the dictionary 26 | """ 27 | name = models.CharField(max_length = 255) 28 | language = models.CharField( 29 | max_length=255, 30 | choices=LANGUAGE_CHOICES 31 | ) 32 | 33 | def __str__(self): 34 | return self.name 35 | 36 | class Edge(models.Model): 37 | """ 38 | Edge (kenar) 39 | Holds the relationship between nodes 40 | """ 41 | source = models.ForeignKey( 42 | Node, 43 | related_name="incoming", 44 | on_delete=models.CASCADE, 45 | ) 46 | destination = models.ForeignKey( 47 | Node, 48 | related_name="outgoing", 49 | on_delete=models.CASCADE, 50 | ) 51 | is_directed = models.BooleanField() 52 | type_of_edge = models.CharField( 53 | max_length=255, 54 | choices=EDGE_TYPE_CHOICES 55 | ) 56 | def __str__(self): 57 | if self.is_directed: 58 | arrow = "-->" 59 | else: 60 | arrow = "<->" 61 | return "%s:%s %s %s:%s" % ( 62 | self.source.language, 63 | self.source.name.lower(), 64 | arrow, 65 | self.destination.language, 66 | self.destination.name.lower() 67 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 3/elifinokuzu/elifinokuzu/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '%#fvsb6e1ekmzo671_^^#d4b(pzuio-8v6h32i8@6_e8zq7t)!' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'dictionary', 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'elifinokuzu.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 87 | 88 | AUTH_PASSWORD_VALIDATORS = [ 89 | { 90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 91 | }, 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 100 | }, 101 | ] 102 | 103 | 104 | # Internationalization 105 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 106 | 107 | LANGUAGE_CODE = 'en-us' 108 | 109 | TIME_ZONE = 'UTC' 110 | 111 | USE_I18N = True 112 | 113 | USE_L10N = True 114 | 115 | USE_TZ = True 116 | 117 | 118 | # Static files (CSS, JavaScript, Images) 119 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | """elifinokuzu URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/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: path('', 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: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | ] 22 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 3/models.md: -------------------------------------------------------------------------------- 1 | ### Models 2 | Yaratılmak istenen model class şeklinde oluşturulur ve models.Model classından türetilir. 3 | ```python 4 | from django.db import models 5 | 6 | 7 | class Node(models.Model): 8 | ``` 9 | Ardından yaratılan class içerisi *CharField*, *ForeignKey*, *BooleanField* gibi fieldlar ile modellenir. 10 | Admin panelinde eklenen objenin isminin görünmesi için *__str__* fonksiyonu(Java'daki *.toString()*) ezilir. 11 | ```python 12 | class Node(models.Model): 13 | name = models.CharField(max_length = 255) 14 | language = models.CharField( 15 | max_length=255, 16 | choices=LANGUAGE_CHOICES 17 | ) 18 | 19 | def __str__(self): 20 | return self.name 21 | 22 | class Edge(models.Model): 23 | source = models.ForeignKey( 24 | Node, 25 | related_name="incoming", 26 | on_delete=models.CASCADE, 27 | ) 28 | destination = models.ForeignKey( 29 | Node, 30 | related_name="outgoing", 31 | on_delete=models.CASCADE, 32 | ) 33 | is_directed = models.BooleanField() 34 | type_of_edge = models.CharField( 35 | max_length=255, 36 | choices=EDGE_TYPE_CHOICES 37 | ) 38 | def __str__(self): 39 | if self.is_directed: 40 | arrow = "-->" 41 | else: 42 | arrow = "<->" 43 | return "%s:%s %s %s:%s" % ( 44 | self.source.language, 45 | self.source.name.lower(), 46 | arrow, 47 | self.destination.language, 48 | self.destination.name.lower() 49 | ) 50 | ``` 51 | Eklenen modelin Admin panelde görünmesi için *admim.py* dosyasına ekleme yapılır. 52 | ```python 53 | from django.contrib import admin 54 | from dictionary.models import Node,Edge 55 | 56 | 57 | admin.site.register(Node) 58 | admin.site.register(Edge) 59 | ``` 60 | Ardından eklenen modeller ve modellerde yapılan değişiklikler için 61 | ``` 62 | python manage.py makemigrations 63 | python manage.py migrate 64 | ``` 65 | yapılır. -------------------------------------------------------------------------------- /DERSLER/GUN 3/probablity.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | class Probablity: 5 | """ 6 | This module functions returns head or tail, rock or paper or scissors, 7 | dice or roll. It depends on what you want. 8 | Usage: 9 | dice_roll(int) 10 | head_tail() 11 | rock_paper_scissors() 12 | """ 13 | def roll_dices(self,number_of_dices): 14 | faces = { 15 | 1:0, 16 | 2:0, 17 | 3:0, 18 | 4:0, 19 | 5:0, 20 | 6:0, 21 | } 22 | for i in range(number_of_dices): 23 | for key,value in faces.items(): 24 | if key == random.randint(0,6): 25 | faces[key] = faces[key] + 1 26 | print("ZAR SAYISI:",number_of_dices) 27 | print("----ATILAN ZARLAR----") 28 | print("Toplam 1 gelme:",faces[1]) 29 | print("Toplam 2 gelme:", faces[2]) 30 | print("Toplam 3 gelme:", faces[3]) 31 | print("Toplam 4 gelme:", faces[4]) 32 | print("Toplam 5 gelme:", faces[5]) 33 | print("Toplam 6 gelme:", faces[6]) 34 | print("----ATILAN ZARLAR----") 35 | 36 | def head_or_tails(self): 37 | print("Yazı Tura:",random.choice(("Yazı","Tura"))) 38 | 39 | def rock_paper_scissors(self): 40 | print("Taş Kağıt Makas:",random.choice(("Rock","Paper","Scissors"))) -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu-not.md: -------------------------------------------------------------------------------- 1 | #### Views model.view.template 2 | Kullanıcının göreceği kısım 3 | 4 | #### Basit bir view; 5 | "views.py" dosyasına eklenir 6 | ```python 7 | from django.http import HttpResponse 8 | import datetime 9 | 10 | def current_datetime(request): 11 | now = datetime.datetime.now() 12 | html = "It is now %s." % now 13 | return HttpResponse(html) 14 | ``` 15 | Ardından eklenen view "urls.py" dosyasına eklenir 16 | ```python 17 | urlpatterns = [ 18 | path('', views.current_datetime, name="home"), 19 | path('admin/', admin.site.urls), 20 | ] 21 | ``` 22 | #### Template eklemek için; 23 | Proje rootuna 'templates' klasörü eklenir. 24 | Ardından içerisine html dosyası eklenir 25 | ```python 26 | #views.py 27 | def home(request): 28 | return render(request, "home.html", { 29 | "title": "Öküzün Elifi" 30 | }) 31 | ``` 32 | settings.py dosyasında 33 | ```python 34 | TEMPLATES = [ 35 | { 36 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 37 | 'DIRS': [ 38 | os.path.join(BASE_DIR, "templates"), 39 | ], 40 | 'APP_DIRS': True, 41 | 'OPTIONS': { 42 | 'context_processors': [ 43 | 'django.template.context_processors.debug', 44 | 'django.template.context_processors.request', 45 | 'django.contrib.auth.context_processors.auth', 46 | 'django.contrib.messages.context_processors.messages', 47 | ], 48 | }, 49 | }, 50 | ] 51 | ``` 52 | kısmına 53 | ```python 54 | 'DIRS': [ 55 | os.path.join(BASE_DIR, "templates"), 56 | ] 57 | ``` 58 | eklenir -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/db.sqlite3 -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node,Edge 3 | 4 | 5 | admin.site.register(Node) 6 | admin.site.register(Edge) -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 15:30 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Node', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=255)), 19 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('de', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish')], max_length=255)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/0002_edge.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:13 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('dictionary', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Edge', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('is_directed', models.BooleanField()), 19 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 20 | ('destination', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node')), 21 | ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/0002_edge.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/0002_edge.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/dictionary/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | LANGUAGE_CHOICES = ( 5 | ("tr", "Turkish"), 6 | ("fr", "French"), 7 | ("de", "German"), 8 | ("pl", "Polish"), 9 | ("kr", "Kurdish"), 10 | ("lt", "Latin"), 11 | ("en", "English"), 12 | ("es", "Spanish"), 13 | ("ar", "Arabic"), 14 | ) 15 | 16 | EDGE_TYPE_CHOICES = ( 17 | ("derives_from", "Derives from"), 18 | ("symbol_of", "Symbol of"), 19 | ("compound_of", "Compound of"), 20 | ) 21 | 22 | class Node(models.Model): 23 | """ 24 | Node (düğüm). 25 | The most base entity in the dictionary 26 | """ 27 | name = models.CharField(max_length = 255) 28 | language = models.CharField( 29 | max_length=255, 30 | choices=LANGUAGE_CHOICES 31 | ) 32 | 33 | def __str__(self): 34 | return self.name 35 | 36 | class Edge(models.Model): 37 | """ 38 | Edge (kenar) 39 | Holds the relationship between nodes 40 | """ 41 | source = models.ForeignKey( 42 | Node, 43 | related_name="incoming", 44 | on_delete=models.CASCADE, 45 | ) 46 | destination = models.ForeignKey( 47 | Node, 48 | related_name="outgoing", 49 | on_delete=models.CASCADE, 50 | ) 51 | is_directed = models.BooleanField() 52 | type_of_edge = models.CharField( 53 | max_length=255, 54 | choices=EDGE_TYPE_CHOICES 55 | ) 56 | def __str__(self): 57 | if self.is_directed: 58 | arrow = '---[%s]-->' % self.type_of_edge 59 | else: 60 | arrow = "<--[%s]-->" % self.type_of_edge 61 | return '(%s:%s) %s (%s:%s)' % ( 62 | self.source.language, 63 | self.source.name.lower(), 64 | arrow, 65 | self.destination.language, 66 | self.destination.name.lower() 67 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from dictionary.models import Node 3 | 4 | 5 | nodes = Node.objects.all() 6 | def home(request): 7 | return render(request, "home.html", { 8 | "title": "Öküzün Elifi", 9 | "nodes": nodes, 10 | }) 11 | 12 | def node_detail(request, id): 13 | node = Node.objects.get(id=id) 14 | incoming = node.incoming.all() 15 | outgoing = node.outgoing.all() 16 | 17 | return render(request, "node_detail.html", { 18 | "title": "Öküzün Elifi: %s" % node.name, 19 | "incoming": incoming, 20 | "outgoing": outgoing, 21 | "node": node, 22 | }) -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 4/elifinokuzu/elifinokuzu/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '%#fvsb6e1ekmzo671_^^#d4b(pzuio-8v6h32i8@6_e8zq7t)!' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'dictionary', 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'elifinokuzu.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [ 59 | os.path.join(BASE_DIR, "templates"), 60 | ], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 83 | } 84 | } 85 | 86 | 87 | # Password validation 88 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 89 | 90 | AUTH_PASSWORD_VALIDATORS = [ 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 102 | }, 103 | ] 104 | 105 | 106 | # Internationalization 107 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 108 | 109 | LANGUAGE_CODE = 'en-us' 110 | 111 | TIME_ZONE = 'UTC' 112 | 113 | USE_I18N = True 114 | 115 | USE_L10N = True 116 | 117 | USE_TZ = True 118 | 119 | 120 | # Static files (CSS, JavaScript, Images) 121 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 122 | 123 | STATIC_URL = '/static/' 124 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | """elifinokuzu URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/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: path('', 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: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | from dictionary import views 19 | 20 | urlpatterns = [ 21 | path('', views.home, name="home"), 22 | path('node//', views.node_detail), 23 | path('admin/', admin.site.urls), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ title }} 6 | 7 | 8 | {% for node in nodes %} 9 | {{ node }}
10 | {% endfor %} 11 | 12 | 13 | -------------------------------------------------------------------------------- /DERSLER/GUN 4/elifinokuzu/templates/node_detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ title }} 6 | 7 | 8 | {% for edge in incoming %} 9 | {{ edge }}
10 | {% endfor %} 11 | 12 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/base-templates.md: -------------------------------------------------------------------------------- 1 | ### Base Templates 2 | Base template başka bir html dosyasını base olarak inherit etmek için kullanılır 3 | 4 | ```python 5 | {% block title %} 6 | YOUR-TITLE 7 | {% endblock %} 8 | {% extends "base_template.html" %} 9 | {% block body_block %} 10 |

{{ node.name }}

11 | {% if incoming %} 12 |

Incoming

13 | {% for edge in incoming %} 14 | {{ edge }}
15 | {% endfor %} 16 | {% endif %} 17 | {% if outgoing %} 18 |

Outgoing

19 | {% for edge in outgoing %} 20 | {{ edge }}
21 | {% endfor %} 22 | {% endif %} 23 | {% endblock %} 24 | ``` 25 | *node_detail.html* dosyasının içeriğini başka bir html dosyası olan *base_template.html* dosyası içerisinde kullanabiliriz 26 | ```html 27 | 28 | 29 | 30 | 31 | 32 | {% block title %} 33 | Default Title 34 | {% endblock %} 35 | 36 | 37 | 38 | {% block body_block %} 39 | {% endblock %} 40 | 41 | 42 | ``` -------------------------------------------------------------------------------- /DERSLER/GUN 5/deployment.md: -------------------------------------------------------------------------------- 1 | ## Deployment 2 | https://www.vultr.com/ yada https://www.digitalocean.com/ gibi sitelerde hesap açılır, gerekli server ve server için OS seçilir, server kiralanır. 3 | Server kurulumu bittikten sonra terminalden SSH ile sunucuya bağlanılır. Gerekli ise -p numarası eklenir. 4 | 5 | ``` 6 | ssh root@ -p 7 | ``` 8 | Bağlandıktan sonra 9 | ``` 10 | sudo apt-get update 11 | sudo apt-get -y upgrade 12 | ``` 13 | ile apt ile update alınır 14 | #### Python3, pip3 ve Django kurulumu 15 | 16 | ``` 17 | sudo apt-get install python3 18 | sudo apt-get install -y python3-pip 19 | ``` 20 | Ardından pip3 ile virtualenv kurulumu yapılır 21 | 22 | ``` 23 | pip3 install virtualenv 24 | ``` 25 | Yükleme sonrasında virtualenv yaratılır; 26 | ``` 27 | virtualenv 28 | ``` 29 | *source* komutu ile virtual environment activate edilir 30 | ``` 31 | cd 32 | source bin/activate 33 | ``` 34 | Daha sonrasında yarattığımız virtual environment a django kurulur 35 | 36 | ``` 37 | pip install django 38 | pip install django-recaptcha 39 | ``` 40 | Virtual environmentların dışında projelerin bulunduğu klasöre proje clonelanır yada yaratılır. 41 | ``` 42 | //Örnek 43 | mkdir Projeler 44 | cd Projeler 45 | sudo apt-get install git 46 | git clone 47 | ``` 48 | #### Proje deploymentı 49 | manage.py bulunduğu klasöre gittikten sonra makemigrations yapılır.cd 50 | ``` 51 | python manage.py makemigrations 52 | ``` 53 | #### Migrate işlemi 54 | ``` 55 | python manage.py migrate 56 | ``` 57 | #### Superuser oluşturma işlemi 58 | ``` 59 | python manage.py createsuperuser 60 | ``` 61 | #### Alınan domain ( HTTP Proxy adresi ) allowed hosts a eklenir 62 | ```python 63 | ALLOWED_HOSTS = ["elifinokuzu.org"] 64 | ``` 65 | #### 80 portundan erişim sağlama 66 | ``` 67 | python manage.py runserver 0.0.0.0:80 68 | ``` 69 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 5/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node,Edge 3 | 4 | 5 | admin.site.register(Node) 6 | admin.site.register(Edge) -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 15:30 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Node', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=255)), 19 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('de', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish')], max_length=255)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/migrations/0002_edge.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:13 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('dictionary', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Edge', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('is_directed', models.BooleanField()), 19 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 20 | ('destination', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node')), 21 | ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 5/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | LANGUAGE_CHOICES = ( 5 | ("tr", "Turkish"), 6 | ("fr", "French"), 7 | ("de", "German"), 8 | ("pl", "Polish"), 9 | ("kr", "Kurdish"), 10 | ("lt", "Latin"), 11 | ("en", "English"), 12 | ("es", "Spanish"), 13 | ("ar", "Arabic"), 14 | ) 15 | 16 | EDGE_TYPE_CHOICES = ( 17 | ("derives_from", "Derives from"), 18 | ("symbol_of", "Symbol of"), 19 | ("compound_of", "Compound of"), 20 | ) 21 | 22 | class Node(models.Model): 23 | """ 24 | Node (düğüm). 25 | The most base entity in the dictionary 26 | """ 27 | name = models.CharField(max_length = 255) 28 | language = models.CharField( 29 | max_length=255, 30 | choices=LANGUAGE_CHOICES 31 | ) 32 | 33 | def __str__(self): 34 | return self.name 35 | 36 | class Edge(models.Model): 37 | """ 38 | Edge (kenar) 39 | Holds the relationship between nodes 40 | """ 41 | source = models.ForeignKey( 42 | Node, 43 | related_name="incoming", 44 | on_delete=models.CASCADE, 45 | ) 46 | destination = models.ForeignKey( 47 | Node, 48 | related_name="outgoing", 49 | on_delete=models.CASCADE, 50 | ) 51 | is_directed = models.BooleanField() 52 | type_of_edge = models.CharField( 53 | max_length=255, 54 | choices=EDGE_TYPE_CHOICES 55 | ) 56 | def __str__(self): 57 | if self.is_directed: 58 | arrow = '---[%s]-->' % self.type_of_edge 59 | else: 60 | arrow = "<--[%s]-->" % self.type_of_edge 61 | return '(%s:%s) %s (%s:%s)' % ( 62 | self.source.language, 63 | self.source.name.lower(), 64 | arrow, 65 | self.destination.language, 66 | self.destination.name.lower() 67 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from dictionary.models import Node 3 | 4 | 5 | nodes = Node.objects.all() 6 | def home(request): 7 | return render(request, "home.html", { 8 | "title": "Öküzün Elifi", 9 | "nodes": nodes, 10 | }) 11 | 12 | def node_detail(request, id): 13 | node = Node.objects.get(id=id) 14 | incoming = node.incoming.all() 15 | outgoing = node.outgoing.all() 16 | 17 | return render(request, "node_detail.html", { 18 | "title": "Öküzün Elifi: %s" % node.name, 19 | "incoming": incoming, 20 | "outgoing": outgoing, 21 | "node": node, 22 | }) 23 | 24 | def about(request): 25 | return render(request, "about.html") 26 | 27 | def support(request): 28 | return render(request, "support.html") 29 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 5/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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 | # Application definition 19 | 20 | INSTALLED_APPS = [ 21 | 'django.contrib.admin', 22 | 'django.contrib.auth', 23 | 'django.contrib.contenttypes', 24 | 'django.contrib.sessions', 25 | 'django.contrib.messages', 26 | 'django.contrib.staticfiles', 27 | 'dictionary', 28 | ] 29 | 30 | MIDDLEWARE = [ 31 | 'django.middleware.security.SecurityMiddleware', 32 | 'django.contrib.sessions.middleware.SessionMiddleware', 33 | 'django.middleware.common.CommonMiddleware', 34 | 'django.middleware.csrf.CsrfViewMiddleware', 35 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 36 | 'django.contrib.messages.middleware.MessageMiddleware', 37 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 38 | ] 39 | 40 | ROOT_URLCONF = 'elifinokuzu.urls' 41 | 42 | TEMPLATES = [ 43 | { 44 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 45 | 'DIRS': [ 46 | os.path.join(BASE_DIR, "templates"), 47 | ], 48 | 'APP_DIRS': True, 49 | 'OPTIONS': { 50 | 'context_processors': [ 51 | 'django.template.context_processors.debug', 52 | 'django.template.context_processors.request', 53 | 'django.contrib.auth.context_processors.auth', 54 | 'django.contrib.messages.context_processors.messages', 55 | ], 56 | }, 57 | }, 58 | ] 59 | 60 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 61 | 62 | # Password validation 63 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 64 | 65 | AUTH_PASSWORD_VALIDATORS = [ 66 | { 67 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 68 | }, 69 | { 70 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 71 | }, 72 | { 73 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 74 | }, 75 | { 76 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 77 | }, 78 | ] 79 | 80 | 81 | # Internationalization 82 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 83 | 84 | LANGUAGE_CODE = 'en-us' 85 | 86 | TIME_ZONE = 'UTC' 87 | 88 | USE_I18N = True 89 | 90 | USE_L10N = True 91 | 92 | USE_TZ = True 93 | 94 | 95 | # Static files (CSS, JavaScript, Images) 96 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 97 | 98 | STATIC_URL = '/static/' 99 | try: 100 | from elifinokuzu.local_settings import * 101 | except ImportError as e: 102 | print( 103 | ''' 104 | Local settings was not found. Duplicate local_settings.example and 105 | rename it to local_settings.py 106 | ''' 107 | ) 108 | except SyntaxError as e: 109 | print( 110 | ''' 111 | Local settings is misconfigured 112 | ''' 113 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | """elifinokuzu URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/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: path('', 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: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | from dictionary import views 19 | 20 | urlpatterns = [ 21 | path('', views.home, name="home"), 22 | path('about/', views.about, name="about"), 23 | path('support/', views.support, name="support"), 24 | path('node//', views.node_detail, name="node_detail"), 25 | path('admin/', admin.site.urls), 26 | ] 27 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/templates/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base_template.html" %} 2 | {% block title %} 3 | About 4 | {% endblock %} 5 | {% block content %} 6 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/templates/base_template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {% block title %} 7 | Default Title 8 | {% endblock %} 9 | 10 | 11 | 12 | 17 | {% block content %} 18 | {% endblock %} 19 | 20 | -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base_template.html" %} 2 | {% block title %} 3 | Home Page 4 | {% endblock %} 5 | {% block content %} 6 | {% for node in nodes %} 7 | {{ node }} 8 |
9 | {% endfor %} 10 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/templates/node_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base_template.html" %} 2 | {% block title %} 3 | {{node.name}} 4 | {% endblock %} 5 | {% block content %} 6 |

{{ node.name }}

7 | {% if incoming %} 8 |

Incoming

9 | {% for edge in incoming %} 10 | {{ edge }}
11 | {% endfor %} 12 | {% endif %} 13 | {% if outgoing %} 14 |

Outgoing

15 | {% for edge in outgoing %} 16 | {{ edge }}
17 | {% endfor %} 18 | {% endif %} 19 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 5/elifinokuzu/templates/support.html: -------------------------------------------------------------------------------- 1 | {% extends "base_template.html" %} 2 | {% block title %} 3 | Support 4 | {% endblock %} 5 | {% block content %} 6 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/authentication.md: -------------------------------------------------------------------------------- 1 | ### Authentication 2 | #### Login 3 | Django default authentication için *urls.py* sayfasına 4 | ```python 5 | from django.urls import path, include 6 | path('accounts/', include('django.contrib.auth.urls')), 7 | ``` 8 | eklenir 9 | Ardından *login.html* sayfası eklenmesi gerekmektedir 10 | ```python 11 | {% extends 'base.html' %} 12 | {% block title %}Login{% endblock %} 13 | 14 | {% block content %} 15 |

Login

16 |
17 | {% csrf_token %} 18 | {{ form.as_p }} 19 | 20 |
21 | {% endblock %} 22 | ``` 23 | 24 | Bir klasörü python paketine çevirmek için *__init__.py* eklemek gerekir 25 | 26 | #### Register 27 | 28 | ```python 29 | {% extends 'base.html' %} 30 | 31 | {% block content %} 32 |

Sign up

33 |
34 | {% csrf_token %} 35 | {{ form.as_p }} 36 | 37 |
38 | {% endblock %} 39 | ``` 40 | ```python 41 | from django.urls import path, include 42 | path('accounts/signup', account_views.signup, name='signup'), 43 | ``` 44 | #### Runtime da Pyhton debugger çalıştırmak için 45 | Debug yapılması istenen satıra; 46 | ```python 47 | import pdb; pdb.set_trace() 48 | ``` 49 | yazılır ve 50 | ```python 51 | python manage.py runserver 52 | ``` 53 | ile proje çalıştırıldığında terminalde shell çalışır ve bu sayede debug yapılabilir. -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 6/elifinokuzu/accounts/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 6/elifinokuzu/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import login, authenticate 2 | from django.contrib.auth.forms import UserCreationForm 3 | from django.shortcuts import render, redirect 4 | 5 | def signup(request): 6 | if request.method == 'POST': 7 | form = UserCreationForm(request.POST) 8 | if form.is_valid(): 9 | form.save() 10 | username = form.cleaned_data.get('username') 11 | raw_password = form.cleaned_data.get('password1') 12 | user = authenticate(username=username, password=raw_password) 13 | login(request, user) 14 | return redirect('home') 15 | else: 16 | form = UserCreationForm() 17 | return render(request, 'registration/signup.html', {'form': form}) 18 | 19 | def dashboard(request): 20 | return render(request, 'accounts/dashboard.html') -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 6/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node,Edge 3 | 4 | 5 | admin.site.register(Node) 6 | admin.site.register(Edge) -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import LANGUAGE_CHOICES, EDGE_TYPE_CHOICES 3 | 4 | 5 | class submission_form(forms.Form): 6 | source_language = forms.ChoiceField( 7 | choices=LANGUAGE_CHOICES, 8 | label='Source Language' 9 | ) 10 | 11 | source_node = forms.CharField( 12 | help_text="Example: Elif in Turkish language", 13 | max_length=255, 14 | label='Source Node' 15 | ) 16 | 17 | target_language = forms.ChoiceField( 18 | choices=LANGUAGE_CHOICES, 19 | label='Target Language', 20 | ) 21 | 22 | target_node = forms.CharField( 23 | help_text="Example: Alpha in Ancient Greek", 24 | max_length=255, 25 | label='Target Node' 26 | ) 27 | 28 | type_of_edge = forms.ChoiceField( 29 | widget=forms.RadioSelect(), 30 | choices=EDGE_TYPE_CHOICES, 31 | label='Type of edge' 32 | ) 33 | 34 | resource = forms.CharField( 35 | help_text="Example: Sevan Nişanyan's Elifin Öküzü", 36 | max_length=255, 37 | label='Resource' 38 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 15:30 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Node', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=255)), 19 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('de', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish')], max_length=255)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/migrations/0002_edge.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:13 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('dictionary', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Edge', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('is_directed', models.BooleanField()), 19 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 20 | ('destination', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node')), 21 | ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/migrations/0003_auto_20180726_1236.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-26 12:36 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dictionary', '0002_edge'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='edge', 15 | name='resource', 16 | field=models.CharField(blank=True, max_length=255, null=True), 17 | ), 18 | migrations.AlterField( 19 | model_name='node', 20 | name='language', 21 | field=models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('de', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish'), ('ar', 'Arabic')], max_length=255), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 6/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | LANGUAGE_CHOICES = ( 5 | ("tr", "Turkish"), 6 | ("fr", "French"), 7 | ("de", "German"), 8 | ("pl", "Polish"), 9 | ("kr", "Kurdish"), 10 | ("lt", "Latin"), 11 | ("en", "English"), 12 | ("es", "Spanish"), 13 | ("ar", "Arabic"), 14 | ) 15 | 16 | EDGE_TYPE_CHOICES = ( 17 | ("derives_from", "Derives from"), 18 | ("symbol_of", "Symbol of"), 19 | ("compound_of", "Compound of"), 20 | ) 21 | 22 | class Node(models.Model): 23 | """ 24 | Node (düğüm). 25 | The most base entity in the dictionary 26 | """ 27 | name = models.CharField(max_length = 255) 28 | language = models.CharField( 29 | max_length=255, 30 | choices=LANGUAGE_CHOICES 31 | ) 32 | 33 | def __str__(self): 34 | return self.name 35 | 36 | class Edge(models.Model): 37 | """ 38 | Edge (kenar) 39 | Holds the relationship between nodes 40 | """ 41 | source = models.ForeignKey( 42 | Node, 43 | related_name="incoming", 44 | on_delete=models.CASCADE, 45 | ) 46 | destination = models.ForeignKey( 47 | Node, 48 | related_name="outgoing", 49 | on_delete=models.CASCADE, 50 | ) 51 | is_directed = models.BooleanField() 52 | resource = models.CharField( 53 | max_length=255, 54 | blank=True, 55 | null=True, 56 | ) 57 | type_of_edge = models.CharField( 58 | max_length=255, 59 | choices=EDGE_TYPE_CHOICES 60 | ) 61 | def __str__(self): 62 | if self.is_directed: 63 | arrow = '---[%s]-->' % self.type_of_edge 64 | else: 65 | arrow = "<--[%s]-->" % self.type_of_edge 66 | return '(%s:%s) %s (%s:%s)' % ( 67 | self.source.language, 68 | self.source.name.lower(), 69 | arrow, 70 | self.destination.language, 71 | self.destination.name.lower() 72 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from dictionary.models import Node, Edge 3 | from dictionary.forms import submission_form 4 | from django.urls import reverse 5 | 6 | 7 | nodes = Node.objects.all() 8 | def home(request): 9 | return render(request, "home.html", { 10 | "title": "Öküzün Elifi", 11 | "nodes": nodes, 12 | }) 13 | 14 | def node_detail(request, id): 15 | node = Node.objects.get(id=id) 16 | incoming = node.incoming.all() 17 | outgoing = node.outgoing.all() 18 | 19 | return render(request, "node_detail.html", { 20 | "title": "Öküzün Elifi: %s" % node.name, 21 | "incoming": incoming, 22 | "outgoing": outgoing, 23 | "node": node, 24 | }) 25 | 26 | def about(request): 27 | return render(request, "about.html") 28 | 29 | def support(request): 30 | return render(request, "support.html") 31 | 32 | def submit(request): 33 | if request.method == 'POST': 34 | form = submission_form(request.POST) 35 | if form.is_valid(): 36 | source_node = Node.objects.create( 37 | name=form.cleaned_data['source_node'], 38 | language=form.cleaned_data['source_language'] 39 | ) 40 | target_node = Node.objects.create( 41 | name=form.cleaned_data['target_node'], 42 | language=form.cleaned_data['target_language'] 43 | ) 44 | type_of_edge = Edge.objects.create( 45 | source=source_node, 46 | destination=target_node, 47 | is_directed=False, 48 | type_of_edge=form.cleaned_data['type_of_edge'], 49 | resource=form.cleaned_data['resource'], 50 | ) 51 | return redirect(reverse("node_detail", args=[source_node.id])) 52 | else: 53 | form = submission_form() 54 | return render(request, "submit.html", {'form': form}) -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 6/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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 | # Application definition 19 | 20 | INSTALLED_APPS = [ 21 | 'django.contrib.admin', 22 | 'django.contrib.auth', 23 | 'django.contrib.contenttypes', 24 | 'django.contrib.sessions', 25 | 'django.contrib.messages', 26 | 'django.contrib.staticfiles', 27 | 'dictionary', 28 | ] 29 | 30 | MIDDLEWARE = [ 31 | 'django.middleware.security.SecurityMiddleware', 32 | 'django.contrib.sessions.middleware.SessionMiddleware', 33 | 'django.middleware.common.CommonMiddleware', 34 | 'django.middleware.csrf.CsrfViewMiddleware', 35 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 36 | 'django.contrib.messages.middleware.MessageMiddleware', 37 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 38 | ] 39 | 40 | ROOT_URLCONF = 'elifinokuzu.urls' 41 | 42 | TEMPLATES = [ 43 | { 44 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 45 | 'DIRS': [ 46 | os.path.join(BASE_DIR, "templates"), 47 | ], 48 | 'APP_DIRS': True, 49 | 'OPTIONS': { 50 | 'context_processors': [ 51 | 'django.template.context_processors.debug', 52 | 'django.template.context_processors.request', 53 | 'django.contrib.auth.context_processors.auth', 54 | 'django.contrib.messages.context_processors.messages', 55 | ], 56 | }, 57 | }, 58 | ] 59 | 60 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 61 | 62 | # Password validation 63 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 64 | 65 | AUTH_PASSWORD_VALIDATORS = [ 66 | { 67 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 68 | }, 69 | { 70 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 71 | }, 72 | { 73 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 74 | }, 75 | { 76 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 77 | }, 78 | ] 79 | 80 | 81 | # Internationalization 82 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 83 | 84 | LANGUAGE_CODE = 'en-us' 85 | 86 | TIME_ZONE = 'UTC' 87 | 88 | USE_I18N = True 89 | 90 | USE_L10N = True 91 | 92 | USE_TZ = True 93 | 94 | 95 | # Static files (CSS, JavaScript, Images) 96 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 97 | 98 | STATIC_DIR = os.path.join(BASE_DIR, 'static') 99 | STATIC_URL = '/static/' 100 | STATICFILES_DIRS = [ 101 | STATIC_DIR, 102 | ] 103 | try: 104 | from elifinokuzu.local_settings import * 105 | except ImportError as e: 106 | print( 107 | ''' 108 | Local settings was not found. Duplicate local_settings.example and 109 | rename it to local_settings.py 110 | ''' 111 | ) 112 | except SyntaxError as e: 113 | print( 114 | ''' 115 | Local settings is misconfigured 116 | ''' 117 | ) -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | """elifinokuzu URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/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: path('', 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: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | from dictionary import views as dictionary_views 19 | from accounts import views as account_views 20 | 21 | urlpatterns = [ 22 | path('', dictionary_views.home, name="home"), 23 | path('about/', dictionary_views.about, name="about"), 24 | path('support/', dictionary_views.support, name="support"), 25 | path('node//', dictionary_views.node_detail, name="node_detail"), 26 | path('admin/', admin.site.urls), 27 | path('accounts/', include('django.contrib.auth.urls')), 28 | path('accounts/signup', account_views.signup, name='signup'), 29 | path('accounts/profile/', account_views.dashboard, name='dashboard' ), 30 | path('submit/', dictionary_views.submit, name='submit'), 31 | ] 32 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/static/layout/styles/base.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: Helvetica; 3 | color: #444444; 4 | font-size: 9pt; 5 | background-color: #FAFAFA; 6 | } -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} 3 | About 4 | {% endblock %} 5 | {% block content %} 6 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/accounts/dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block content %} 3 |

Welcome {{ user.username }}

4 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/base.html: -------------------------------------------------------------------------------- 1 | {% block css %} 2 | {% load static %} 3 | 4 | {% endblock %} 5 | 6 | 7 | 8 | 9 | 10 | {% block title %} 11 | Default Title 12 | {% endblock %} 13 | 14 | 15 | 16 |
25 | {% block content %} 26 | {% endblock %} 27 | 28 | -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} 3 | Home Page 4 | {% endblock %} 5 | {% block content %} 6 | {% for node in nodes %} 7 | {{ node }} 8 |
9 | {% endfor %} 10 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/node_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} 3 | {{node.name}} 4 | {% endblock %} 5 | {% block content %} 6 |

{{ node.name }}

7 | {% if incoming %} 8 |

Incoming

9 | {% for edge in incoming %} 10 | {{ edge }}
11 | {% endfor %} 12 | {% endif %} 13 | {% if outgoing %} 14 |

Outgoing

15 | {% for edge in outgoing %} 16 | {{ edge }}
17 | {% endfor %} 18 | {% endif %} 19 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Login{% endblock %} 4 | 5 | {% block content %} 6 |

Login

7 |
8 | {% csrf_token %} 9 | {{ form.as_p }} 10 | 11 |
12 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/registration/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

Sign up

5 |
6 | {% csrf_token %} 7 | {{ form.as_p }} 8 | 9 |
10 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/submit.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} Submit Page {% endblock %} 3 | {% block content %} 4 |

Submit

5 |
6 | {% csrf_token %} 7 | {{ form.as_p }} 8 | 9 |
10 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/elifinokuzu/templates/support.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %} 3 | Support 4 | {% endblock %} 5 | {% block content %} 6 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 6/forms.md: -------------------------------------------------------------------------------- 1 | ### Formlar 2 | *forms.py* dosyası çalışması istenen app in içerisinde yaratılır ardından projeye uygun şekilde içeriği doldurulur. 3 | 4 | ```python 5 | from django import forms 6 | from .models import LANGUAGE_CHOICES, EDGE_TYPE_CHOICES 7 | 8 | 9 | class submission_form(forms.Form): 10 | source_language = forms.ChoiceField( 11 | choices=LANGUAGE_CHOICES, 12 | label='Source Language' 13 | ) 14 | 15 | source_node = forms.CharField( 16 | help_text="Example: Elif in Turkish language", 17 | max_length=255, 18 | label='Source Node' 19 | ) 20 | 21 | target_language = forms.ChoiceField( 22 | choices=LANGUAGE_CHOICES, 23 | label='Target Language', 24 | ) 25 | 26 | target_node = forms.CharField( 27 | help_text="Example: Alpha in Ancient Greek", 28 | max_length=255, 29 | label='Target Node' 30 | ) 31 | 32 | type_of_edge = forms.ChoiceField( 33 | widget=forms.RadioSelect(), 34 | choices=EDGE_TYPE_CHOICES, 35 | label='Type of edge' 36 | ) 37 | 38 | resource = forms.CharField( 39 | help_text="Example: Sevan Nişanyan's Elifin Öküzü", 40 | max_length=255, 41 | label='Resource' 42 | ) 43 | ``` 44 | Ardından *views.py* a ve *urls.py* a gerekli alanlar eklenir; 45 | 46 | *urls.py* 47 | ```python 48 | urlpatterns = [ 49 | path('', dictionary_views.home, name="home"), 50 | path('about/', dictionary_views.about, name="about"), 51 | path('support/', dictionary_views.support, name="support"), 52 | path('node//', dictionary_views.node_detail, name="node_detail"), 53 | path('admin/', admin.site.urls), 54 | path('accounts/', include('django.contrib.auth.urls')), 55 | path('accounts/signup', account_views.signup, name='signup'), 56 | path('accounts/profile/', account_views.submit.dashboard, name='dashboard' ), 57 | path('submit/', dictionary_views.submit, name='submit') #THIS 58 | ] 59 | ``` 60 | *views.py* 61 | ```python 62 | from forms import as submission_form 63 | from django.shortcuts import render, redirect 64 | from django.urls import reverse 65 | def submit(request): 66 | if request.method == 'POST': 67 | form = submission_form(request.POST) 68 | if form.is_valid(): 69 | source_node = Node.objects.create( 70 | name=form.cleaned_data['source_node'], 71 | language=form.cleaned_data['source_language'] 72 | ) 73 | target_node = Node.objects.create( 74 | name=form.cleaned_data['target_node'], 75 | language=form.cleaned_data['target_language'] 76 | ) 77 | type_of_edge = Edge.objects.create( 78 | source=source_node, 79 | destination=target_node, 80 | is_directed=False, 81 | type_of_edge=form.cleaned_data['type_of_edge'], 82 | resource=form.cleaned_data['resource'], 83 | ) 84 | return redirect(reverse("node_detail", args=[source_node.id])) 85 | else: 86 | form = submission_form() 87 | return render(request, "submit.html", {'form': form}) 88 | ``` -------------------------------------------------------------------------------- /DERSLER/GUN 6/static-css.md: -------------------------------------------------------------------------------- 1 | ### Base CSS Files 2 | *settings.py* dosyasına *STATICFILES_DIRS* adlı array(liste) eklenir ardından içine 3 | ```python 4 | STATICFILES_DIRS = [ 5 | os.path.join(BASE_DIR, 'static'), 6 | ] 7 | ``` 8 | eklenir. 9 | Ardından istenen konuma css dosyası yaratılır ve istenilen şekilde doldurulur. 10 | ```css 11 | * { 12 | font-family: Helvetica; 13 | /* Put your CSS here */ 14 | } 15 | ``` 16 | Daha sonra *base.html* e yada eklenmek istenilen html sayfasına *{% block css %}* şeklinde eklenir. 17 | ```html 18 | {% block css %} 19 | {% load static %} 20 | 21 | {% endblock %} 22 | ... 23 | ``` -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/accounts/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import login, authenticate 2 | from django.contrib.auth.forms import UserCreationForm 3 | from django.shortcuts import render, redirect 4 | 5 | def signup(request): 6 | if request.method == 'POST': 7 | form = UserCreationForm(request.POST) 8 | if form.is_valid(): 9 | form.save() 10 | username = form.cleaned_data.get('username') 11 | raw_password = form.cleaned_data.get('password1') 12 | user = authenticate(username=username, password=raw_password) 13 | login(request, user) 14 | return redirect('home') 15 | else: 16 | form = UserCreationForm() 17 | return render(request, 'registration/signup.html', {'form': form}) 18 | 19 | def dashboard(request): 20 | return render(request, 'accounts/dashboard.html') 21 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/comments/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Comment 3 | 4 | 5 | admin.site.register(Comment) -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CommentsConfig(AppConfig): 5 | name = 'comments' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Comment #Node, Edge 3 | 4 | class CommentForm(forms.ModelForm): 5 | 6 | class Meta: 7 | model = Comment 8 | fields = ('text',) -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 18:40 2 | 3 | import datetime 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | ('dictionary', '0005_auto_20180727_1146'), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Comment', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('user', models.CharField(max_length=200)), 22 | ('text', models.TextField()), 23 | ('created_date', models.DateTimeField(default=datetime.datetime.now)), 24 | ('approved_comment', models.BooleanField(default=False)), 25 | ('node', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='dictionary.Node')), 26 | ], 27 | ), 28 | ] 29 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0002_auto_20180727_2228.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 19:28 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('comments', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='comment', 17 | name='user', 18 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0003_auto_20180727_2253.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 19:53 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('comments', '0002_auto_20180727_2228'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='comment', 17 | name='created_date', 18 | field=models.DateTimeField(default='27/07/18 22:53'), 19 | ), 20 | migrations.AlterField( 21 | model_name='comment', 22 | name='user', 23 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0004_auto_20180727_2254.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 19:54 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('comments', '0003_auto_20180727_2253'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='comment', 15 | name='created_date', 16 | field=models.DateTimeField(default='27/07/18 22:54'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0005_auto_20180727_2130.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 21:30 2 | 3 | import datetime 4 | from django.db import migrations, models 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('comments', '0004_auto_20180727_2254'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='comment', 16 | name='created_date', 17 | field=models.DateTimeField(default=datetime.datetime(2018, 7, 27, 21, 30, 40, 463700)), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/0006_auto_20180727_2203.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 22:03 2 | 3 | from django.db import migrations, models 4 | import django.utils.timezone 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('comments', '0005_auto_20180727_2130'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='comment', 16 | name='created_date', 17 | field=models.DateTimeField(default=django.utils.timezone.now), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/comments/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/models.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from django.db import models 3 | from django.conf import settings 4 | from django.utils import timezone 5 | 6 | class Comment(models.Model): 7 | node = models.ForeignKey('dictionary.Node', on_delete=models.CASCADE, related_name='comments') 8 | user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) 9 | text = models.TextField() 10 | created_date = models.DateTimeField(default=timezone.now) 11 | approved_comment = models.BooleanField(default=False) 12 | 13 | def approve(self): 14 | self.approved_comment = True 15 | self.save() 16 | 17 | def __str__(self): 18 | return str(self.node) + ": " + str(self.text) 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/comments/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404, redirect 2 | from .forms import CommentForm 3 | from dictionary.models import Node 4 | 5 | def add_comment_to_node(request, id): 6 | node = get_object_or_404(Node.objects.filter(pk=id)) 7 | if request.method == "POST": 8 | form = CommentForm(request.POST) 9 | if form.is_valid(): 10 | comment = form.save(commit=False) 11 | comment.node = node 12 | comment.user = request.user 13 | comment.save() 14 | return redirect('node_detail', node.id) 15 | else: 16 | form = CommentForm() 17 | return render(request, 'comments/add_comment_to_node.html', {'form': form}) 18 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/crawler/management/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/crawler/management/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/crawler/management/commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/crawler/management/commands/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/crawler/management/commands/crawler.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import requests 3 | from dictionary.models import Node,Edge 4 | from django.core.management import BaseCommand 5 | 6 | class Command(BaseCommand): 7 | 8 | def __init__(self): 9 | self.main_url = "https://www.etimolojiturkce.com/kelime/{}" 10 | self.word = "" 11 | 12 | def add_arguments(self, parser): 13 | parser.add_argument('word', type=str) 14 | parser.add_argument('') 15 | 16 | def origin_crawler(self,word): 17 | webpage = requests.get(self.main_url.format(word).lower()) 18 | content = webpage.content 19 | if webpage.status_code == 404: 20 | return None 21 | soup = BeautifulSoup(content,"lxml") 22 | origin_language = soup.find('h2',{"id" : "koken"}) 23 | origin_language = str(origin_language.find_next_sibling('p')) 24 | first = origin_language.find("")+3 25 | end = origin_language.find("") 26 | origin_language = origin_language[first:end] 27 | self.origin_word(soup) 28 | return origin_language,self.word 29 | 30 | def origin_word(self,html): 31 | origin = html.find('span',{"class" : "ety2"}).get_text() 32 | origin2 = html.find('span',{'class' :"ety4"}).get_text() 33 | self.word = str(origin)+" "+str(origin2) 34 | 35 | def new_node(self,node_name="null",node_lang="null"): 36 | n = Node.objects.get_or_create(name=node_name,language=node_lang)[0] 37 | n.save() 38 | 39 | def new_edge(self,destination,source): 40 | e = Edge.objects.get_or_create\ 41 | ( 42 | source=Node.objects.get(name=source), 43 | destination=Node.objects.get(name=destination), 44 | type_of_edge= "derives_from", 45 | is_directed = True, 46 | )[0] 47 | e.save() 48 | 49 | def handle(self, *args, **options): 50 | word = options['word'] 51 | try: 52 | destination,origin = self.origin_crawler(word) 53 | except TypeError: 54 | print("404 Not Found.") 55 | return None 56 | if origin.startswith("+"): # when the word dont have a origin. 57 | print("Skipped",word) 58 | return None 59 | self.new_node(word,"tr") 60 | self.new_node(origin,destination) 61 | self.new_edge(origin,word) 62 | print("Added",word) -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node 3 | from dictionary.models import Edge 4 | 5 | 6 | admin.site.register(Node) 7 | admin.site.register(Edge) 8 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import LANGUAGE_CHOICES, EDGE_TYPE_CHOICES 3 | from django.utils.translation import ugettext_lazy as _ 4 | #from captcha.fields import ReCaptchaField 5 | 6 | class SubmissionForm(forms.Form): 7 | source_language = forms.ChoiceField( 8 | choices=LANGUAGE_CHOICES, 9 | label=_('Source Language'), 10 | ) 11 | source_node = forms.CharField( 12 | help_text=_("Example: Elif in Turkish language"), 13 | max_length=255, 14 | label=_('Source Node'), 15 | ) 16 | target_language = forms.ChoiceField( 17 | choices=LANGUAGE_CHOICES, 18 | label=_('Target Language'), 19 | ) 20 | target_node = forms.CharField( 21 | help_text=_("Example: Alpha in Ancient Greek"), 22 | max_length=255, 23 | label=_('Target Node'), 24 | ) 25 | type_of_edge = forms.ChoiceField( 26 | widget=forms.RadioSelect(), 27 | choices=EDGE_TYPE_CHOICES, 28 | label=_('Type of Edge'), 29 | ) 30 | resource = forms.CharField( 31 | help_text=_("Example: Sevan Nişanyan's Elifin Öküzü"), 32 | max_length=255, 33 | label=_('Resource'), 34 | ) 35 | #captcha = ReCaptchaField() 36 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 15:30 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Node', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=255)), 19 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('gr', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish')], max_length=255)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/0002_edge.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:13 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('dictionary', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Edge', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('is_directed', models.BooleanField()), 19 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 20 | ('destination', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node')), 21 | ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/0003_auto_20180722_1650.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-22 16:50 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dictionary', '0002_edge'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='node', 15 | name='language', 16 | field=models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('gr', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish'), ('ar', 'Arabic')], max_length=255), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/0004_edge_resource.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.1 on 2018-07-26 12:21 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('dictionary', '0003_auto_20180722_1650'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='edge', 15 | name='resource', 16 | field=models.CharField(blank=True, max_length=255, null=True), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/0005_auto_20180727_1146.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-27 11:46 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 12 | ('dictionary', '0004_edge_resource'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AddField( 17 | model_name='edge', 18 | name='user', 19 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 20 | ), 21 | migrations.AddField( 22 | model_name='node', 23 | name='user', 24 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.conf import settings 3 | from django.utils.translation import ugettext_lazy as _ 4 | 5 | 6 | LANGUAGE_CHOICES = ( 7 | ('tr', _('Turkish')), 8 | ('fr', _('French')), 9 | ('gr', _('German')), 10 | ('pl', _('Polish')), 11 | ('kr', _('Kurdish')), 12 | ('lt', _('Latin')), 13 | ('en', _('English')), 14 | ('es', _('Spanish')), 15 | ('ar', _('Arabic')), 16 | ) 17 | 18 | EDGE_TYPE_CHOICES = ( 19 | ('derives_from', _('Derives from')), 20 | ('symbol_of', _('Symbol of')), 21 | ('compound_of', _('Compound of')), 22 | ) 23 | 24 | 25 | class Node(models.Model): 26 | """ 27 | Node (düğüm) 28 | The most base entity in the dictionary 29 | """ 30 | user = models.ForeignKey( 31 | settings.AUTH_USER_MODEL, 32 | null=True, 33 | on_delete=models.CASCADE, 34 | ) 35 | name = models.CharField(max_length=255) 36 | language = models.CharField( 37 | max_length=255, 38 | choices=LANGUAGE_CHOICES 39 | ) 40 | 41 | def __str__(self): 42 | return self.name 43 | 44 | 45 | class Edge(models.Model): 46 | """ 47 | Holds the relationships between nodes. 48 | """ 49 | user = models.ForeignKey( 50 | settings.AUTH_USER_MODEL, 51 | null=True, 52 | on_delete=models.CASCADE, 53 | ) 54 | source = models.ForeignKey( 55 | Node, 56 | related_name='incoming', 57 | on_delete=models.CASCADE, 58 | ) 59 | destination = models.ForeignKey( 60 | Node, 61 | related_name='outgoing', 62 | on_delete=models.CASCADE, 63 | ) 64 | is_directed = models.BooleanField() 65 | resource = models.CharField( 66 | max_length=255, 67 | blank=True, 68 | null=True, 69 | ) 70 | type_of_edge = models.CharField( 71 | max_length=255, 72 | choices=EDGE_TYPE_CHOICES 73 | ) 74 | 75 | def __str__(self): 76 | if self.is_directed: 77 | arrow = '---[%s]-->' % self.type_of_edge 78 | else: 79 | arrow = '<--[%s]-->' % self.type_of_edge 80 | 81 | return '(%s:%s) %s (%s:%s)' % ( 82 | self.source.language, 83 | self.source.name.lower(), 84 | arrow, 85 | self.destination.language, 86 | self.destination.name.lower(), 87 | ) 88 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | import random 2 | from django.shortcuts import render, redirect 3 | from dictionary.models import Node, Edge 4 | from .forms import SubmissionForm 5 | from django.urls import reverse 6 | 7 | 8 | def home(request): 9 | nodes = Node.objects.all() 10 | 11 | if len(Node.objects.all()) > 0: 12 | random_word = random.choice(Node.objects.all()).id 13 | else: 14 | random_word = "None" 15 | 16 | return render(request, 'home.html', { 17 | 'title': 'Öküzün Elifi', 18 | 'nodes': nodes, 19 | 'random_word': random_word, 20 | }) 21 | 22 | def node_detail(request, id): 23 | node = Node.objects.get(id=id) 24 | incoming = node.incoming.all() 25 | outgoing = node.outgoing.all() 26 | return render(request, 'node_detail.html', { 27 | 'node': node, 28 | 'incoming': incoming, 29 | 'outgoing': outgoing, 30 | 'title': 'Öküzün Elifi: %s' % node.name, 31 | }) 32 | 33 | def about(request): 34 | return render(request, 'about.html') 35 | 36 | def support(request): 37 | return render(request, 'support.html') 38 | 39 | def submit(request): 40 | form = SubmissionForm() 41 | 42 | if request.method == "POST": 43 | form = SubmissionForm(request.POST) 44 | 45 | if form.is_valid(): 46 | source_node = Node.objects.create( 47 | name=form.cleaned_data['source_node'], 48 | language=form.cleaned_data['source_language'], 49 | user=request.user, 50 | 51 | ) 52 | target_node = Node.objects.create( 53 | name=form.cleaned_data['target_node'], 54 | language=form.cleaned_data['target_language'], 55 | user=request.user, 56 | ) 57 | edge = Edge.objects.create( 58 | source=source_node, 59 | destination=target_node, 60 | is_directed=False, 61 | type_of_edge=form.cleaned_data['type_of_edge'], 62 | resource=form.cleaned_data['resource'], 63 | user=request.user, 64 | ) 65 | 66 | return redirect(reverse("node_detail", args=[source_node.id])) 67 | return render(request, 'submit.html',{"form" : form}) 68 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.utils.translation import ugettext_lazy as _ 15 | 16 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 17 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18 | 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 22 | 23 | # Application definition 24 | 25 | INSTALLED_APPS = [ 26 | 'django.contrib.admin', 27 | 'django.contrib.auth', 28 | 'django.contrib.contenttypes', 29 | 'django.contrib.sessions', 30 | 'django.contrib.messages', 31 | 'django.contrib.staticfiles', 32 | 'dictionary', 33 | 'crawler', 34 | 'captcha', 35 | 'comments', 36 | ] 37 | 38 | MIDDLEWARE = [ 39 | 'django.middleware.security.SecurityMiddleware', 40 | 'django.contrib.sessions.middleware.SessionMiddleware', 41 | 'django.middleware.common.CommonMiddleware', 42 | 'django.middleware.csrf.CsrfViewMiddleware', 43 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 44 | 'django.contrib.messages.middleware.MessageMiddleware', 45 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 46 | 'django.middleware.locale.LocaleMiddleware', 47 | ] 48 | 49 | ROOT_URLCONF = 'elifinokuzu.urls' 50 | 51 | TEMPLATES = [ 52 | { 53 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 54 | 'DIRS': [ 55 | os.path.join(BASE_DIR, 'templates'), 56 | ], 57 | 'APP_DIRS': True, 58 | 'OPTIONS': { 59 | 'context_processors': [ 60 | 'django.template.context_processors.debug', 61 | 'django.template.context_processors.request', 62 | 'django.contrib.auth.context_processors.auth', 63 | 'django.contrib.messages.context_processors.messages', 64 | ], 65 | }, 66 | }, 67 | ] 68 | 69 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 70 | 71 | # Password validation 72 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 73 | 74 | AUTH_PASSWORD_VALIDATORS = [ 75 | { 76 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 77 | }, 78 | { 79 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 80 | }, 81 | { 82 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 83 | }, 84 | { 85 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 86 | }, 87 | ] 88 | 89 | 90 | # Internationalization 91 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 92 | 93 | LANGUAGE_CODE = 'en-us' 94 | 95 | LANGUAGES = ( 96 | ('en', _('English')), 97 | ('tr', _('Turkish')), 98 | ) 99 | 100 | LOCALE_PATHS = ( 101 | os.path.join(BASE_DIR, 'locale'), 102 | ) 103 | 104 | TIME_ZONE = 'UTC' 105 | 106 | USE_I18N = True 107 | 108 | USE_L10N = True 109 | 110 | USE_TZ = True 111 | 112 | 113 | # Static files (CSS, JavaScript, Images) 114 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 115 | STATIC_DIR = os.path.join(BASE_DIR, 'static') 116 | STATIC_URL = '/static/' 117 | STATICFILES_DIRS= [ 118 | STATIC_DIR, 119 | ] 120 | LOGOUT_REDIRECT_URL = '/' 121 | 122 | try: 123 | from elifinokuzu.local_settings import * 124 | except ImportError: 125 | print( 126 | ''' 127 | Local settings was not found. Duplicate local_settings.example and 128 | rename it to local_settings.py 129 | ''' 130 | ) 131 | except SyntaxError: 132 | print( 133 | ''' 134 | Local settings is misconfigured. 135 | ''' 136 | ) 137 | NOCAPTCHA = True 138 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | from dictionary import views as dictionary_views 4 | from accounts import views as account_views 5 | from comments import views as comment_views 6 | 7 | urlpatterns = [ 8 | path('', dictionary_views.home, name='home'), 9 | path('about/', dictionary_views.about, name='about'), 10 | path('support/', dictionary_views.support, name='support'), 11 | path('admin/', admin.site.urls), 12 | path('nodes//', dictionary_views.node_detail, name='node_detail'), 13 | path('accounts/', include('django.contrib.auth.urls')), 14 | path('accounts/signup/', account_views.signup, name='signup'), 15 | path('accounts/profile/', account_views.dashboard, name='dashboard'), 16 | path('submit/', dictionary_views.submit, name='submit' ), 17 | path('nodes//comment/', comment_views.add_comment_to_node, name='add_comment_to_node'), 18 | ] 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/static/favicon.ico -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/static/layout/styles/base.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: helvetica, sans-serif; 3 | font-size: 1.4em; 4 | } 5 | .info{ 6 | display: block; 7 | padding: 10px; 8 | letter-spacing: 1px; 9 | } 10 | .warning{ 11 | background-color: #fcf8e3; 12 | border:1px solid #faebcc; 13 | color: #333; 14 | } 15 | .container { 16 | width: 37em; 17 | margin: auto; 18 | } 19 | 20 | header { 21 | text-align: center; 22 | } 23 | 24 | #logo img { 25 | width: 190px; 26 | } 27 | 28 | nav { 29 | background: #e6fff7; 30 | padding: 0.6em; 31 | } 32 | 33 | nav a { 34 | color: black; 35 | } 36 | 37 | .content { 38 | padding: 1em 0; 39 | color: #404040; 40 | } 41 | 42 | nav a { 43 | float: right; 44 | display: inline-block; 45 | padding: 0 5px; 46 | } 47 | 48 | footer { 49 | background: lightgray; 50 | padding: 0.6em; 51 | } 52 | 53 | .content h3 { 54 | margin: 0; 55 | padding: 0.4em 1em; 56 | font-weight: normal; 57 | color: #464646; 58 | } 59 | 60 | /* Story — Relationship */ 61 | .story-relationship { 62 | border: 3px solid #f3f3f3; 63 | border-left: 0; 64 | border-right: 0; 65 | border-bottom: 0; 66 | padding: 1em; 67 | } 68 | 69 | .story-relationship a { 70 | text-decoration: underline; 71 | color: black; 72 | } 73 | 74 | /* Django */ 75 | label { 76 | display: block; 77 | } 78 | 79 | input { 80 | font-size: 1.2em; 81 | border: 3px solid yellow; 82 | outline: none; 83 | margin: 2px 0; 84 | } 85 | 86 | input:focus { 87 | border: 3px solid black; 88 | } 89 | 90 | select { 91 | font-size: 1.2em; 92 | margin: 2px 0; 93 | } 94 | 95 | form ul li { 96 | list-style: none; 97 | } 98 | 99 | form ul { 100 | padding: 0 10px; 101 | } 102 | 103 | .helptext { 104 | color: darkgray; 105 | display: block; 106 | } 107 | 108 | button { 109 | font-size: 1.2em; 110 | padding: 0.3em 0.8em; 111 | } 112 | 113 | /* Heading sets */ 114 | 115 | *, *:after, *:before { 116 | box-sizing: border-box; 117 | } 118 | 119 | h1 { 120 | font-size: 36px; 121 | line-height: 40px; 122 | } 123 | 124 | h2 { 125 | font-size: 35px; 126 | line-height: 40px; 127 | border-bottom: 3px solid yellow; 128 | font-weight: normal; 129 | text-align: center; 130 | padding: 0 0 10px; 131 | } 132 | 133 | h3 { 134 | font-size: 24px; 135 | line-height: 40px; 136 | } 137 | 138 | h4 { 139 | font-size: 18px; 140 | line-height: 20px; 141 | } 142 | 143 | h5 { 144 | font-size: 14px; 145 | line-height: 20px; 146 | } 147 | 148 | h6 { 149 | font-size: 12px; 150 | line-height: 20px; 151 | } 152 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 7/elifinokuzu/static/logo.png -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}About{% endblock %} 3 | ABOUTTT 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/accounts/dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Welcome' %} {{ user.username }}

6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | {% load i18n %} 5 | 6 | 7 | 8 | 9 | {% block title %} Default Title{% endblock %} 10 | 11 | 12 |
13 |
14 | 20 |
21 | 33 |
34 | {% block content %} 35 | lorem ipsum dolor sit amet 36 | {% endblock %} 37 |
38 |
39 | {% trans 'elifinokuzu is an open-source etymological dictionary. Support us on github.' %} 40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/comments/add_comment_to_node.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

New comment

5 |
{% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{% trans 'Home Page' %}{% endblock %} 5 | {% block content %} 6 | {% for node in nodes %} 7 |
8 |

{{ node.name }}

9 |

{{ node.language }}

10 | Comments: {{ node.comments.count }}

11 |
12 | {% endfor %} 13 | {% if random_word != "None" %} 14 | {% trans 'GET A RANDOM WORD' %}
15 | {% else %} 16 |

{% trans 'Database is EMPTY' %}

17 | {% endif %} 18 | {% endblock %} 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/node_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{{ node.name }}{% endblock %} 5 | {% block content %} 6 |

{{ node.name }}

7 | {% if incoming %} 8 |

Incoming

9 | {% for edge in incoming %} 10 | {{ edge }} 11 | {% endfor %} 12 | {% endif %} 13 | {% if outgoing %} 14 |

Outgoing

15 | {% for edge in outgoing %} 16 | {{ edge }} 17 | {% endfor %} 18 | {% endif %} 19 |

Add comment

20 | {% for comment in node.comments.all %} 21 |
22 |

{{ comment.user }}:

23 |

{{ comment.text }}

24 |
{{ comment.created_date|date:"d M, Y" }}
25 |
26 |
27 | {% empty %} 28 |

No comments here yet :(

29 | {% endfor %} 30 | 31 | {% endblock %} 32 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Login' %}

6 |
7 | {% csrf_token %} 8 | {{ form.as_p }} 9 | 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/registration/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Sign up' %}

6 |
7 | {% csrf_token %} 8 | {{ form.as_p }} 9 | 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/submit.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{% trans 'Submit Page' %}{% endblock %} 5 | {% block content %} 6 |

{% trans 'Submit' %}

7 | {% if user.is_anonymous %} 8 |
9 | {% trans 'Please login for creating a new record.' %} 10 |
11 | {% else %} 12 |
13 | {% csrf_token %} 14 | {{ form.as_p }} 15 | 16 |
17 | {% endif %} 18 | {% endblock %} 19 | -------------------------------------------------------------------------------- /DERSLER/GUN 7/elifinokuzu/templates/support.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Support{% endblock %} 3 | 4 | SUPPORT US PLX 5 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/accounts/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | # Register your models here. 3 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/forms.py: -------------------------------------------------------------------------------- 1 | 2 | from django import forms 3 | from django.contrib.auth.models import User 4 | from django.contrib.auth.forms import UserCreationForm 5 | from captcha.fields import ReCaptchaField 6 | 7 | class CustomUserCreationForm(UserCreationForm): 8 | email=forms.EmailField(required=True) 9 | captcha = ReCaptchaField() 10 | class Meta: 11 | model=User 12 | fields=("username","email") 13 | def save(self, commit=True): 14 | user = super(UserExtendedCreationForm, self).save(commit=False) # type: object 15 | user.email = self.cleaned_data["email"] 16 | if commit: 17 | user.save() 18 | return user 19 | 20 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import login, authenticate 2 | from django.shortcuts import render, redirect 3 | from .forms import CustomUserCreationForm 4 | 5 | def signup(request): 6 | if request.method == 'POST': 7 | form = CustomUserCreationForm(request.POST) 8 | if form.is_valid(): 9 | form.save() 10 | username = form.cleaned_data.get('username') 11 | raw_password = form.cleaned_data.get('password1') 12 | email=form.cleaned_data.get('email') 13 | user = authenticate(username=username,password=raw_password,email=email) 14 | login(request, user) 15 | return redirect('home') 16 | else: 17 | form = CustomUserCreationForm() 18 | return render(request, 'registration/signup.html', {'form': form}) 19 | 20 | def dashboard(request): 21 | return render(request, 'accounts/dashboard.html') 22 | 23 | def support(request): 24 | return render(request, 'support.html') -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/comments/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Comment_To_Node, Comment_To_Edge 3 | 4 | 5 | admin.site.register(Comment_To_Node) 6 | admin.site.register(Comment_To_Edge) -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CommentsConfig(AppConfig): 5 | name = 'comments' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Comment_To_Node, Comment_To_Edge #Node, Edge 3 | from captcha.fields import ReCaptchaField 4 | 5 | class CommentFormForNode(forms.ModelForm): 6 | captcha = ReCaptchaField() 7 | class Meta: 8 | model = Comment_To_Node 9 | fields = ('text',) 10 | 11 | class CommentFormForEdge(forms.ModelForm): 12 | captcha = ReCaptchaField() 13 | class Meta: 14 | model = Comment_To_Edge 15 | fields = ('text',) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-28 12:27 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | import django.utils.timezone 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | initial = True 12 | 13 | dependencies = [ 14 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 15 | ('dictionary', '0001_initial'), 16 | ] 17 | 18 | operations = [ 19 | migrations.CreateModel( 20 | name='Comment_To_Edge', 21 | fields=[ 22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 23 | ('text', models.TextField()), 24 | ('created_date', models.DateTimeField(default=django.utils.timezone.now)), 25 | ('approved_comment', models.BooleanField(default=False)), 26 | ('edge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments_edge', to='dictionary.Edge')), 27 | ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 28 | ], 29 | ), 30 | migrations.CreateModel( 31 | name='Comment_To_Node', 32 | fields=[ 33 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 34 | ('text', models.TextField()), 35 | ('created_date', models.DateTimeField(default=django.utils.timezone.now)), 36 | ('approved_comment', models.BooleanField(default=False)), 37 | ('node', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments_node', to='dictionary.Node')), 38 | ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 39 | ], 40 | ), 41 | ] 42 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/comments/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/models.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from django.db import models 3 | from django.conf import settings 4 | from django.utils import timezone 5 | 6 | class Comment_To_Node(models.Model): 7 | node = models.ForeignKey('dictionary.Node', on_delete=models.CASCADE, related_name='comments_node') 8 | user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) 9 | text = models.TextField() 10 | created_date = models.DateTimeField(default=timezone.now) 11 | approved_comment = models.BooleanField(default=False) 12 | 13 | def approve(self): 14 | self.approved_comment = True 15 | self.save() 16 | 17 | def __str__(self): 18 | return str(self.node) + ": " + str(self.text) 19 | 20 | class Comment_To_Edge(models.Model): 21 | edge = models.ForeignKey('dictionary.Edge', on_delete=models.CASCADE, related_name='comments_edge') 22 | user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) 23 | text = models.TextField() 24 | created_date = models.DateTimeField(default=timezone.now) 25 | approved_comment = models.BooleanField(default=False) 26 | 27 | def approve(self): 28 | self.approved_comment = True 29 | self.save() 30 | 31 | def __str__(self): 32 | return str(self.edge) + ": " + str(self.text) 33 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/comments/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404, redirect 2 | from .forms import CommentFormForNode, CommentFormForEdge 3 | from dictionary.models import Node, Edge 4 | 5 | def add_comment_to_node(request, id): 6 | node = get_object_or_404(Node.objects.filter(pk=id)) 7 | if request.method == "POST": 8 | form = CommentFormForNode(request.POST) 9 | if form.is_valid(): 10 | comment = form.save(commit=False) 11 | comment.node = node 12 | comment.user = request.user 13 | comment.save() 14 | return redirect('node_detail', node.id) 15 | else: 16 | form = CommentFormForNode() 17 | return render(request, 'comments/add_comment_to_node.html', {'form': form}) 18 | 19 | def add_comment_to_edge(request, id): 20 | edge = get_object_or_404(Edge.objects.filter(pk=id)) 21 | if request.method == "POST": 22 | form = CommentFormForEdge(request.POST) 23 | if form.is_valid(): 24 | comment = form.save(commit=False) 25 | comment.edge = edge 26 | comment.user = request.user 27 | comment.save() 28 | return redirect('edge_detail', edge.id) 29 | else: 30 | form = CommentFormForEdge() 31 | return render(request, 'comments/add_comment_to_edge.html', {'form': form}) 32 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/crawler/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/crawler/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/crawler/management/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/crawler/management/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/crawler/management/commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/crawler/management/commands/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/crawler/management/commands/crawler.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import requests 3 | from dictionary.models import Node,Edge 4 | from django.core.management import BaseCommand 5 | 6 | class Command(BaseCommand): 7 | 8 | help = 'Crawling data from etimolojiksozluk' 9 | 10 | def __init__(self, *args ,**kwargs): 11 | super().__init__(*args, **kwargs) 12 | self.main_url = "https://www.etimolojiturkce.com/kelime/{}" 13 | self.word = "" 14 | 15 | def add_arguments(self, parser): 16 | parser.add_argument('word', type=str) 17 | 18 | def origin_crawler(self,word): 19 | webpage = requests.get(self.main_url.format(word).lower()) 20 | content = webpage.content 21 | if webpage.status_code == 404: 22 | return None 23 | soup = BeautifulSoup(content,"lxml") 24 | origin_language = soup.find('h2',{"id" : "koken"}) 25 | origin_language = str(origin_language.find_next_sibling('p')) 26 | first = origin_language.find("")+3 27 | end = origin_language.find("") 28 | origin_language = origin_language[first:end] 29 | self.origin_word(soup) 30 | return origin_language,self.word 31 | 32 | def origin_word(self,html): 33 | origin = html.find('span',{"class" : "ety2"}).get_text() 34 | origin2 = html.find('span',{'class' :"ety4"}).get_text() 35 | self.word = str(origin)+" "+str(origin2) 36 | 37 | def new_node(self,node_name="null",node_lang="null"): 38 | n = Node.objects.get_or_create(name=node_name,language=node_lang)[0] 39 | n.save() 40 | 41 | def new_edge(self,destination,source): 42 | e = Edge.objects.get_or_create\ 43 | ( 44 | source=Node.objects.get(name=source), 45 | destination=Node.objects.get(name=destination), 46 | type_of_edge= "derives_from", 47 | is_directed = True, 48 | )[0] 49 | e.save() 50 | 51 | def handle(self, *args, **options): 52 | word = options['word'] 53 | try: 54 | destination,origin = self.origin_crawler(word) 55 | except TypeError: 56 | print("404 Not Found.") 57 | return None 58 | if origin.startswith("+"): # when the word dont have a origin. 59 | print("Skipped",word) 60 | return None 61 | self.new_node(word,"tr") 62 | self.new_node(origin,destination) 63 | self.new_edge(origin,word) 64 | print("Added",word) -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/dictionary/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from dictionary.models import Node 3 | from dictionary.models import Edge 4 | 5 | 6 | admin.site.register(Node) 7 | admin.site.register(Edge) 8 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | name = 'dictionary' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import LANGUAGE_CHOICES, EDGE_TYPE_CHOICES 3 | from django.utils.translation import ugettext_lazy as _ 4 | from captcha.fields import ReCaptchaField 5 | 6 | class SubmissionForm(forms.Form): 7 | source_language = forms.ChoiceField( 8 | choices=LANGUAGE_CHOICES, 9 | label=_('Source Language'), 10 | ) 11 | source_node = forms.CharField( 12 | help_text=_("Example: Elif in Turkish language"), 13 | max_length=255, 14 | label=_('Source Node'), 15 | ) 16 | target_language = forms.ChoiceField( 17 | choices=LANGUAGE_CHOICES, 18 | label=_('Target Language'), 19 | ) 20 | target_node = forms.CharField( 21 | help_text=_("Example: Alpha in Ancient Greek"), 22 | max_length=255, 23 | label=_('Target Node'), 24 | ) 25 | type_of_edge = forms.ChoiceField( 26 | widget=forms.RadioSelect(), 27 | choices=EDGE_TYPE_CHOICES, 28 | label=_('Type of Edge'), 29 | ) 30 | resource = forms.CharField( 31 | help_text=_("Example: Sevan Nişanyan's Elifin Öküzü"), 32 | max_length=255, 33 | label=_('Resource'), 34 | ) 35 | captcha = ReCaptchaField() 36 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-28 12:27 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Edge', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('is_directed', models.BooleanField()), 22 | ('resource', models.CharField(blank=True, max_length=255, null=True)), 23 | ('type_of_edge', models.CharField(choices=[('derives_from', 'Derives from'), ('symbol_of', 'Symbol of'), ('compound_of', 'Compound of')], max_length=255)), 24 | ], 25 | ), 26 | migrations.CreateModel( 27 | name='Node', 28 | fields=[ 29 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 30 | ('name', models.CharField(max_length=255, unique=True)), 31 | ('language', models.CharField(choices=[('tr', 'Turkish'), ('fr', 'French'), ('gr', 'German'), ('pl', 'Polish'), ('kr', 'Kurdish'), ('lt', 'Latin'), ('en', 'English'), ('es', 'Spanish'), ('ar', 'Arabic')], max_length=255)), 32 | ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 33 | ], 34 | ), 35 | migrations.AddField( 36 | model_name='edge', 37 | name='destination', 38 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outgoing', to='dictionary.Node'), 39 | ), 40 | migrations.AddField( 41 | model_name='edge', 42 | name='source', 43 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='incoming', to='dictionary.Node'), 44 | ), 45 | migrations.AddField( 46 | model_name='edge', 47 | name='user', 48 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 49 | ), 50 | ] 51 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/dictionary/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.conf import settings 3 | from django.utils.translation import ugettext_lazy as _ 4 | 5 | 6 | LANGUAGE_CHOICES = ( 7 | ('tr', _('Turkish')), 8 | ('fr', _('French')), 9 | ('gr', _('German')), 10 | ('pl', _('Polish')), 11 | ('kr', _('Kurdish')), 12 | ('lt', _('Latin')), 13 | ('en', _('English')), 14 | ('es', _('Spanish')), 15 | ('ar', _('Arabic')), 16 | ) 17 | 18 | EDGE_TYPE_CHOICES = ( 19 | ('derives_from', _('Derives from')), 20 | ('symbol_of', _('Symbol of')), 21 | ('compound_of', _('Compound of')), 22 | ) 23 | 24 | 25 | class Node(models.Model): 26 | """ 27 | Node (düğüm) 28 | The most base entity in the dictionary 29 | """ 30 | user = models.ForeignKey( 31 | settings.AUTH_USER_MODEL, 32 | null=True, 33 | on_delete=models.CASCADE, 34 | ) 35 | name = models.CharField(max_length=255, unique=True) 36 | language = models.CharField( 37 | max_length=255, 38 | choices=LANGUAGE_CHOICES 39 | ) 40 | 41 | def __str__(self): 42 | return self.name 43 | 44 | 45 | class Edge(models.Model): 46 | """ 47 | Holds the relationships between nodes. 48 | """ 49 | user = models.ForeignKey( 50 | settings.AUTH_USER_MODEL, 51 | null=True, 52 | on_delete=models.CASCADE, 53 | ) 54 | source = models.ForeignKey( 55 | Node, 56 | related_name='incoming', 57 | on_delete=models.CASCADE, 58 | ) 59 | destination = models.ForeignKey( 60 | Node, 61 | related_name='outgoing', 62 | on_delete=models.CASCADE, 63 | ) 64 | is_directed = models.BooleanField() 65 | resource = models.CharField( 66 | max_length=255, 67 | blank=True, 68 | null=True, 69 | ) 70 | type_of_edge = models.CharField( 71 | max_length=255, 72 | choices=EDGE_TYPE_CHOICES 73 | ) 74 | 75 | def __str__(self): 76 | if self.is_directed: 77 | arrow = '---[%s]-->' % self.type_of_edge 78 | else: 79 | arrow = '<--[%s]-->' % self.type_of_edge 80 | 81 | return '(%s:%s) %s (%s:%s)' % ( 82 | self.source.language, 83 | self.source.name.lower(), 84 | arrow, 85 | self.destination.language, 86 | self.destination.name.lower(), 87 | ) 88 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/dictionary/views.py: -------------------------------------------------------------------------------- 1 | import random 2 | from django.shortcuts import render, redirect 3 | from dictionary.models import Node, Edge 4 | from .forms import SubmissionForm 5 | from django.urls import reverse 6 | 7 | 8 | def home(request): 9 | nodes = Node.objects.all() 10 | 11 | if len(Node.objects.all()) > 0: 12 | random_word = random.choice(Node.objects.all()).id 13 | else: 14 | random_word = "None" 15 | 16 | return render(request, 'home.html', { 17 | 'title': 'Öküzün Elifi', 18 | 'nodes': nodes, 19 | 'random_word': random_word, 20 | }) 21 | 22 | def node_detail(request, id): 23 | node = Node.objects.get(id=id) 24 | incoming = node.incoming.all() 25 | outgoing = node.outgoing.all() 26 | return render(request, 'node_detail.html', { 27 | 'node': node, 28 | 'incoming': incoming, 29 | 'outgoing': outgoing, 30 | 'title': 'Öküzün Elifi: %s' % node.name, 31 | }) 32 | 33 | def edge_detail(request, id): 34 | edge = Edge.objects.get(id=id) 35 | return render(request, 'edge_detail.html', { 36 | 'edge': edge, 37 | 'edge.source': edge.source, 38 | 'edge.destination': edge.destination, 39 | 'edge.type_of_edge': edge.type_of_edge, 40 | 'title': 'Öküzün Elifi: %s' % edge.type_of_edge, 41 | }) 42 | 43 | def about(request): 44 | return render(request, 'about.html') 45 | 46 | def support(request): 47 | return render(request, 'support.html') 48 | 49 | def submit(request): 50 | form = SubmissionForm() 51 | 52 | if request.method == "POST": 53 | form = SubmissionForm(request.POST) 54 | if form.is_valid(): 55 | 56 | if [i for i in Node.objects.all() if i.name == form.cleaned_data['source_node']] == [] \ 57 | or [i for i in Node.objects.all() if i.name == form.cleaned_data['target_node']] == []: 58 | 59 | try: 60 | source_node = Node.objects.get(name=form.cleaned_data['source_node']) 61 | except Node.DoesNotExist: 62 | source_node = Node.objects.create(name=form.cleaned_data['source_node'],language=form.cleaned_data['source_language'],user=request.user,) 63 | 64 | try: 65 | target_node = Node.objects.get(name=form.cleaned_data['target_node']) 66 | except Node.DoesNotExist: 67 | target_node = Node.objects.create(name=form.cleaned_data['target_node'],language=form.cleaned_data['target_language'],user=request.user,) 68 | 69 | edge = Edge.objects.create(source=source_node,destination=target_node,is_directed=False,type_of_edge=form.cleaned_data['type_of_edge'],resource=form.cleaned_data['resource'],user=request.user,) 70 | 71 | else: 72 | return render(request, 'submit.html', 73 | {"error" : "there are already those nodes available, please try new one", 74 | 'form': SubmissionForm()} 75 | ) 76 | 77 | return redirect(reverse("node_detail", args=[source_node.id])) 78 | return render(request, 'submit.html',{"form" : form}) -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/elifinokuzu/.settings.py.swp: -------------------------------------------------------------------------------- 1 | b0nano 2.5.3kioxkiox-VirtualBoxsettings.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/elifinokuzu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/elifinokuzu/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/elifinokuzu/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elifinokuzu project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.utils.translation import ugettext_lazy as _ 15 | 16 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 17 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18 | 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 22 | 23 | # Application definition 24 | 25 | INSTALLED_APPS = [ 26 | 'django.contrib.admin', 27 | 'django.contrib.auth', 28 | 'django.contrib.contenttypes', 29 | 'django.contrib.sessions', 30 | 'django.contrib.messages', 31 | 'django.contrib.staticfiles', 32 | 'dictionary', 33 | 'crawler', 34 | 'reports', 35 | 'captcha', 36 | 'comments',] 37 | 38 | MIDDLEWARE = [ 39 | 'django.middleware.security.SecurityMiddleware', 40 | 'django.contrib.sessions.middleware.SessionMiddleware', 41 | 'django.middleware.common.CommonMiddleware', 42 | 'django.middleware.csrf.CsrfViewMiddleware', 43 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 44 | 'django.contrib.messages.middleware.MessageMiddleware', 45 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 46 | 'django.middleware.locale.LocaleMiddleware', 47 | ] 48 | 49 | ROOT_URLCONF = 'elifinokuzu.urls' 50 | 51 | TEMPLATES = [ 52 | { 53 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 54 | 'DIRS': [ 55 | os.path.join(BASE_DIR, 'templates'), 56 | ], 57 | 'APP_DIRS': True, 58 | 'OPTIONS': { 59 | 'context_processors': [ 60 | 'django.template.context_processors.debug', 61 | 'django.template.context_processors.request', 62 | 'django.contrib.auth.context_processors.auth', 63 | 'django.contrib.messages.context_processors.messages', 64 | ], 65 | }, 66 | }, 67 | ] 68 | 69 | WSGI_APPLICATION = 'elifinokuzu.wsgi.application' 70 | 71 | # Password validation 72 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 73 | 74 | AUTH_PASSWORD_VALIDATORS = [ 75 | { 76 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 77 | }, 78 | { 79 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 80 | }, 81 | { 82 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 83 | }, 84 | { 85 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 86 | }, 87 | ] 88 | 89 | 90 | # Internationalization 91 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 92 | 93 | LANGUAGE_CODE = 'en-us' 94 | 95 | LANGUAGES = ( 96 | ('en', _('English')), 97 | ('tr', _('Turkish')), 98 | ) 99 | 100 | LOCALE_PATHS = ( 101 | os.path.join(BASE_DIR, 'locale'), 102 | ) 103 | 104 | TIME_ZONE = 'UTC' 105 | 106 | USE_I18N = True 107 | 108 | USE_L10N = True 109 | 110 | USE_TZ = True 111 | 112 | 113 | # Static files (CSS, JavaScript, Images) 114 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 115 | STATIC_DIR = os.path.join(BASE_DIR, 'static') 116 | STATIC_URL = '/static/' 117 | STATICFILES_DIRS= [ 118 | STATIC_DIR, 119 | ] 120 | LOGOUT_REDIRECT_URL = '/' 121 | 122 | try: 123 | from elifinokuzu.local_settings import * 124 | except ImportError: 125 | print( 126 | ''' 127 | Local settings was not found. Duplicate local_settings.example and 128 | rename it to local_settings.py 129 | ''' 130 | ) 131 | except SyntaxError: 132 | print( 133 | ''' 134 | Local settings is misconfigured. 135 | ''' 136 | ) 137 | NOCAPTCHA = True 138 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/elifinokuzu/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | from reports import views as report_views 4 | from dictionary import views as dictionary_views 5 | from accounts import views as account_views 6 | from comments import views as comment_views 7 | 8 | urlpatterns = [ 9 | path('', dictionary_views.home, name='home'), 10 | path('about/', dictionary_views.about, name='about'), 11 | path('support/', dictionary_views.support, name='support'), 12 | path('admin/', admin.site.urls), 13 | path('nodes//', dictionary_views.node_detail, name='node_detail'), 14 | path('accounts/', include('django.contrib.auth.urls')), 15 | path('accounts/signup/', account_views.signup, name='signup'), 16 | path('accounts/profile/', account_views.dashboard, name='dashboard'), 17 | path('support/', account_views.support, name='support'), 18 | path('submit/', dictionary_views.submit, name='submit' ), 19 | path('edges//', dictionary_views.edge_detail, name='edge_detail'), 20 | path('report/', report_views.report, name='report'), 21 | path('reportdone', report_views.reportdone, name ='reportdone'), 22 | path('nodes//comment/', comment_views.add_comment_to_node, name='add_comment_to_node'), 23 | path('edges//comment/', comment_views.add_comment_to_edge, name='add_comment_to_edge'), 24 | ] 25 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/elifinokuzu/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elifinokuzu 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/2.0/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", "elifinokuzu.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/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", "elifinokuzu.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/reports/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Issue 3 | 4 | admin.site.register(Issue) -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ReportsConfig(AppConfig): 5 | name = 'reports' 6 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/forms.py: -------------------------------------------------------------------------------- 1 | from django.forms import ModelForm 2 | from .models import Issue 3 | from captcha.fields import ReCaptchaField 4 | class ReportForm(ModelForm): 5 | class Meta: 6 | model = Issue 7 | fields = ['url',"explantation"] 8 | 9 | captcha = ReCaptchaField() -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-28 12:27 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Issue', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('url', models.CharField(max_length=255)), 19 | ('explantation', models.TextField(max_length=2000)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/reports/migrations/__init__.py -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Issue(models.Model): 4 | url = models.CharField(max_length=255) 5 | explantation = models.TextField(max_length=2000) 6 | 7 | def __str__(self): 8 | return self.url -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/reports/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from reports.forms import ReportForm 3 | from django.urls import reverse 4 | 5 | 6 | def reportdone(request): 7 | return render(request, "reports/reportdone.html") 8 | 9 | def report(request): 10 | if request.method == "POST": 11 | form = ReportForm(request.POST) 12 | if form.is_valid(): 13 | model_instance = form.save(commit=False) 14 | model_instance.save() 15 | return redirect(reverse("reportdone")) 16 | else: 17 | form = ReportForm() 18 | return render(request, 'reports/report.html', {'form': form}) -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/static/favicon.ico -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lyk2018-python/django-notlar/729ea3ef291a92e3dcfad9df8c909a4acfcda1d0/DERSLER/GUN 8/elifinokuzu/static/logo.png -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}About{% endblock %} 3 | {% block content %} 4 |

Elifin Öküzü is an open source etymological dictionary prepared by 5 | Python-Django class at Mustafa Akgül Free Software Summer Camp. The 6 | project bases on mapping the words at Sevan Nişanyan's "Elif's Ok or The 7 | Surprises Book". If you can give clear resources, you can add words too.

8 | 9 |

Elif's Ox or The Surprises Book

10 |

There are more than 1000 explanations of what some words meant and how they 11 | sounded 600 or 2,000 years ago at Nişanyan's book. It is full of surprises. 12 | The words we use has an unbeliveable history. The history of Turkish language 13 | is about 1300 years but the words we use today has a history of thousands years. 14 | We run across some of the words at Homeros's sources or some others at Zarathustra 15 | religion. For example we think that the word "sex" come from America but it 16 | takes us to Rome before it was an empire. 17 |

18 |

Mustafa Akgül Free Software Summer 19 | Camp

20 |

The camp at first named "Lınux Summer Camp" and starts at 2010 with 1 class, 21 | 35 students and lasts 9 days. Today at 2018; it is a "Free Software Camp" with 22 | 20+ classes, 15+ different subjects, 500+ participants, 70+ instructors and 23 | lasts 15 days. It was named "Mustafa Akgül Free Software Summer Camp." at 24 | the honor of Mustafa Akgül after his death.

25 |

The participants don't need to pay any money except travel, food and 26 | accomodation expenses. Quotas are limited.

27 | 28 |

Free Software Philosopy

29 |

Free software is software that gives the user the freedom to share, 30 | study and modify it. We call this free software because the user is free. 31 | To use free software is to make a political and ethical choice asserting the 32 | right to learn, and share what we learn with others. Free software has become 33 | the foundation of a learning society where we share our knowledge in a way 34 | that others can build upon and enjoy.

Currently, many people use proprietary 35 | software that denies users these freedoms and benefits. If we make a copy 36 | and give it to a friend, if we try to figure out how the program works, 37 | if we put a copy on more than one of our own computers in our own home, 38 | we could be caught and fined or put in jail. That’s what’s in the fine print 39 | of the license agreement you accept when using proprietary software.

40 | The corporations behind proprietary software will often spy on your activities 41 | and restrict you from sharing with others. And because our computers control 42 | much of our personal information and daily activities, proprietary software 43 | represents an unacceptable danger to a free society.

44 | 45 |

Mustafa Akgül

46 |

Mustafa Akgül was a Turkish computer scientist who was the key figure of the 47 | acceptance of the Internet in Turkey. He went to the University of Waterloo, 48 | Canada and got his PhD in Combinatorics and Optimisation. He started with 49 | the motto of "Internet is life".

50 |

He gave start to a free software community at 1990's and worked 51 | for extending it until his death at 2017. At 1993 he opened linux@bilkent.edu.tr 52 | mail address to start a communication channel between free software developers 53 | and at 1995 he brought together these people at 1. Turkey Internet Conference. 54 | At this conference; people come together and started a community named Turkey 55 | Linux Users Community and made their first speech about free software again 56 | at that organization.

57 |

It was Mustafa Akgül's dream to organize a Linux Summer Camp and he made it 58 | real at 2010. And from now on the camp's name will be Mustafa Akgül Free Software 59 | Summer Camp.

60 | 61 | {% endblock %} 62 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/accounts/dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Welcome' %} {{ user.username }}

6 | {% trans 'Name & Surname:' %} {{ user.first_name }} {{ user.last_name }} 7 |
8 | {% trans 'User ID:' %} {{ user.id }} 9 |
10 | {% trans 'Username:' %} {{ user.username }} 11 |
12 | {% trans 'eMail Address:' %} {{ user.email }} 13 |
14 | {% trans 'Last Login:' %} {{ user.last_login }} 15 |
16 | {% trans 'Date Joined:' %} {{ user.date_joined }} 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | {% load i18n %} 5 | 6 | 7 | 8 | 9 | {% block title %} Default Title{% endblock %} 10 | 31 | 32 | 33 |
34 |
35 | 41 |
42 | 66 |
67 | {% block content %} 68 | {% endblock %} 69 |
70 |
71 | {% trans 'elifinokuzu is an open-source etymological dictionary. Support us on github.' %} 72 |
73 |
74 | 75 | 76 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/comments/add_comment_to_edge.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

New comment

5 |
{% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 | {% endblock %} 10 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/comments/add_comment_to_node.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

New comment

5 |
{% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 | {% endblock %} 10 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/edge_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{{ edge.type_of_edge }}{% endblock %} 5 | {% block content %} 6 |
7 | 8 |
9 |

{{ edge.type_of_edge }}

10 |

{{ edge.source }}

11 |

{{ edge.type_of_edge }}

12 |

{{ edge.destination }}

13 | {% if user.is_authenticated %} 14 |

Add comment

15 | {% endif %} 16 | {% for comment in edge.comments_edge.all %} 17 |
18 |

{{ comment.user }}:

19 |

{{ comment.text }}

20 |
{{ comment.created_date|date:"d M, Y" }}
21 |
22 |
23 | {% empty %} 24 |

No comments here yet :(

25 | {% endfor %} 26 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{% trans 'Home Page' %}{% endblock %} 5 | {% block content %} 6 | {% for node in nodes %} 7 | 11 | {% endfor %} 12 | {% if random_word != "None" %} 13 | {% trans 'GET A RANDOM WORD' %}
14 | {% else %} 15 |

{% trans 'Database is EMPTY' %}

16 | {% endif %} 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/node_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{{ node.name }}{% endblock %} 5 | {% block content %} 6 |
7 | 8 |
9 |

{{ node.name }}

10 | {% if incoming %} 11 |

Incoming

12 | {% for edge in incoming %} 13 |
{{ edge }}
14 | {% endfor %} 15 | {% endif %} 16 | {% if outgoing %} 17 |

Outgoing

18 | {% for edge in outgoing %} 19 |
{{ edge }}
20 | {% endfor %} 21 | {% endif %} 22 | {% if user.is_authenticated %} 23 |

Add comment

24 | {% endif %} 25 | {% for comment in node.comments_node.all %} 26 |
27 |

{{ comment.user }}:

28 |

{{ comment.text }}

29 |
{{ comment.created_date|date:"d M, Y" }}
30 |
31 |
32 | {% empty %} 33 |

No comments here yet :(

34 | {% endfor %} 35 | 36 | {% endblock %} 37 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Login' %}

6 |
7 | {% csrf_token %} 8 | {{ form.as_p }} 9 | 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/registration/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load i18n %} 3 | 4 | {% block content %} 5 |

{% trans 'Sign up' %}

6 |
7 | {% csrf_token %} 8 | {{ form.as_p }} 9 | 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/reports/report.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Report Page{% endblock %} 3 | {% block content %} 4 |

Submit Report

7 |

Please login for creating a new report

8 | 9 | {% else %} 10 |

Submit Report

11 |
12 | {% csrf_token %} 13 | {{ form.as_p }} 14 | 15 |
16 | {% endif %} 17 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/reports/reportdone.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Successful{% endblock %} 3 | {% block content %} 4 | 5 |

Congratulations Your Report Submitted. Automatically redirected in 5 seconds.

6 | {% endblock %} -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/submit.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | 4 | {% block title %}{% trans 'Submit Page' %}{% endblock %} 5 | {% block content %} 6 | 7 | {% if error %} 8 |

{{ error }}

9 | {% endif %} 10 | 11 | {% if form %} 12 | {% if user.is_authenticated %} 13 |

{% trans 'Submit' %}

14 | {% if user.is_anonymous %} 15 |
16 | {% trans 'Please login for creating a new record.' %} 17 |
18 | {% else %} 19 |
20 | {% csrf_token %} 21 | {{ form.as_p }} 22 | 23 |
24 | {% endif %} 25 | {% endif %} 26 |

You need to log in to submit a word

27 | {% else %} 28 | {% endif %} 29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/elifinokuzu/templates/support.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Support{% endblock %} 3 | {% block content %} 4 |
This site developed by django class of LYK2018. 5 |
For more information you can contact us.
6 | {% endblock %} 7 | 8 | SUPPORT US PLX 9 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/logos/1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /DERSLER/GUN 8/logos/ice_cream.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 26 | 28 | 29 | 32 | 33 | 36 | 37 | 38 | 40 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /DERSLER/Notlar/authentication.md: -------------------------------------------------------------------------------- 1 | ### Authentication 2 | #### Login 3 | Django default authentication için *urls.py* sayfasına 4 | ```python 5 | from django.urls import path, include 6 | path('accounts/', include('django.contrib.auth.urls')), 7 | ``` 8 | eklenir 9 | Ardından *login.html* sayfası eklenmesi gerekmektedir 10 | ```python 11 | {% extends 'base.html' %} 12 | {% block title %}Login{% endblock %} 13 | 14 | {% block content %} 15 |

Login

16 |
17 | {% csrf_token %} 18 | {{ form.as_p }} 19 | 20 |
21 | {% endblock %} 22 | ``` 23 | 24 | Bir klasörü python paketine çevirmek için *__init__.py* eklemek gerekir 25 | 26 | #### Register 27 | 28 | ```python 29 | {% extends 'base.html' %} 30 | 31 | {% block content %} 32 |

Sign up

33 |
34 | {% csrf_token %} 35 | {{ form.as_p }} 36 | 37 |
38 | {% endblock %} 39 | ``` 40 | ```python 41 | from django.urls import path, include 42 | path('accounts/signup', account_views.signup, name='signup'), 43 | ``` 44 | #### Runtime da Pyhton debugger çalıştırmak için 45 | Debug yapılması istenen satıra; 46 | ```python 47 | import pdb; pdb.set_trace() 48 | ``` 49 | yazılır ve 50 | ```python 51 | python manage.py runserver 52 | ``` 53 | ile proje çalıştırıldığında terminalde shell çalışır ve bu sayede debug yapılabilir. -------------------------------------------------------------------------------- /DERSLER/Notlar/base-templates.md: -------------------------------------------------------------------------------- 1 | ### Base Templates 2 | Base template başka bir html dosyasını base olarak inherit etmek için kullanılır 3 | 4 | ```python 5 | {% block title %} 6 | YOUR-TITLE 7 | {% endblock %} 8 | {% extends "base_template.html" %} 9 | {% block body_block %} 10 |

{{ node.name }}

11 | {% if incoming %} 12 |

Incoming

13 | {% for edge in incoming %} 14 | {{ edge }}
15 | {% endfor %} 16 | {% endif %} 17 | {% if outgoing %} 18 |

Outgoing

19 | {% for edge in outgoing %} 20 | {{ edge }}
21 | {% endfor %} 22 | {% endif %} 23 | {% endblock %} 24 | ``` 25 | *node_detail.html* dosyasının içeriğini başka bir html dosyası olan *base_template.html* dosyası içerisinde kullanabiliriz 26 | ```html 27 | 28 | 29 | 30 | 31 | 32 | {% block title %} 33 | Default Title 34 | {% endblock %} 35 | 36 | 37 | 38 | {% block body_block %} 39 | {% endblock %} 40 | 41 | 42 | ``` -------------------------------------------------------------------------------- /DERSLER/Notlar/deployment.md: -------------------------------------------------------------------------------- 1 | ## Deployment 2 | https://www.vultr.com/ yada https://www.digitalocean.com/ gibi sitelerde hesap açılır, gerekli server ve server için OS seçilir, server kiralanır. 3 | Server kurulumu bittikten sonra terminalden SSH ile sunucuya bağlanılır. Gerekli ise -p numarası eklenir. 4 | 5 | ``` 6 | ssh root@ -p 7 | ``` 8 | Bağlandıktan sonra 9 | ``` 10 | sudo apt-get update 11 | sudo apt-get -y upgrade 12 | ``` 13 | ile apt ile update alınır 14 | #### Python3, pip3 ve Django kurulumu 15 | 16 | ``` 17 | sudo apt-get install python3 18 | sudo apt-get install -y python3-pip 19 | ``` 20 | Ardından pip3 ile virtualenv kurulumu yapılır 21 | 22 | ``` 23 | pip3 install virtualenv 24 | ``` 25 | Yükleme sonrasında virtualenv yaratılır; 26 | ``` 27 | virtualenv 28 | ``` 29 | *source* komutu ile virtual environment activate edilir 30 | ``` 31 | cd 32 | source bin/activate 33 | ``` 34 | Daha sonrasında yarattığımız virtual environment a django kurulur 35 | 36 | ``` 37 | pip install django 38 | pip install django-recaptcha 39 | ``` 40 | Virtual environmentların dışında projelerin bulunduğu klasöre proje clonelanır yada yaratılır. 41 | ``` 42 | //Örnek 43 | mkdir Projeler 44 | cd Projeler 45 | sudo apt-get install git 46 | git clone 47 | ``` 48 | #### Proje deploymentı 49 | manage.py bulunduğu klasöre gittikten sonra makemigrations yapılır.cd 50 | ``` 51 | python manage.py makemigrations 52 | ``` 53 | #### Migrate işlemi 54 | ``` 55 | pyton manage.py migrate 56 | ``` 57 | #### Superuser oluşturma işlemi 58 | ``` 59 | python manage.py createsuperuser 60 | ``` 61 | #### Alınan domain ( HTTP Proxy adresi ) allowed hosts a eklenir 62 | ```python 63 | ALLOWED_HOSTS = ["elifinokuzu.org"] 64 | ``` 65 | #### 80 portundan erişim sağlama 66 | ``` 67 | python manage.py runserver 0.0.0.0:80 68 | ``` 69 | -------------------------------------------------------------------------------- /DERSLER/Notlar/forms.md: -------------------------------------------------------------------------------- 1 | ### Formlar 2 | *forms.py* dosyası çalışması istenen app in içerisinde yaratılır ardından projeye uygun şekilde içeriği doldurulur. 3 | 4 | ```python 5 | from django import forms 6 | from .models import LANGUAGE_CHOICES, EDGE_TYPE_CHOICES 7 | 8 | 9 | class submission_form(forms.Form): 10 | source_language = forms.ChoiceField( 11 | choices=LANGUAGE_CHOICES, 12 | label='Source Language' 13 | ) 14 | 15 | source_node = forms.CharField( 16 | help_text="Example: Elif in Turkish language", 17 | max_length=255, 18 | label='Source Node' 19 | ) 20 | 21 | target_language = forms.ChoiceField( 22 | choices=LANGUAGE_CHOICES, 23 | label='Target Language', 24 | ) 25 | 26 | target_node = forms.CharField( 27 | help_text="Example: Alpha in Ancient Greek", 28 | max_length=255, 29 | label='Target Node' 30 | ) 31 | 32 | type_of_edge = forms.ChoiceField( 33 | widget=forms.RadioSelect(), 34 | choices=EDGE_TYPE_CHOICES, 35 | label='Type of edge' 36 | ) 37 | 38 | resource = forms.CharField( 39 | help_text="Example: Sevan Nişanyan's Elifin Öküzü", 40 | max_length=255, 41 | label='Resource' 42 | ) 43 | ``` 44 | Ardından *views.py* a ve *urls.py* a gerekli alanlar eklenir; 45 | 46 | *urls.py* 47 | ```python 48 | urlpatterns = [ 49 | path('', dictionary_views.home, name="home"), 50 | path('about/', dictionary_views.about, name="about"), 51 | path('support/', dictionary_views.support, name="support"), 52 | path('node//', dictionary_views.node_detail, name="node_detail"), 53 | path('admin/', admin.site.urls), 54 | path('accounts/', include('django.contrib.auth.urls')), 55 | path('accounts/signup', account_views.signup, name='signup'), 56 | path('accounts/profile/', account_views.submit.dashboard, name='dashboard' ), 57 | path('submit/', dictionary_views.submit, name='submit') #THIS 58 | ] 59 | ``` 60 | *views.py* 61 | ```python 62 | from forms import as submission_form 63 | from django.shortcuts import render, redirect 64 | from django.urls import reverse 65 | def submit(request): 66 | if request.method == 'POST': 67 | form = submission_form(request.POST) 68 | if form.is_valid(): 69 | source_node = Node.objects.create( 70 | name=form.cleaned_data['source_node'], 71 | language=form.cleaned_data['source_language'] 72 | ) 73 | target_node = Node.objects.create( 74 | name=form.cleaned_data['target_node'], 75 | language=form.cleaned_data['target_language'] 76 | ) 77 | type_of_edge = Edge.objects.create( 78 | source=source_node, 79 | destination=target_node, 80 | is_directed=False, 81 | type_of_edge=form.cleaned_data['type_of_edge'], 82 | resource=form.cleaned_data['resource'], 83 | ) 84 | return redirect(reverse("node_detail", args=[source_node.id])) 85 | else: 86 | form = submission_form() 87 | return render(request, "submit.html", {'form': form}) 88 | ``` -------------------------------------------------------------------------------- /DERSLER/Notlar/models.md: -------------------------------------------------------------------------------- 1 | ### Models 2 | Yaratılmak istenen model class şeklinde oluşturulur ve models.Model classından türetilir. 3 | ```python 4 | from django.db import models 5 | 6 | 7 | class Node(models.Model): 8 | ``` 9 | Ardından yaratılan class içerisi *CharField*, *ForeignKey*, *BooleanField* gibi fieldlar ile modellenir. 10 | Admin panelinde eklenen objenin isminin görünmesi için *__str__* fonksiyonu(Java'daki *.toString()*) ezilir. 11 | ```python 12 | class Node(models.Model): 13 | name = models.CharField(max_length = 255) 14 | language = models.CharField( 15 | max_length=255, 16 | choices=LANGUAGE_CHOICES 17 | ) 18 | 19 | def __str__(self): 20 | return self.name 21 | 22 | class Edge(models.Model): 23 | source = models.ForeignKey( 24 | Node, 25 | related_name="incoming", 26 | on_delete=models.CASCADE, 27 | ) 28 | destination = models.ForeignKey( 29 | Node, 30 | related_name="outgoing", 31 | on_delete=models.CASCADE, 32 | ) 33 | is_directed = models.BooleanField() 34 | type_of_edge = models.CharField( 35 | max_length=255, 36 | choices=EDGE_TYPE_CHOICES 37 | ) 38 | def __str__(self): 39 | if self.is_directed: 40 | arrow = "-->" 41 | else: 42 | arrow = "<->" 43 | return "%s:%s %s %s:%s" % ( 44 | self.source.language, 45 | self.source.name.lower(), 46 | arrow, 47 | self.destination.language, 48 | self.destination.name.lower() 49 | ) 50 | ``` 51 | Eklenen modelin Admin panelde görünmesi için *admim.py* dosyasına ekleme yapılır. 52 | ```python 53 | from django.contrib import admin 54 | from dictionary.models import Node,Edge 55 | 56 | 57 | admin.site.register(Node) 58 | admin.site.register(Edge) 59 | ``` 60 | Ardından eklenen modeller ve modellerde yapılan değişiklikler için 61 | ``` 62 | python manage.py makemigrations 63 | python manage.py migrate 64 | ``` 65 | yapılır. -------------------------------------------------------------------------------- /DERSLER/Notlar/static-css.md: -------------------------------------------------------------------------------- 1 | ### Base CSS Files 2 | *settings.py* dosyasına *STATICFILES_DIRS* adlı array(liste) eklenir ardından içine 3 | ```python 4 | STATICFILES_DIRS = [ 5 | os.path.join(BASE_DIR, 'static'), 6 | ] 7 | ``` 8 | eklenir. 9 | Ardından istenen konuma css dosyası yaratılır ve istenilen şekilde doldurulur. 10 | ```css 11 | * { 12 | font-family: Helvetica; 13 | /* Put your CSS here */ 14 | } 15 | ``` 16 | Daha sonra *base.html* e yada eklenmek istenilen html sayfasına *{% block css %}* şeklinde eklenir. 17 | ```html 18 | {% block css %} 19 | {% load static %} 20 | 21 | {% endblock %} 22 | ... 23 | ``` -------------------------------------------------------------------------------- /DERSLER/Notlar/to-run-django-note.md: -------------------------------------------------------------------------------- 1 | #### Virtualenv için 2 | *virtualenv --python=python3 * 3 | 4 | *source /bin/activate* 5 | 6 | *virtualenv --python=python3 lyk* 7 | 8 | *source lyk/bin/activate* 9 | 10 | #### Ardından o konuma django kurmak için 11 | *pip install django* 12 | 13 | #### Django projesi oluşturmak için, ama önce klasör dizinini belirle 14 | *django-admin startproject * 15 | 16 | *django-admin startproject Melek* 17 | 18 | #### Startprojectten sonra proje dizinine git sonra; 19 | *python manage.py runserver* 20 | 21 | #### İstenilen Itemın ismini ezmek için models.py a eklenir; 22 | ```python 23 | def __str__(self): 24 | return self.title 25 | ``` 26 | #### App başlatmak için 27 | *python manage.py startapp * 28 | 29 | *python manage.py startapp news* 30 | * Melek/Melek/settings.py dosyasında installed apps güncelle(modeli ekle) 31 | 32 | ```python 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'news', 41 | ] 42 | ``` 43 | admin panelde düzenlemek için news/admin.py dosyasına; 44 | ```python 45 | from news.models import NewsItem 46 | admin.site.register(NewsItem) 47 | ``` 48 | ekle 49 | 50 | #### Migrationsları oluşturma 51 | *python manage.py makemigrations* 52 | #### Migrate işlemi 53 | *pyton manage.py migrate* 54 | #### Superuser oluşturma işlemi 55 | *python manage.py createsuperuser* 56 | #### 80 portundan erişim sağlama 57 | *python manage.py runserver 0.0.0.0:80* 58 | * Global erişişm için Melek/Melek/settings.py dosyasında 59 | 60 | ```python 61 | ALLOWED_HOSTS = ['*'] 62 | ``` 63 | * şeklinde güncellenmeli 64 | #### Shell kullanma örneği 65 | *python manage.py shell* 66 | ```python 67 | from news.models import NewsItem 68 | NewsItem() 69 | NewsItem(title="fikibok") 70 | 71 | haber = NewsItem() 72 | haber.title = "fiki fiki" 73 | haber.content = "emoji" 74 | haber.save() 75 | haber.id 76 | ``` -------------------------------------------------------------------------------- /DERSLER/Notlar/views.md: -------------------------------------------------------------------------------- 1 | #### Views model.view.template 2 | Kullanıcının göreceği kısım 3 | 4 | #### Basit bir view; 5 | "views.py" dosyasına eklenir 6 | ```python 7 | from django.http import HttpResponse 8 | import datetime 9 | 10 | def current_datetime(request): 11 | now = datetime.datetime.now() 12 | html = "It is now %s." % now 13 | return HttpResponse(html) 14 | ``` 15 | Ardından eklenen view "urls.py" dosyasına eklenir 16 | ```python 17 | urlpatterns = [ 18 | path('', views.current_datetime, name="home"), 19 | path('admin/', admin.site.urls), 20 | ] 21 | ``` 22 | #### Template eklemek için; 23 | Proje rootuna 'templates' klasörü eklenir. 24 | Ardından içerisine html dosyası eklenir 25 | ```python 26 | #views.py 27 | def home(request): 28 | return render(request, "home.html", { 29 | "title": "Öküzün Elifi" 30 | }) 31 | ``` 32 | settings.py dosyasında 33 | ```python 34 | TEMPLATES = [ 35 | { 36 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 37 | 'DIRS': [ 38 | os.path.join(BASE_DIR, "templates"), 39 | ], 40 | 'APP_DIRS': True, 41 | 'OPTIONS': { 42 | 'context_processors': [ 43 | 'django.template.context_processors.debug', 44 | 'django.template.context_processors.request', 45 | 'django.contrib.auth.context_processors.auth', 46 | 'django.contrib.messages.context_processors.messages', 47 | ], 48 | }, 49 | }, 50 | ] 51 | ``` 52 | kısmına 53 | ```python 54 | 'DIRS': [ 55 | os.path.join(BASE_DIR, "templates"), 56 | ] 57 | ``` 58 | eklenir -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Mustafa Akgül Özgür Yazılım Yaz Kampı 2018 - Python / Django ile Web Programlama 2 | --------------------------------------------------------------------------------