added social media fields and referral count in customer list

This commit is contained in:
rizwanisready
2024-04-05 19:58:49 +05:30
parent 7591c23b78
commit 8d6de7745e
10 changed files with 104 additions and 18 deletions

View File

@@ -157,6 +157,10 @@ class ProfileSerializer(serializers.ModelSerializer):
"register_complete",
"has_active_subscription",
"has_preferences",
"linkedin_profile",
"youtube_profile",
"facebook_profile",
"instagram_profile",
]
def update(self, instance, validated_data):

View File

@@ -0,0 +1,41 @@
# Generated by Django 5.0.2 on 2024-04-05 13:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("accounts", "0005_appversion"),
]
operations = [
migrations.AddField(
model_name="iamprincipal",
name="facebook_profile",
field=models.URLField(
blank=True, null=True, verbose_name="Principal Facebook"
),
),
migrations.AddField(
model_name="iamprincipal",
name="instagram_profile",
field=models.URLField(
blank=True, null=True, verbose_name="Principal Instagram"
),
),
migrations.AddField(
model_name="iamprincipal",
name="linkedin_profile",
field=models.URLField(
blank=True, null=True, verbose_name="Principal LinkedIn"
),
),
migrations.AddField(
model_name="iamprincipal",
name="youtube_profile",
field=models.URLField(
blank=True, null=True, verbose_name="Principal Youtube"
),
),
]

View File

@@ -285,6 +285,30 @@ class IAmPrincipal(AbstractUser):
related_name="principal_groups",
)
register_complete = models.BooleanField(default=False)
linkedin_profile = models.URLField(
verbose_name="Principal LinkedIn",
max_length=200,
blank=True,
null=True,
)
instagram_profile = models.URLField(
verbose_name="Principal Instagram",
max_length=200,
blank=True,
null=True,
)
youtube_profile = models.URLField(
verbose_name="Principal Youtube",
max_length=200,
blank=True,
null=True,
)
facebook_profile = models.URLField(
verbose_name="Principal Facebook",
max_length=200,
blank=True,
null=True,
)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []

View File

@@ -1,5 +1,5 @@
import logging
from django.db.models import Count, Q
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.views import LogoutView
@@ -523,16 +523,10 @@ class CustomerListView(LoginRequiredMixin, generic.ListView):
action = resource_action.ACTION_READ
model = IAmPrincipal
template_name = "accounts/customer/customer_list.html"
context_object_name = "data_obj"
context_object_name = "data_objs"
def get_queryset(self):
user_types = [
resource_action.PRINCIPAL_TYPE_EVENT_USER,
resource_action.PRINCIPAL_TYPE_EVENT_MANAGER,
resource_action.PRINCIPAL_TYPE_FREE_USER,
]
return (
queryset = (
super()
.get_queryset()
.select_related("principal_type", "principal_source")
@@ -546,12 +540,22 @@ class CustomerListView(LoginRequiredMixin, generic.ListView):
| models.Q(
principal_type__name=resource_action.PRINCIPAL_TYPE_FREE_USER
),
# principal_type__name=resource_action.PRINCIPAL_TYPE_PLAYER,
# principal_type__in=user_types,
# deleted=False,
)
)
# Annotate the queryset with the count of referrals for each principal
queryset = queryset.annotate(
referral_count=Count(
"referrals_by_referrer",
filter=Q(
referrals_by_referrer__is_completed=True
), # Assuming you only want to count completed referrals
distinct=True, # Ensures referrals are not double-counted if there are multiple conditions or joins
)
)
return queryset
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_name"] = self.page_name

View File

