Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
96bd0c5
Implement revert detection for already-reviewed edits
Teja-Sri-Surya Oct 23, 2025
99281c5
Add LiftWing model visualization feature (clean implementation)
Teja-Sri-Surya Oct 25, 2025
098fb08
Fix views.py - Add complete LiftWing functionality
Teja-Sri-Surya Oct 25, 2025
3b70756
Merge upstream/main into liftwing-clean - Resolve conflicts in views,…
Teja-Sri-Surya Oct 25, 2025
f331cbf
Refresh branch to resolve GitHub conflict detection
Teja-Sri-Surya Oct 25, 2025
fee338e
feat: Add benchmark command for superseded additions test using Media…
Teja-Sri-Surya Oct 26, 2025
1a104e4
feat: Add word-level annotation system for Issue #114
Teja-Sri-Surya Oct 26, 2025
5c1f505
fix: Remove non-existent model imports from admin.py
Teja-Sri-Surya Oct 26, 2025
c019727
fix: Fix word annotation engine and admin imports
Teja-Sri-Surya Oct 26, 2025
141ef1b
fix: Add User-Agent header to MediaWiki REST API requests
Teja-Sri-Surya Oct 26, 2025
8dffda4
Implement revert detection for already-reviewed edits
Teja-Sri-Surya Oct 28, 2025
fdf645f
feat: Add benchmark command for superseded additions (Issue #113)
Teja-Sri-Surya Oct 28, 2025
102326a
fix: Enhance word annotation system with admin registration, move det…
Teja-Sri-Surya Oct 28, 2025
7f2f3b6
docs: Add visual summary of word annotation fixes with before/after c…
Teja-Sri-Surya Oct 28, 2025
311a509
docs: Add final report summarizing all fixes and current PR status
Teja-Sri-Surya Oct 28, 2025
bee7056
docs: Add step-by-step guide for resolving merge conflicts
Teja-Sri-Surya Oct 28, 2025
af5221c
refactor: Remove unrelated features from PR #119 - keep only word ann…
Teja-Sri-Surya Oct 28, 2025
cbff808
Resolve merge conflicts with main - keep both features
Teja-Sri-Surya Oct 28, 2025
92603ac
docs: Add comprehensive documentation of conflict resolution and cleanup
Teja-Sri-Surya Oct 28, 2025
857e545
docs: Add conflicts resolution status
Teja-Sri-Surya Oct 28, 2025
f517fea
docs: Add comprehensive GitHub conflict resolution guide with exact c…
Teja-Sri-Surya Oct 28, 2025
d834611
fix: Add missing FlaggedRevs view functions and URL patterns
Teja-Sri-Surya Oct 28, 2025
6d4f21b
Merge branch 'main' into issue-114-word-annotation
Teja-Sri-Surya Oct 28, 2025
9ecd96b
Fix: Add missing require_POST import and create word annotation migra…
Teja-Sri-Surya Oct 29, 2025
a30d5fc
docs: Clean up temporary execution guides
Teja-Sri-Surya Oct 29, 2025
414f115
fix: Improve auto-fill for revision ID with Enter key and better feed…
Teja-Sri-Surya Oct 29, 2025
0ed8c24
docs: Add comprehensive testing guide with working Page IDs
Teja-Sri-Surya Oct 29, 2025
8e6c3cd
fix: Auto-fill now shows only revisions with annotations
Teja-Sri-Surya Oct 29, 2025
4eca374
Merge branch 'main' into issue-114-word-annotation
Teja-Sri-Surya Oct 29, 2025
6f4be1f
Merge branch 'main' into issue-114-word-annotation
Teja-Sri-Surya Oct 31, 2025
c894dc8
fix: CI lint/security issues for PR #119
Teja-Sri-Surya Oct 29, 2025
51285f6
fix: Remove duplicate functions and resolve CI lint/security issues f…
Teja-Sri-Surya Nov 1, 2025
4aec698
style: Auto-format code with ruff
Teja-Sri-Surya Nov 1, 2025
2c64b3f
style: Format settings.py
Teja-Sri-Surya Nov 1, 2025
0ebfe36
fix: Use camelCase field names in FlaggedRevs API responses and add w…
Teja-Sri-Surya Nov 1, 2025
6ee7fe5
fix: Update test assertions to match camelCase API field names
Teja-Sri-Surya Nov 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 286 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
# 🧪 Testing Guide for Word Annotation Feature

## ✅ **Auto-Fill Feature Fixed!**

The auto-fill for Revision ID now works in **3 ways**:

1. **Press Enter** after typing Page ID
2. **Tab away** from the Page ID field
3. **Click outside** the Page ID field

The Revision ID will show:
- `Loading...` while fetching
- `Latest: 123456789` when successful
- `No revisions found` if page has no data
- `Error loading revisions` if API fails

---

## 📊 **Working Page IDs in Your Database**

Use these **real Page IDs** that exist in your local database:

| Page ID | Title | Language |
|---------|-------|----------|
| **534366** | Barack Obama | English |
| **9504027** | List of Hollyoaks characters | English |
| **5935** | The Church of Jesus Christ of Latter-day Saints | English |
| **248224** | अल्लू अर्जुन | Hindi |
| **190306** | कार्तिकेय | Hindi |
| **4877** | कृष्ण | Hindi |
| **18322** | भगत सिंह | Hindi |
| **59** | भारत | Hindi |
| **32193** | भारतीय राज्यों के वर्तमान राज्यपालों की सूची | Hindi |
| **217426** | योगी आदित्यनाथ | Hindi |

---

## 🎯 **How to Test the Auto-Fill Feature**

### **Step 1: Open the Word Annotation Page**

```
http://127.0.0.1:8000/word-annotation/
```

### **Step 2: Enter a Page ID**

Try one of these:

```
Page ID: 534366
```
(Barack Obama article)

### **Step 3: Trigger Auto-Fill**

Do ONE of these:
- ✅ Press **Enter** key
- ✅ Press **Tab** key
- ✅ Click outside the field

### **Step 4: Watch the Revision ID Field**

You should see:
1. Placeholder changes to `Loading...`
2. Then either:
- ✅ **Success**: Revision ID auto-fills (e.g., `1234567890`)
- ❌ **No data**: Shows `No revisions found`

### **Step 5: Click "Load Annotations"**

The page will load word annotations if they exist!

---

## 🧪 **Quick Test Commands**

### **Test 1: Check Available Pages**

```powershell
cd C:\Users\hp\Desktop\Outreachy\PendingChangesBot-ng\app
python manage.py shell -c "from reviews.models import PendingPage; [print(f'Page ID: {p.pageid:>10} | {p.title}') for p in PendingPage.objects.all()[:10]]"
```

### **Test 2: Check Revisions for a Page**

```powershell
python manage.py shell -c "from reviews.models import PendingRevision, PendingPage; page = PendingPage.objects.get(pageid=534366); revs = PendingRevision.objects.filter(page=page)[:5]; print(f'Page: {page.title}'); [print(f' Revision: {r.revid} by {r.user_name} at {r.timestamp}') for r in revs]"
```

### **Test 3: Check Word Annotations**

```powershell
python manage.py shell -c "from reviews.models import WordAnnotation; count = WordAnnotation.objects.count(); print(f'Total Word Annotations: {count}')"
```

---

## 🌐 **Testing the Web Interface**

### **Test Scenario 1: Barack Obama Article**

1. **Page ID**: `534366`
2. Press **Enter** or **Tab**
3. Revision ID should auto-fill
4. Click **"Load Annotations"**
5. See word-level annotations

### **Test Scenario 2: Hindi Article (भारत)**

1. **Page ID**: `59`
2. Press **Enter**
3. Check auto-fill works
4. Load annotations

### **Test Scenario 3: Manual Revision ID**

1. **Page ID**: `534366`
2. Wait for auto-fill
3. **Manually change** Revision ID to a different number
4. Click **"Load Annotations"**
5. Should load that specific revision

---

## 🔍 **What Should Happen**

### **✅ Success Path:**

1. Enter Page ID: `534366`
2. Press Enter
3. Revision ID auto-fills: e.g., `1316772466`
4. Placeholder shows: `Latest: 1316772466`
5. Click "Load Annotations"
6. Words display with color-coded authors

### **❌ Error Paths:**

#### **Page Not Found:**
```
Input: Page ID: 99999999
Result: "No revisions found"
```

#### **No Annotations Yet:**
```
Input: Page ID: 534366
Load Annotations Result: "No annotations found for this revision"
```

**Solution**: Run annotation commands first:
```powershell
python manage.py annotate_article 534366
```

---

## 📊 **API Endpoints to Test**

### **1. Get Revisions (Auto-Fill Uses This)**

```
http://127.0.0.1:8000/api/annotations/revisions/?page_id=534366
```

**Expected Response:**
```json
{
"revisions": [
{
"revision_id": 1316772466,
"timestamp": "2024-03-15T10:30:00",
"user": "ExampleUser",
"comment": "Updated article"
}
]
}
```

### **2. Get Word Annotations**

```
http://127.0.0.1:8000/api/annotations/words/?page_id=534366&revision_id=1316772466
```

**Expected Response:**
```json
{
"annotations": [
{
"word": "Barack",
"author": "Editor1",
"is_moved": false,
"is_deleted": false
}
],
"authors": ["Editor1", "Editor2"]
}
```

---

## 🐛 **Troubleshooting**

### **Issue 1: "No revisions found"**

**Cause**: Page has no revisions in database

**Solution**:
```powershell
# Check if page has revisions
python manage.py shell -c "from reviews.models import PendingRevision, PendingPage; page = PendingPage.objects.get(pageid=534366); print(f'Revisions: {PendingRevision.objects.filter(page=page).count()}')"
```

### **Issue 2: Auto-fill doesn't work**

**Cause**: Multiple possible causes

**Solutions**:
1. Check console (F12) for JavaScript errors
2. Verify API endpoint works: `/api/annotations/revisions/?page_id=534366`
3. Make sure you pressed Enter/Tab
4. Check server is running

### **Issue 3: "No annotations found"**

**Cause**: Annotations haven't been generated yet

**Solution**:
```powershell
# Generate annotations for a page
python manage.py annotate_article 534366
```

---

## ✅ **Changes Made to Fix Auto-Fill**

### **Before:**
- Only worked when clicking outside field
- No visual feedback
- No error handling

### **After:**
- ✅ Works with Enter key
- ✅ Works with Tab key
- ✅ Works when clicking outside
- ✅ Shows "Loading..." during fetch
- ✅ Shows "No revisions found" on error
- ✅ Shows "Latest: XXX" on success
- ✅ Better error handling

---

## 🎉 **Testing Checklist**

- [ ] Server is running (`python manage.py runserver`)
- [ ] Word annotation page loads (`/word-annotation/`)
- [ ] Enter Page ID: `534366`
- [ ] Press **Enter** key
- [ ] Revision ID auto-fills ✅
- [ ] Placeholder shows "Latest: XXX" ✅
- [ ] Click "Load Annotations"
- [ ] Page displays results (or "No annotations found")
- [ ] Try other Page IDs from the list
- [ ] Test API endpoints in browser

---

## 📝 **Quick Copy-Paste Test**

```
1. Open: http://127.0.0.1:8000/word-annotation/
2. Page ID: 534366
3. Press: Enter
4. Wait: Revision ID fills
5. Click: Load Annotations
```

---

**Created**: October 28, 2025
**Feature**: Auto-fill for Revision ID
**Status**: ✅ Working
**Commit**: 414f115

10 changes: 10 additions & 0 deletions app/reviewer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@

PYWIKIBOT_SITE_FAMILY = os.getenv("PYWIKIBOT_SITE_FAMILY", "wikipedia")

# Pending changes approval configuration
# Enable/disable dry-run mode for pending changes approval
# When True, only allows approvals on test pages (Merkityt_versiot_-kokeilu/*)
# When False, allows approvals on all pages
PENDING_CHANGES_DRY_RUN = os.getenv("PENDING_CHANGES_DRY_RUN", "True").lower() in (
"true",
"1",
"yes",
)

# ORES model thresholds (global defaults, per-wiki config takes precedence)
ORES_DAMAGING_THRESHOLD = float(os.getenv("ORES_DAMAGING_THRESHOLD", "0.3"))
ORES_GOODFAITH_THRESHOLD = float(os.getenv("ORES_GOODFAITH_THRESHOLD", "0.7"))
Expand Down
38 changes: 37 additions & 1 deletion app/reviews/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from .models import (
EditorProfile,
FlaggedRevsStatistics,
ModelScores,
PendingPage,
PendingRevision,
ReviewActivity,
RevisionAnnotation,
Wiki,
WikiConfiguration,
WordAnnotation,
)
from .models.flaggedrevs_statistics import FlaggedRevsStatistics, ReviewActivity


@admin.register(Wiki)
Expand Down Expand Up @@ -57,6 +60,39 @@ class ModelScoresAdmin(admin.ModelAdmin):
readonly_fields = ("ores_fetched_at",)


@admin.register(WordAnnotation)
class WordAnnotationAdmin(admin.ModelAdmin):
list_display = (
"page",
"revision_id",
"word",
"author_user_name",
"position",
"is_moved",
"is_deleted",
)
search_fields = ("word", "author_user_name", "stable_word_id")
list_filter = ("page__wiki", "is_moved", "is_modified", "is_deleted")
readonly_fields = ("created_at",)
ordering = ("page", "revision_id", "position")


@admin.register(RevisionAnnotation)
class RevisionAnnotationAdmin(admin.ModelAdmin):
list_display = (
"page",
"revision_id",
"status",
"words_annotated",
"created_at",
"completed_at",
)
search_fields = ("page__title",)
list_filter = ("status", "page__wiki", "created_at")
readonly_fields = ("created_at", "updated_at")
ordering = ("-created_at",)


@admin.register(FlaggedRevsStatistics)
class FlaggedRevsStatisticsAdmin(admin.ModelAdmin):
list_display = (
Expand Down
5 changes: 5 additions & 0 deletions app/reviews/annotations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from .engine import WordAnnotationEngine

__all__ = ["WordAnnotationEngine"]
Loading