From 34f0fe7cac1d6e6c22e07d0764d64c1c2a366922 Mon Sep 17 00:00:00 2001 From: ferdzo Date: Tue, 18 Apr 2023 02:04:19 +0200 Subject: [PATCH] Initial commit --- .gitignore | 208 ++++++++++++++++++ .idea/.gitignore | 8 + .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/serviceCRM.iml | 29 +++ README.md | 2 + index.html | 6 + manage.py | 22 ++ serviceCRM/__init__.py | 0 serviceCRM/admin.py | 5 + serviceCRM/apps.py | 6 + serviceCRM/asgi.py | 16 ++ serviceCRM/migrations/0001_initial.py | 25 +++ serviceCRM/migrations/__init__.py | 0 serviceCRM/models.py | 14 ++ serviceCRM/settings.py | 130 +++++++++++ serviceCRM/templates/serviceCRM/id.html | 65 ++++++ serviceCRM/urls.py | 25 +++ serviceCRM/views.py | 14 ++ serviceCRM/wsgi.py | 16 ++ 21 files changed, 609 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/serviceCRM.iml create mode 100644 README.md create mode 100644 index.html create mode 100644 manage.py create mode 100644 serviceCRM/__init__.py create mode 100644 serviceCRM/admin.py create mode 100644 serviceCRM/apps.py create mode 100644 serviceCRM/asgi.py create mode 100644 serviceCRM/migrations/0001_initial.py create mode 100644 serviceCRM/migrations/__init__.py create mode 100644 serviceCRM/models.py create mode 100644 serviceCRM/settings.py create mode 100644 serviceCRM/templates/serviceCRM/id.html create mode 100644 serviceCRM/urls.py create mode 100644 serviceCRM/views.py create mode 100644 serviceCRM/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d9f2c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,208 @@ +# Created by https://www.toptal.com/developers/gitignore/api/venv,dotenv,intellij,pycharm +# Edit at https://www.toptal.com/developers/gitignore?templates=venv,dotenv,intellij,pycharm + +### dotenv ### +.env + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# AWS User-specific + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# SonarLint plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + +### PyCharm Patch ### + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij + +### venv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +.Python +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +.venv +pip-selfcheck.json + +# End of https://www.toptal.com/developers/gitignore/api/venv,dotenv,intellij,pycharm \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..40a3832 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..464c84a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/serviceCRM.iml b/.idea/serviceCRM.iml new file mode 100644 index 0000000..f084a1b --- /dev/null +++ b/.idea/serviceCRM.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..132749e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# serviceCRM +Simple CRM for making reports for service customers diff --git a/index.html b/index.html new file mode 100644 index 0000000..a5b4ad9 --- /dev/null +++ b/index.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..0e4e559 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'serviceCRM.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/serviceCRM/__init__.py b/serviceCRM/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/serviceCRM/admin.py b/serviceCRM/admin.py new file mode 100644 index 0000000..2b0ad64 --- /dev/null +++ b/serviceCRM/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from .models import Insert + +admin.site.register(Insert) \ No newline at end of file diff --git a/serviceCRM/apps.py b/serviceCRM/apps.py new file mode 100644 index 0000000..0d4b91c --- /dev/null +++ b/serviceCRM/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class serviceCRMconfig(AppConfig): + name = "serviceCRM" + verbose_name = "Service CRM" \ No newline at end of file diff --git a/serviceCRM/asgi.py b/serviceCRM/asgi.py new file mode 100644 index 0000000..18b39ee --- /dev/null +++ b/serviceCRM/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for serviceCRM project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'serviceCRM.settings') + +application = get_asgi_application() diff --git a/serviceCRM/migrations/0001_initial.py b/serviceCRM/migrations/0001_initial.py new file mode 100644 index 0000000..e5db73e --- /dev/null +++ b/serviceCRM/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2 on 2023-04-17 22:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Insert', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('phone', models.CharField(max_length=20)), + ('description', models.CharField(max_length=300)), + ('date', models.DateField(verbose_name='date submitted')), + ('done', models.BooleanField()), + ], + ), + ] diff --git a/serviceCRM/migrations/__init__.py b/serviceCRM/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/serviceCRM/models.py b/serviceCRM/models.py new file mode 100644 index 0000000..0335972 --- /dev/null +++ b/serviceCRM/models.py @@ -0,0 +1,14 @@ +from django.db import models +from django.contrib.auth.models import UserManager + +class Insert(models.Model): + name = models.CharField(max_length=50) + phone = models.CharField(max_length=20) + description = models.CharField(max_length=300) + date = models.DateField("date submitted") + done = models.BooleanField() + + def __str__(self): + return "Ime: "+self.name + " Telefonski broj: "+self.phone+ "\nDefekt: "+self.description + "\nDatum: \n" + + diff --git a/serviceCRM/settings.py b/serviceCRM/settings.py new file mode 100644 index 0000000..f2fc914 --- /dev/null +++ b/serviceCRM/settings.py @@ -0,0 +1,130 @@ +""" +Django settings for serviceCRM project. + +Generated by 'django-admin startproject' using Django 4.2. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/ref/settings/ +""" + +from pathlib import Path +import environ +env = environ.Env() +environ.Env.read_env('.env') +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = env('SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + 'serviceCRM.apps.serviceCRMconfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'serviceCRM.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'serviceCRM.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': env('DATABASE_NAME'), + 'USER': env('DATABASE_USER'), + 'PASSWORD': env('DATABASE_PASS'), + 'HOST': env('DATABASE_HOST'), + 'PORT': env('DATABASE_PORT'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/serviceCRM/templates/serviceCRM/id.html b/serviceCRM/templates/serviceCRM/id.html new file mode 100644 index 0000000..5d0360c --- /dev/null +++ b/serviceCRM/templates/serviceCRM/id.html @@ -0,0 +1,65 @@ + + + Nalog + + +{#

