Fix permissions and prepare admin login for deploy

- Admin-only: list contacts, create/edit campaigns and compositions
- Public: submit contact, mine contacts by email/phone, read campaigns/compositions
- Add admin_response field on ContactUs
- Update Postman base_url to https://zoneco.org/api with token save

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Shayan Azadi
2026-07-22 22:52:44 +03:30
parent 97127d5772
commit 149fb614b0
8 changed files with 425 additions and 220 deletions

View File

@@ -2,7 +2,7 @@
"info": {
"_postman_id": "zoneco-org-api-collection",
"name": "Zoneco ORG API",
"description": "مجموعه کامل APIهای بک‌اند Zoneco ORG.\n\n1) متغیرهای collection را تنظیم کنید: base_url, admin_username, admin_password\n2) Admin Auth > POST Admin Login را بزنید\n3) توکن در admin_token ذخیره می‌شود\n4) درخواست‌های ادمین با Authorization: Token {{admin_token}} ارسال می‌شوند\n\nCredentials را در متغیرها بگذارید — در کد هاردکد نکنید.",
"description": "Zoneco ORG API\n\nbase_url must be: https://zoneco.org/api\n\n1) Set admin_username and admin_password variables\n2) Run Admin Auth > POST Admin Login\n3) Token is saved to admin_token and shown in response body\n4) Admin requests send: Authorization: Token {{admin_token}}\n\nPermissions:\n- Public: create contact, mine contacts, view campaigns & compositions\n- Admin only: list all contacts, create/edit campaigns & compositions",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
@@ -22,6 +22,7 @@
" var json = pm.response.json();",
" if (json.token) {",
" pm.collectionVariables.set('admin_token', json.token);",
" console.log('admin_token saved');",
" }",
"}"
]
@@ -40,12 +41,12 @@
"mode": "raw",
"raw": "{\n \"username\": \"{{admin_username}}\",\n \"password\": \"{{admin_password}}\"\n}"
},
"url": "{{base_url}}/api/admin/login/",
"description": "Login with admin credentials. Saves token to admin_token automatically."
"url": "{{base_url}}/admin/login/",
"description": "Login. Response includes token. Also saved to collection variable admin_token."
}
},
{
"name": "GET Admin Me",
"name": "GET Admin Me (shows token works)",
"request": {
"auth": {
"type": "apikey",
@@ -69,7 +70,7 @@
},
"method": "GET",
"header": [],
"url": "{{base_url}}/api/admin/me/"
"url": "{{base_url}}/admin/me/"
}
},
{
@@ -97,7 +98,7 @@
},
"method": "POST",
"header": [],
"url": "{{base_url}}/api/admin/logout/"
"url": "{{base_url}}/admin/logout/"
}
}
]
@@ -107,11 +108,56 @@
"description": "APIهای فرم تماس با ما",
"item": [
{
"name": "GET All Contact Us",
"name": "GET My Contact Us (Public)",
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/contact-us/"
"url": {
"raw": "{{base_url}}/contact-us/mine/?email_or_phone={{my_email_or_phone}}",
"host": [
"{{base_url}}"
],
"path": [
"contact-us",
"mine",
""
],
"query": [
{
"key": "email_or_phone",
"value": "{{my_email_or_phone}}",
"description": "Your email or phone used when submitting the form"
}
]
}
}
},
{
"name": "GET All Contact Us (Admin)",
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/contact-us/",
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
{
@@ -119,7 +165,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/contact-us/1/"
"url": "{{base_url}}/contact-us/1/"
}
},
{
@@ -136,21 +182,20 @@
"mode": "raw",
"raw": "{\n \"name\": \"احمد محمدی\",\n \"email_or_phone\": \"ahmad@example.com\",\n \"description\": \"سلام، می‌خواستم در مورد خدمات شما اطلاعات بیشتری دریافت کنم.\",\n \"category\": \"پشتیبانی\"\n}"
},
"url": "{{base_url}}/api/contact-us/"
"url": "{{base_url}}/contact-us/"
}
},
{
"name": "GET Contact Us by Category",
"name": "GET Contact Us by Category (Admin)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/api/contact-us/by_category/?category=پشتیبانی",
"raw": "{{base_url}}/contact-us/by_category/?category=پشتیبانی",
"host": [
"{{base_url}}"
],
"path": [
"api",
"contact-us",
"by_category",
""
@@ -162,6 +207,26 @@
"description": "همکاری | فروش | پشتیبانی | درخواست مشاور | سایر"
}
]
},
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
@@ -197,9 +262,9 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"نام بروزرسانی شده\"\n}"
"raw": "{\n \"admin_response\": \"پاسخ ادمین به پیام شما\"\n}"
},
"url": "{{base_url}}/api/contact-us/1/"
"url": "{{base_url}}/contact-us/1/"
}
},
{
@@ -227,7 +292,7 @@
},
"method": "DELETE",
"header": [],
"url": "{{base_url}}/api/contact-us/1/"
"url": "{{base_url}}/contact-us/1/"
}
}
]
@@ -241,7 +306,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/compositions/"
"url": "{{base_url}}/compositions/"
}
},
{
@@ -249,7 +314,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/compositions/{{composition_id}}/"
"url": "{{base_url}}/compositions/{{composition_id}}/"
}
},
{
@@ -258,12 +323,11 @@
"method": "GET",
"header": [],
"url": {
"raw": "{{base_url}}/api/compositions/by-created-at/?from=2026-01-01T00:00:00Z&to=2026-12-31T23:59:59Z",
"raw": "{{base_url}}/compositions/by-created-at/?from=2026-01-01T00:00:00Z&to=2026-12-31T23:59:59Z",
"host": [
"{{base_url}}"
],
"path": [
"api",
"compositions",
"by-created-at",
""
@@ -284,7 +348,7 @@
}
},
{
"name": "POST Create Composition (JSON)",
"name": "POST Create Composition (JSON) (Admin)",
"request": {
"method": "POST",
"header": [
@@ -297,11 +361,31 @@
"mode": "raw",
"raw": "{\n \"name\": \"ترکیب تست\",\n \"description\": \"این یک ترکیب تستی است\"\n}"
},
"url": "{{base_url}}/api/compositions/"
"url": "{{base_url}}/compositions/",
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
{
"name": "POST Create Composition with Images",
"name": "POST Create Composition with Images (Admin)",
"request": {
"method": "POST",
"header": [],
@@ -336,7 +420,27 @@
}
]
},
"url": "{{base_url}}/api/compositions/"
"url": "{{base_url}}/compositions/",
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
{
@@ -379,7 +483,7 @@
}
]
},
"url": "{{base_url}}/api/compositions/{{composition_id}}/add-images/"
"url": "{{base_url}}/compositions/{{composition_id}}/add-images/"
}
},
{
@@ -416,7 +520,7 @@
"mode": "raw",
"raw": "{\n \"image_id\": {{image_id}}\n}"
},
"url": "{{base_url}}/api/compositions/{{composition_id}}/set-main-image/"
"url": "{{base_url}}/compositions/{{composition_id}}/set-main-image/"
}
},
{
@@ -444,7 +548,7 @@
},
"method": "DELETE",
"header": [],
"url": "{{base_url}}/api/compositions/{{composition_id}}/images/{{image_id}}/"
"url": "{{base_url}}/compositions/{{composition_id}}/images/{{image_id}}/"
}
},
{
@@ -481,7 +585,7 @@
"mode": "raw",
"raw": "{\n \"name\": \"نام بروزرسانی شده\"\n}"
},
"url": "{{base_url}}/api/compositions/{{composition_id}}/"
"url": "{{base_url}}/compositions/{{composition_id}}/"
}
},
{
@@ -509,7 +613,7 @@
},
"method": "DELETE",
"header": [],
"url": "{{base_url}}/api/compositions/{{composition_id}}/"
"url": "{{base_url}}/compositions/{{composition_id}}/"
}
}
]
@@ -523,7 +627,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/campaigns/"
"url": "{{base_url}}/campaigns/"
}
},
{
@@ -531,11 +635,11 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/campaigns/1/"
"url": "{{base_url}}/campaigns/1/"
}
},
{
"name": "POST Create Campaign",
"name": "POST Create Campaign (Admin)",
"request": {
"method": "POST",
"header": [
@@ -548,11 +652,31 @@
"mode": "raw",
"raw": "{\n \"name\": \"کمپین تست\",\n \"description\": \"این یک کمپین تستی است\",\n \"start_time\": \"2026-06-01T00:00:00Z\",\n \"end_time\": \"2026-12-31T23:59:59Z\"\n}"
},
"url": "{{base_url}}/api/campaigns/"
"url": "{{base_url}}/campaigns/",
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
{
"name": "POST Create Campaign with Image",
"name": "POST Create Campaign with Image (Admin)",
"request": {
"method": "POST",
"header": [],
@@ -586,7 +710,27 @@
}
]
},
"url": "{{base_url}}/api/campaigns/"
"url": "{{base_url}}/campaigns/",
"auth": {
"type": "apikey",
"apikey": [
{
"key": "key",
"value": "Authorization",
"type": "string"
},
{
"key": "value",
"value": "Token {{admin_token}}",
"type": "string"
},
{
"key": "in",
"value": "header",
"type": "string"
}
]
}
}
},
{
@@ -594,7 +738,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/campaigns/active/"
"url": "{{base_url}}/campaigns/active/"
}
},
{
@@ -602,7 +746,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/campaigns/upcoming/"
"url": "{{base_url}}/campaigns/upcoming/"
}
},
{
@@ -610,7 +754,7 @@
"request": {
"method": "GET",
"header": [],
"url": "{{base_url}}/api/campaigns/ended/"
"url": "{{base_url}}/campaigns/ended/"
}
},
{
@@ -647,7 +791,7 @@
"mode": "raw",
"raw": "{\n \"name\": \"نام بروزرسانی شده\"\n}"
},
"url": "{{base_url}}/api/campaigns/1/"
"url": "{{base_url}}/campaigns/1/"
}
},
{
@@ -675,7 +819,7 @@
},
"method": "DELETE",
"header": [],
"url": "{{base_url}}/api/campaigns/1/"
"url": "{{base_url}}/campaigns/1/"
}
}
]
@@ -684,7 +828,7 @@
"variable": [
{
"key": "base_url",
"value": "http://127.0.0.1:8000",
"value": "https://zoneco.org/api",
"type": "string"
},
{
@@ -711,6 +855,11 @@
"key": "admin_token",
"value": "",
"type": "string"
},
{
"key": "my_email_or_phone",
"value": "ali@example.com",
"type": "string"
}
]
}