Prechádzať zdrojové kódy

Добавил модуль с формой для обработки заказа

1Mike21 1 rok pred
commit
f7dd641b99
12 zmenil súbory, kde vykonal 119 pridanie a 0 odobranie
  1. 10 0
      .gitignore
  2. 44 0
      README.md
  3. 0 0
      __init__.py
  4. 3 0
      admin.py
  5. 6 0
      apps.py
  6. 8 0
      forms.py
  7. 3 0
      models.py
  8. 17 0
      templates/webservice_running/base.html
  9. 8 0
      templates/webservice_running/order_reg.html
  10. 3 0
      tests.py
  11. 8 0
      urls.py
  12. 9 0
      views.py

+ 10 - 0
.gitignore

@@ -0,0 +1,10 @@
+# VSCode
+.vscode
+
+# Python
+__pycache__/
+*.py[cod]
+*$py.class
+
+# Django
+migrations/

+ 44 - 0
README.md

@@ -0,0 +1,44 @@
+# Design Template
+
+A module for processing customer orders implemented as a Django application.
+
+## Installation
+
+
+1) Download or clone repository
+
+```bash
+git clone https://git.sharix-app.org/ShariX_Open/sharix-open-webservice-running.git
+```
+
+2) Install required dependencies in project settings
+
+```python
+INSTALLED_APPS = [   
+    ...
+    'webservice_running',
+    ...
+]
+```
+
+3) Connects application routes to the project
+
+```python
+  urlpatterns = (
+  [
+    ...
+    path('webservice/', include("webservice_running.urls"), name='webservice'),
+    ...
+  ]
+  )
+```
+
+4) Delete the migration files in the **migrations** folder (everything except __init__.py)
+
+Start test the server:
+
+```bash
+python manage.py runserver 8000
+```
+
+If the port has not been selected, it is 8000 by default. If selected port is busy, use another one (for example, try increasing port number by 1 until the server starts). A link to the website should appear in the terminal.

+ 0 - 0
__init__.py


+ 3 - 0
admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 6 - 0
apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class WebserviceRunningConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'webservice_running'

+ 8 - 0
forms.py

@@ -0,0 +1,8 @@
+from django import forms
+from metaservicesynced.models.orders import Orders
+
+
+class OrderRegForm(forms.ModelForm):
+    class Meta: 
+        model = Orders
+        fields = '__all__'

+ 3 - 0
models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 17 - 0
templates/webservice_running/base.html

@@ -0,0 +1,17 @@
+{% load static %}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="shortcut icon" href="{% static 'SharixAdmin/img/logo.svg' %}"/>
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
+    <title></title>
+</head>
+<body style="min-width: 1050px;">
+    {% block content %}
+    {% endblock %}
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
+</body>
+</html>

+ 8 - 0
templates/webservice_running/order_reg.html

@@ -0,0 +1,8 @@
+{% extends "webservice_running/base.html" %}
+{% block content %}
+      <form action="{% url 'order_reg' %}" method="post">
+        {% csrf_token %}
+        {{ form.as_p }}
+        <button type="submit">Оформить заказ</button>
+      </form>
+{% endblock content %}

+ 3 - 0
tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 8 - 0
urls.py

@@ -0,0 +1,8 @@
+from django.urls import path
+from . import views
+
+app_name = 'webservice'
+
+urlpatterns = [
+    path("", views.order_reg, name="order_reg"),
+]

+ 9 - 0
views.py

@@ -0,0 +1,9 @@
+from django.shortcuts import redirect, render
+from webservice_running.forms import OrderRegForm
+
+def order_reg(request):
+    if request.method == 'POST':
+      form = OrderRegForm(request.POST)
+      if form.is_valid():
+          form.save()
+    return render(request, 'webservice/order_reg.html', {'form': form})