@@ -331,6 +331,7 @@ class EventDetailView(generic.DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_name"] = self.page_name
event_id = self.object.id # Get the current event's ID
# Separate count for interested and going

View File

@@ -9,6 +9,7 @@ from django.utils.decorators import method_decorator
from accounts.models import IAmPrincipal, IAmPrincipalType
from goodtimes import services, constants
from decimal import Decimal
from manage_referrals.models import GoodTimeCoins
from manage_wallets import models
from django.conf import settings
from django.utils import timezone
@@ -356,6 +357,11 @@ class WithdrawalRequestCreateAPI(APIView):
def post(self, request, *args, **kwargs):
user = request.user
wallet = models.Wallet.objects.filter(principal=user).first()
coins_amount = (
GoodTimeCoins.objects.filter(active=True, deleted=False)
.last()
.value_in_pound
)
# Check if the user has a wallet and sufficient coins
if wallet is None or wallet.coins <= 0:
@@ -364,7 +370,8 @@ class WithdrawalRequestCreateAPI(APIView):
status=status.HTTP_400_BAD_REQUEST,
message=constants.FAILURE,
)
print("Request.DATA: ", request.data)
amount = coins_amount * wallet.coins
print("amount: ", amount)
serializer = serializers.WithdrawalRequestSerializer(data=request.data)
if serializer.is_valid():
@@ -375,6 +382,7 @@ class WithdrawalRequestCreateAPI(APIView):
created_on=timezone.now(),
coins=wallet.coins,
notes=notes,
amount=amount,
)
# Reset the wallet's coins to 0
wallet.coins = 0

View File

@@ -56,7 +56,7 @@ class WithdrawalListView(LoginRequiredMixin, generic.TemplateView):
class BankAccountListView(LoginRequiredMixin, generic.TemplateView):
page_name = resource_action.RESOURCE_MANAGE_WITHDRAWALS
page_name = resource_action.RESOURCE_MANAGE_BANK_ACCOUNTS
template_name = "manage_wallets/account_list.html"
model = PrincipalBankAccount

View File

@@ -56,6 +56,8 @@
style="width: 98.875px;">Phone Verified</th> -->
<th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
style="width: 98.875px;">Email Verified</th>
<th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
style="width: 98.875px;">Referral Count</th>
<th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
style="width: 98.875px;">Created On</th>
<th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
@@ -70,7 +72,7 @@
</tr>
</thead>
<tbody>
{% for data_obj in data_obj %}
{% for data_obj in data_objs %}
<tr role="row">
<td class="checkbox-column text-center sorting_1"> {{ data_obj.id }} </td>
<td class="text-center">
@@ -84,6 +86,7 @@
<td>{{ data_obj.principal_type.name }}</td>
<!-- <td>{{ data_obj.phone_verified }}</td> -->
<td>{{ data_obj.email_verified }}</td>
<td>{{ data_obj.referral_count }}</td>
<td>{{ data_obj.created_on }}</td>
<td>{{ data_obj.modified_on }}</td>
<td class="text-center">

View File

@@ -21,7 +21,7 @@
Back
</button>
-->
<a class="btn btn-primary mb-2" href="{% url 'manage_events:event_add' %}">Add Event</a>
<!-- <a class="btn btn-primary mb-2" href="{% url 'manage_events:event_add' %}">Add Event</a> -->
<a class="btn btn-primary mb-2" href="{% url 'manage_events:event_category_list' %}">Event Category</a>
<!-- <a class="btn btn-primary mb-2" href="{% url 'manage_events:event_master_list' %}">Event Master</a> -->

View File

@@ -71,7 +71,7 @@
<button type="button" class="btn btn-success mb-2 me-4"
data-bs-toggle="modal" data-bs-target="#replyFormModal"
onclick="ReplyModal('{{withdrawal_obj.id}}','{{withdrawal_obj.status}}')">
Reply
Status
</button>
</td>
</tr>
@@ -136,7 +136,7 @@
</div>
</div>
<div class="modal-footer">
<button class="btn btn-light-dark" data-bs-dismiss="modal">Discard</button>
<button class="btn btn-light-dark" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
@@ -199,6 +199,7 @@
"sSearchPlaceholder": "Search...",
"sLengthMenu": "Results : _MENU_",
},
"order": [[ 0, "desc" ]],
"stripeClasses": [],
"lengthMenu": [5, 10, 20, 50],
"pageLength": 10