Name:{{ name}}

#} +{#

Phone:{{ phone }}

#} +{#

Description:{{ desc }}

#} +{#

Date:{{ date }}

#} + + + + + + + + + + + + + + + + + + + + + + + + + + +
NamePhoneDate
{{ name}} {{ phone }}{{ date }}
Опис на проблем:
{{ desc }}
+ + + + +
\ No newline at end of file diff --git a/serviceCRM/urls.py b/serviceCRM/urls.py new file mode 100644 index 0000000..dcd4ea6 --- /dev/null +++ b/serviceCRM/urls.py @@ -0,0 +1,25 @@ +""" +URL configuration for serviceCRM project. + +The `urlpatterns` list routes URLs to views.py. For more information please see: + https://docs.djangoproject.com/en/4.2/topics/http/urls/ +Examples: +Function views.py + 1. Add an import: from my_app import views.py + 2. Add a URL to urlpatterns: path('', views.py.home, name='home') +Class-based views.py + 1. Add an import: from other_app.views.py import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import include, path + +from . import views +urlpatterns = [ + path("", views.index, name="index"), + path('admin/', admin.site.urls), + path("/", views.detail, name="detail"), +] \ No newline at end of file diff --git a/serviceCRM/views.py b/serviceCRM/views.py new file mode 100644 index 0000000..25278d0 --- /dev/null +++ b/serviceCRM/views.py @@ -0,0 +1,14 @@ +from django.http import HttpResponse +from .models import Insert +from django.template import loader + +def index(request): + proba = Insert.objects.order_by("name") + return HttpResponse(proba) + +def detail(request,question_id): + proba = Insert.objects.get(id=question_id) + template = loader.get_template("serviceCRM/id.html") + context = {"name":proba.name, "phone":proba.phone,"desc":proba.description,"date":proba.date} + return HttpResponse(template.render(context, request)) + diff --git a/serviceCRM/wsgi.py b/serviceCRM/wsgi.py new file mode 100644 index 0000000..0f29e7b --- /dev/null +++ b/serviceCRM/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for serviceCRM project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'serviceCRM.settings') + +application = get_wsgi_application()