# Template Upload Instructions - Step by Step

## 🚨 Problem
Django can't find the templates even after upload. This means either:
1. Files uploaded to wrong location
2. Wrong file permissions
3. Application not restarted

## ✅ Solution - Follow These Exact Steps

### Step 1: Verify Upload Location

The templates MUST be uploaded to this EXACT path:
```
/home/acbptxvs/public_html/branchbusinessadvance.co.ke/templates/payments/
```

**NOT** any of these:
- ❌ `/home/acbptxvs/templates/payments/`
- ❌ `/home/acbptxvs/public_html/templates/payments/`
- ❌ `/home/acbptxvs/public_html/branchbusinessadvance.co.ke/payments/templates/`

### Step 2: Upload Files via cPanel File Manager

1. **Login to cPanel**
   - Go to: https://branchbusinessadvance.co.ke:2083
   - Login with your credentials

2. **Open File Manager**
   - Click "File Manager" icon
   - Navigate to: `public_html/branchbusinessadvance.co.ke/templates/payments/`

3. **Verify You're in the Right Place**
   - You should see these existing files:
     - `configuration.html`
     - `dashboard.html`
     - `test_payment.html`
     - `transactions.html`
   - If you DON'T see these files, you're in the WRONG directory!

4. **Upload New Templates**
   - Click "Upload" button at the top
   - Upload these 4 files:
     - `callbacks.html`
     - `transaction_detail.html`
     - `reprocess_transaction.html`
     - `my_payments.html`

5. **Verify Files Uploaded**
   - Refresh the file list
   - You should now see 8 HTML files total

### Step 3: Set File Permissions

1. **Select all 4 new files**
   - Check the boxes next to:
     - `callbacks.html`
     - `transaction_detail.html`
     - `reprocess_transaction.html`
     - `my_payments.html`

2. **Change Permissions**
   - Click "Permissions" button at the top
   - Set to: **644**
   - Or check: Owner (Read, Write), Group (Read), World (Read)
   - Click "Change Permissions"

### Step 4: Restart Application

**Option A: Via cPanel (Recommended)**
1. In cPanel, find "Setup Python App"
2. Click on it
3. Find your application (branchbusinessadvance.co.ke)
4. Click "Restart" button

**Option B: Via Terminal/SSH**
```bash
touch /home/acbptxvs/public_html/branchbusinessadvance.co.ke/passenger_wsgi.py
```

**Option C: Via File Manager**
1. Navigate to: `public_html/branchbusinessadvance.co.ke/`
2. Find file: `passenger_wsgi.py`
3. Right-click → "Touch" (updates modification time)

### Step 5: Verify Templates Work

1. **Clear your browser cache** (Ctrl+Shift+Delete)
2. Visit: https://branchbusinessadvance.co.ke/payments/callbacks/
3. Should now load without error

---

## 🔍 Diagnostic Script

If still not working, upload and run this diagnostic script:

1. **Upload `check_templates.py` to:**
   ```
   /home/acbptxvs/public_html/branchbusinessadvance.co.ke/
   ```

2. **Run it via Terminal:**
   ```bash
   cd /home/acbptxvs/public_html/branchbusinessadvance.co.ke
   python check_templates.py
   ```

3. **Check the output** - it will tell you:
   - If templates directory exists
   - Which files are present
   - Which files are missing
   - File permissions

---

## 📋 Quick Checklist

Before asking for help, verify:

- [ ] Files uploaded to `/home/acbptxvs/public_html/branchbusinessadvance.co.ke/templates/payments/`
- [ ] Can see existing templates (dashboard.html, transactions.html, etc.)
- [ ] All 4 new files uploaded (callbacks.html, transaction_detail.html, etc.)
- [ ] File permissions set to 644
- [ ] Application restarted
- [ ] Browser cache cleared
- [ ] Tried accessing: https://branchbusinessadvance.co.ke/payments/callbacks/

---

## 🆘 Still Not Working?

### Check 1: Verify Files Exist
Via SSH/Terminal:
```bash
ls -la /home/acbptxvs/public_html/branchbusinessadvance.co.ke/templates/payments/
```

Should show:
```
callbacks.html
configuration.html
dashboard.html
my_payments.html
reprocess_transaction.html
test_payment.html
transaction_detail.html
transactions.html
```

### Check 2: Verify Permissions
```bash
ls -la /home/acbptxvs/public_html/branchbusinessadvance.co.ke/templates/payments/*.html
```

All files should show: `-rw-r--r--` (644)

### Check 3: Check Django Settings
Via Django shell:
```python
from django.conf import settings
print(settings.BASE_DIR)
print(settings.TEMPLATES[0]['DIRS'])
```

Should output:
```
/home/acbptxvs/public_html/branchbusinessadvance.co.ke
[PosixPath('/home/acbptxvs/public_html/branchbusinessadvance.co.ke/templates')]
```

### Check 4: Test Template Loading
Via Django shell:
```python
from django.template.loader import get_template
template = get_template('payments/callbacks.html')
print("Template loaded successfully!")
```

If this fails, the file is not in the right place.

---

## 📁 Correct Directory Structure

Your production server should have this structure:

```
/home/acbptxvs/public_html/branchbusinessadvance.co.ke/
├── branch_system/
│   ├── settings.py
│   └── ...
├── payments/
│   ├── views.py
│   ├── models.py
│   └── ...
├── templates/
│   ├── base.html
│   ├── payments/
│   │   ├── callbacks.html          ← NEW
│   │   ├── configuration.html
│   │   ├── dashboard.html
│   │   ├── my_payments.html        ← NEW
│   │   ├── reprocess_transaction.html  ← NEW
│   │   ├── test_payment.html
│   │   ├── transaction_detail.html ← NEW
│   │   └── transactions.html
│   └── ...
├── manage.py
└── passenger_wsgi.py
```

---

## 💡 Common Mistakes

1. **Uploading to wrong directory**
   - Double-check you're in `templates/payments/` not `payments/templates/`

2. **Not restarting application**
   - Django caches template locations
   - MUST restart after uploading

3. **Wrong file permissions**
   - Files must be readable (644)
   - Directories must be executable (755)

4. **Browser cache**
   - Old error page cached
   - Clear cache or use incognito mode

---

## ✅ Success Indicators

You'll know it's working when:

1. ✅ `/payments/callbacks/` loads without error
2. ✅ Shows "Callback Logs" heading
3. ✅ Has filters and table (even if empty)
4. ✅ No "TemplateDoesNotExist" error

---

**Need more help?** Run the diagnostic script and share the output.
