Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
555d117
Update SITE_VERSION to 2.13.6
shubhamgoel02 Jan 17, 2025
1d26047
code reverted
arushsinghh Jan 20, 2025
6d3a804
1392 changes reverted
arushsinghh Jan 20, 2025
e2c6966
Update production.py
shubhamgoel02 Jan 21, 2025
2a70b4d
user authentication url
vimugdhabatra Jan 21, 2025
c83735a
Github 1392 changes
arushsinghh Jan 27, 2025
080bbf9
Invite admin user button commented
arushsinghh Jan 29, 2025
05e5ea7
Deleted unwanted file
vimugdhabatra Jan 29, 2025
1d00e85
user authentication commented
vimugdhabatra Jan 29, 2025
60851b4
Invite admin user button commented (#1730)
vimugdhabatra Jan 29, 2025
ac91204
2.13.8
shubhamgoel-tomhorn Jan 29, 2025
f6fb0eb
user authentication: restricting uninvited users to login
vimugdhabatra Jan 30, 2025
e54721d
index.html file change
vimugdhabatra Jan 30, 2025
15b7735
first name updated by admin user is finalised
vimugdhabatra Jan 30, 2025
1e9479c
chat experience auto refresh: by Ajay
vimugdhabatra Jan 31, 2025
fde9a1b
user authentication fix and epic2 matomo changes
vimugdhabatra Feb 5, 2025
a30bfc9
conflict of main and user authencation
vimugdhabatra Feb 5, 2025
29e8193
epic2 matomo and user auth full functionality (#1739)
vimugdhabatra Feb 5, 2025
f535688
2.13.9-rc.3
shubhamgoel02 Feb 5, 2025
c8ce100
conflict resolved
vimugdhabatra Feb 5, 2025
0c62ef6
conflict resolved (#1740)
vimugdhabatra Feb 5, 2025
ab4cc91
2.13.9-rc.5
shubhamgoel02 Feb 5, 2025
4db72c3
invite admin css fix
vimugdhabatra Feb 6, 2025
a0f0f1e
invite admin css fix (#1741)
vimugdhabatra Feb 6, 2025
080ab9c
discription added for image title as alt text (#1742)
kushvah-ajaysingh-nagarro Feb 11, 2025
15c516b
2.13.9
shubhamgoel02 Feb 11, 2025
14f82d9
reply url: removed locale for user authentication
vimugdhabatra Feb 13, 2025
25f548b
reply url: removed locale for user authentication (#1743)
vimugdhabatra Feb 13, 2025
f38eb31
share feature
Feb 19, 2025
d312fb3
2.13.10-rc.3
shubhamgoel02 Feb 21, 2025
f3f3e0b
user authentication redirect url reverse, matomo email masking
vimugdhabatra Feb 21, 2025
14672cd
user authentication redirect url reverse, matomo email masking (#1746)
vimugdhabatra Feb 21, 2025
04c4ac3
Update production.py
shubhamgoel02 Feb 26, 2025
cc8456b
rating and feedback
kushvah-ajaysingh-nagarro Feb 27, 2025
247363d
rating and feedback (#1747)
kushvah-ajaysingh-nagarro Feb 27, 2025
5d9243d
rating setting
kushvah-ajaysingh-nagarro Feb 27, 2025
f0560cb
rating setting (#1748)
kushvah-ajaysingh-nagarro Feb 27, 2025
58a30bd
2.13.10-rc.8
shubhamgoel02 Feb 27, 2025
1b9b585
list reviews
kushvah-ajaysingh-nagarro Feb 27, 2025
59414d9
list reviews (#1749)
kushvah-ajaysingh-nagarro Feb 27, 2025
a8b6504
2.13.10-rc.9
shubhamgoel02 Feb 27, 2025
69d7221
Merge branch 'development' into share_article
kushvah-ajaysingh-nagarro Feb 27, 2025
bc5aea0
merge development
kushvah-ajaysingh-nagarro Feb 27, 2025
2994088
share feature (#1744)
kushvah-ajaysingh-nagarro Feb 27, 2025
e8cad26
move share button above feedback
kushvah-ajaysingh-nagarro Feb 27, 2025
e392780
move share button above feedback (#1750)
kushvah-ajaysingh-nagarro Feb 27, 2025
9c1c26c
secure and httponly issue fix
kushvah-ajaysingh-nagarro Feb 28, 2025
932bca8
secure and httponly issue fix (#1751)
kushvah-ajaysingh-nagarro Feb 28, 2025
37ca5ac
2.13.10-rc.10
shubhamgoel02 Feb 28, 2025
b574133
commented proxy
kushvah-ajaysingh-nagarro Feb 28, 2025
9313464
commented proxy (#1752)
kushvah-ajaysingh-nagarro Feb 28, 2025
cfd0beb
2.13.10-rc.11
shubhamgoel02 Feb 28, 2025
29a63cd
commented enforce https
kushvah-ajaysingh-nagarro Feb 28, 2025
7ea2fbf
commented enforce https (#1753)
kushvah-ajaysingh-nagarro Feb 28, 2025
753cbb0
2.13.10-rc.12
shubhamgoel02 Feb 28, 2025
c6c5e26
Vulnerability issue secure httponly (#1754)
kushvah-ajaysingh-nagarro Feb 28, 2025
180576f
superset iogt widget complete code
vimugdhabatra Mar 2, 2025
31a9571
superset iogt widget complete code (#1755)
vimugdhabatra Mar 2, 2025
28ff52a
Merge branch 'epic2_user_auth' into main
vimugdhabatra Mar 2, 2025
cbb3165
merged main into epic2_user_auth
vimugdhabatra Mar 2, 2025
962d509
2.13.11-rc.1
shubhamgoel02 Mar 3, 2025
a491308
questionnarie changes
vimugdhabatra Mar 3, 2025
6e88565
questionnarie changes (#1757)
vimugdhabatra Mar 3, 2025
9d11844
2.13.11-rc.2
shubhamgoel02 Mar 3, 2025
b115629
Merge branch 'main' into development
kushvah-ajaysingh-nagarro Mar 4, 2025
15d3a41
Merge branch 'development_2' into epic2_user_auth
Mar 4, 2025
c6fa3f1
Development (#1758)
vimugdhabatra Mar 4, 2025
db0de88
2.13.11-rc.3
shubhamgoel02 Mar 4, 2025
da625c9
feedback enhancements
kushvah-ajaysingh-nagarro Mar 7, 2025
eb5be90
Merge branch 'epic2_user_auth' into development_2
Mar 10, 2025
92f2c6f
Merge branch 'epic2_user_auth' into development_2
Mar 10, 2025
8242532
Development 2 (#1760)
kushvah-ajaysingh-nagarro Mar 10, 2025
9fb90c4
2.13.11-rc.5
shubhamgoel02 Mar 10, 2025
b61d52b
Share and rating feedback (#1761)
kushvah-ajaysingh-nagarro Mar 11, 2025
e31d64f
2.13.11
shubhamgoel02 Mar 11, 2025
54efe59
Update base.py
vimugdhabatra Mar 12, 2025
525beba
Update urls.py for production user auth
vimugdhabatra Mar 12, 2025
308a31f
2.13.12-rc.2
shubhamgoel02 Mar 12, 2025
03fe738
Update urls.py
vimugdhabatra Mar 13, 2025
890e9b0
Update base.py
vimugdhabatra Mar 13, 2025
5434cdc
2.13.12-rc.3
shubhamgoel02 Mar 13, 2025
ebf7c57
print statement added for debugging of env variables
vimugdhabatra Mar 13, 2025
2f5d9cb
print statement added for debugging of env variables (#1762)
vimugdhabatra Mar 13, 2025
e8db61a
2.13.12-rc.4
shubhamgoel02 Mar 13, 2025
06e3c21
merged main
shubhamgoel02 Mar 13, 2025
f179022
2.13.12-rc.5
shubhamgoel02 Mar 13, 2025
a439530
Bugfix/login profile button (#1764)
shubhamgoel02 Mar 13, 2025
1016f57
Merge pull request #1 from unicef/epic2_user_auth
vimugdhabatra Mar 13, 2025
f74c93c
redirect uri change for production
vimugdhabatra Mar 13, 2025
e157a10
merged main
shubhamgoel02 Mar 13, 2025
ee5ef04
2.13.13-rc.1
shubhamgoel02 Mar 13, 2025
32223f5
Merge pull request #1 from unicef/epic2_user_auth (#1765)
shubhamgoel02 Mar 17, 2025
a7130eb
Update base.py
shubhamgoel02 Mar 17, 2025
a9bea00
Update urls.py
shubhamgoel02 Mar 17, 2025
e1177ce
2.13.13-rc.2
shubhamgoel02 Mar 17, 2025
6304bd0
offline functionality
vimugdhabatra Mar 19, 2025
37669fb
offline functionality
vimugdhabatra Mar 19, 2025
1757434
Merge branch 'epic2_user_auth' of https://github.com/vimugdhabatra/io…
vimugdhabatra Mar 19, 2025
6830f80
Update urls.py
vimugdhabatra Mar 19, 2025
10bcfcd
Update base.py
vimugdhabatra Mar 19, 2025
c78d8a5
Epic2 user auth (#1766)
vimugdhabatra Mar 19, 2025
73093f2
Update production.py
shubhamgoel02 Mar 19, 2025
6a9378b
questionnarie change
vimugdhabatra Mar 20, 2025
890dae1
questionnarie change (#1768)
vimugdhabatra Mar 20, 2025
f8d097d
2.13.13-rc.5
shubhamgoel02 Mar 20, 2025
602920d
registration survey not showing in form data fix
vimugdhabatra Mar 20, 2025
f122af0
2.13.13-rc.6
shubhamgoel02 Mar 20, 2025
9e002be
message error offline
vimugdhabatra Mar 26, 2025
b195fce
Merge branch 'epic2_user_auth' into epic2_user_auth
vimugdhabatra Mar 26, 2025
16ecad4
Epic2 user auth (#1772)
vimugdhabatra Mar 26, 2025
e2860ed
3.0.1-rc.2
shubhamgoel02 Mar 27, 2025
07ad7bf
Update base.py
vimugdhabatra Mar 27, 2025
177f3d7
3.0.1-rc.3
shubhamgoel02 Mar 27, 2025
ff0f7e0
offline functionality warning and sandbox issue fix
vimugdhabatra Mar 30, 2025
34f30ed
Merge branch 'epic2_user_auth' of https://github.com/unicef/iogt into…
vimugdhabatra Mar 31, 2025
a124b4b
Merge branch 'offline_enhancement' into epic2_user_auth
vimugdhabatra Mar 31, 2025
b1cc060
Epic2 user auth (#1775)
vimugdhabatra Mar 31, 2025
68c97f5
3.0.2-rc.1
shubhamgoel02 Mar 31, 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
37 changes: 0 additions & 37 deletions admin_login/azure_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,6 @@ def authenticate(self, request, username=None, password=None, **kwargs):
Authenticate user via Azure AD using username (email) and password.
"""
pass
# azure_details = get_azure_auth_details()
#
# # Initialize MSAL client
# msal_client = PublicClientApplication(
# client_id=azure_details['client_id'],
# authority=azure_details['authority'],
# )
#
# # Acquire token using username and password
# try:
# token_data = msal_client.acquire_token_by_username_password(
# username=username,
# password=password,
# scopes=azure_details['scope']
# )
#
# if 'access_token' in token_data:
# # Token is valid, retrieve or create the user
# user, created = User.objects.get_or_create(
# email=username, defaults={'username': username}
# )
# return user
# else:
# return None
# except Exception as e:
# # Log or handle error appropriately
# print(f"Error during Azure AD authentication: {e}")
# return None
#
# def get_user(self, user_id):
# """
# Retrieve user by their ID.
# """
# try:
# return User.objects.get(pk=user_id)
# except User.DoesNotExist:
# return None


class AzureADSignupService:
Expand Down
3 changes: 2 additions & 1 deletion admin_login/azure_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ def payload_for_access_token(code):
'client_secret': azure_details['client_secret'],
}

return data
return data

10 changes: 5 additions & 5 deletions admin_login/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
from django.views import View
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied

from admin_login.azure_backend import AzureADSignupService, get_azure_auth_details

User = get_user_model()
# Create your views here.



class AzureADSignupView(View):
template_name = 'signup.html'

Expand Down Expand Up @@ -77,20 +79,18 @@ def _save_user_info(self, user_info):
name = user_info.get('name')
given_name = user_info.get('given_name')

if not User.objects.filter(email=email, is_active=True, is_superuser=True).exists():
raise PermissionDenied("Access Denied: You are not allowed to sign up.")
# Check if the user already exists
user, created = User.objects.get_or_create(
email=email,
defaults={
'username': name,
'username': email,
'first_name': given_name,
'is_staff': True, # Make the user an admin
'is_superuser': True, # Grant superuser permissions
},
)
if not created:
# Update user details if necessary
user.first_name = given_name
user.save()

user.is_superuser = True
user.is_staff = True
Expand Down
28 changes: 27 additions & 1 deletion home/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.contrib import admin
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from django.db.models import Avg, Count
from django.utils.html import format_html
from django.urls import reverse

from home.models import ManifestSettings, SVGToPNGMap
from home.models import ManifestSettings, SVGToPNGMap, Article, ArticleFeedback


class ManifestSettingsAdmin(ModelAdmin):
Expand All @@ -21,3 +24,26 @@ class SVGToPNGMapAdmin(admin.ModelAdmin):
list_display = ('id', 'svg_path', 'fill_color', 'stroke_color', 'png_image_file')


class ArticleAdmin(ModelAdmin):
model = Article
menu_label = "Article Ratings"
menu_icon = "form"
list_display = ("title", "average_rating", "number_of_reviews", "view_feedback_button")
search_fields = ("title",)
ordering = ("-average_rating", "-number_of_reviews") # Sort by rating & reviews in descending order

def view_feedback_button(self, obj):
"""
Creates a button to view feedback for an article.
"""
url = reverse("admin_article_feedback", args=[obj.id])
return format_html('<a class="button button-small" href="{}">View Feedback</a>', url)
view_feedback_button.short_description = "Feedback"

def has_add_permission(self, request):
"""
Hide the 'Add Article' button in the Wagtail admin panel.
"""
return False # Prevents adding new articles from this page

modeladmin_register(ArticleAdmin)
8 changes: 8 additions & 0 deletions home/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig

class HomeConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "home"

def ready(self):
import home.signals # Ensure signals are loaded
31 changes: 31 additions & 0 deletions home/migrations/0056_articlefeedback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.2.25 on 2025-02-26 05:18

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('home', '0055_enable_use_json_field'),
]

operations = [
migrations.CreateModel(
name='ArticleFeedback',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('session_id', models.CharField(blank=True, max_length=255, null=True)),
('rating', models.IntegerField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)])),
('feedback', models.TextField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('article', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='feedbacks', to='home.article')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('article', 'user')},
},
),
]
26 changes: 26 additions & 0 deletions home/migrations/0057_feedbacksettings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.25 on 2025-02-27 08:29

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0069_log_entry_jsonfield'),
('home', '0056_articlefeedback'),
]

operations = [
migrations.CreateModel(
name='FeedbackSettings',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('enable_feedback', models.BooleanField(default=True, verbose_name='Enable Feedback')),
('site', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.site')),
],
options={
'verbose_name': 'Rating Settings',
},
),
]
23 changes: 23 additions & 0 deletions home/migrations/0058_auto_20250306_1311.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.25 on 2025-03-06 13:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('home', '0057_feedbacksettings'),
]

operations = [
migrations.AddField(
model_name='article',
name='average_rating',
field=models.FloatField(default=0.0, null=True),
),
migrations.AddField(
model_name='article',
name='number_of_reviews',
field=models.PositiveIntegerField(default=0, null=True),
),
]
53 changes: 53 additions & 0 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
get_all_renditions_urls,
)
import iogt.iogt_globals as globals_
from django.db.models import Avg, Count

User = get_user_model()
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -432,9 +433,26 @@ class Meta:
verbose_name_plural = _("articles")


@register_setting
class FeedbackSettings(BaseSetting):
"""Global setting to enable or disable feedback submission for all articles."""
enable_feedback = models.BooleanField(default=True, verbose_name="Enable Feedback")

panels = [
FieldPanel("enable_feedback"),
]

class Meta:
verbose_name = "Rating Settings"


class Article(AbstractArticle):
tags = ClusterTaggableManager(through='ArticleTaggedItem', blank=True)

# New fields for precomputed values
average_rating = models.FloatField(default=0.0, null=True)
number_of_reviews = models.PositiveIntegerField(default=0, null=True)

content_panels = AbstractArticle.content_panels + [
MultiFieldPanel([
InlinePanel('recommended_articles',
Expand Down Expand Up @@ -463,13 +481,48 @@ def get_context(self, request):
for recommended_article in self.recommended_articles.all() if recommended_article.article.live
]

# Fetch feedback setting correctly
feedback_settings = FeedbackSettings.for_request(request)
context["feedback_enabled"] = feedback_settings.enable_feedback

# Get the latest 5 feedbacks
context["feedbacks"] = self.feedbacks.order_by('-created_at')[:3]
return context

def serve(self, request):
response = super().serve(request)
if response.status_code == status.HTTP_200_OK:
User.record_article_read(request=request, article=self)
return response

def update_feedback_metrics(self):
"""
Updates the average rating and number of reviews for this article.
"""
feedback_stats = self.feedbacks.aggregate(
avg_rating=Avg("rating"), review_count=Count("id")
)
self.average_rating = feedback_stats["avg_rating"] or 0.0
self.number_of_reviews = feedback_stats["review_count"] or 0
self.save(update_fields=["average_rating", "number_of_reviews"])

def compute_average_rating(self):
return self.average_rating if self.average_rating else 0

def compute_number_of_reviews(self):
return self.number_of_reviews if self.number_of_reviews else 0


class ArticleFeedback(models.Model):
article = models.ForeignKey(Article, on_delete=models.CASCADE, related_name='feedbacks')
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
session_id = models.CharField(max_length=255, null=True, blank=True)
rating = models.IntegerField(choices=[(i, i) for i in range(1, 6)])
feedback = models.TextField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
unique_together = ('article', 'user')


class MiscellaneousIndexPage(Page):
Expand Down
12 changes: 12 additions & 0 deletions home/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from .models import ArticleFeedback

@receiver(post_save, sender=ArticleFeedback)
@receiver(post_delete, sender=ArticleFeedback)
def update_article_feedback_metrics(sender, instance, **kwargs):
"""
Update the article's feedback metrics whenever a feedback entry is added, updated, or deleted.
"""
if instance.article:
instance.article.update_feedback_metrics()
4 changes: 4 additions & 0 deletions home/static/css/custom_admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Hide the "Add Article" button in the Wagtail admin */
a[href*="/admin/home/article/create/"] {
display: none !important;
}
Binary file added home/static/icons/email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/icons/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/icons/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/icons/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/icons/whatsapp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/icons/x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading