Skip to content

Commit

Permalink
Merge pull request #2203 from gtech-mulearn/dev-server
Browse files Browse the repository at this point in the history
Merge dev-server to production
  • Loading branch information
jelanmathewjames authored Aug 10, 2024
2 parents cde9392 + 152d820 commit 927e606
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
30 changes: 23 additions & 7 deletions api/dashboard/profile/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Meta:
"percentile",
)


def get_percentile(self, obj):
users_count_lt_user_karma = Wallet.objects.filter(
karma__lt=obj.wallet_user.karma
Expand Down Expand Up @@ -177,7 +178,7 @@ def get_tasks(self, obj):
user_igs = UserIgLink.objects.filter(
user__id=user_id).values_list("ig__name", flat=True)
tasks = TaskList.objects.filter(level=obj)

if obj.level_order > 4:
tasks = tasks.filter(ig__name__in=user_igs)

Expand Down Expand Up @@ -271,8 +272,8 @@ def update(self, instance, validated_data):

class UserProfileEditSerializer(serializers.ModelSerializer):
communities = serializers.ListField(write_only=True)


def to_representation(self, instance):
data = super().to_representation(instance)
communities = instance.user_organization_link_user.filter(
Expand Down Expand Up @@ -312,7 +313,7 @@ def update(self, instance, validated_data):
UserOrganizationLink.objects.bulk_create(
user_organization_links)



return super().update(instance, validated_data)

Expand All @@ -326,9 +327,9 @@ class Meta:
"gender",
"dob",
"district",

]



class UserIgListSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -409,7 +410,7 @@ def create_karma_activity_log(task_hashtag, karma_value):
WebHookActions.UPDATE.value,
value
)

else:
KarmaActivityLog.objects.filter(
task_id=task.id, user_id=user_id
Expand All @@ -431,3 +432,18 @@ def create_karma_activity_log(task_hashtag, karma_value):
create_karma_activity_log(f"#social_{account}", -20)

return super().update(instance, validated_data)

class UserTermSerializer(serializers.ModelSerializer):
is_userterms_approved = serializers.SerializerMethodField()


class Meta:
model = UserSettings
fields =[
"is_userterms_approved",
"user",
]
def get_userterm(self, instance, validated_data):
instance.is_userterms_approved = validated_data.get('is_userterms_approved', instance.is_userterms_approved)
instance.save()
return instance
28 changes: 28 additions & 0 deletions api/dashboard/profile/profile_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,31 @@ def get(self, request, muid):
return CustomResponse(
response="The given muid seems to be invalid"
).get_failure_response()

class UsertermAPI(APIView):
def post(self, request,muid):
user = User.objects.get(muid=muid)
try:
settings = UserSettings.objects.get(user=user)
except UserSettings.DoesNotExist:
return CustomResponse(response="The user setting doesn't exists").get_failure_response()

serializer = UserTermSerializer(settings, data={"is_userterms_approved": True}, partial=True)
if serializer.is_valid():
settings = serializer.save()
if settings.is_userterms_approved:
return CustomResponse(response=response_data).get_success_response()
else:
return CustomResponse(response="The given muid seems to be invalid").get_failure_response()
return CustomResponse(response=response_data).get_failure_response()

def get(self,request,muid):
user = User.objects.get(muid=muid)
try:
settings = UserSettings.objects.get(user=user)
except UserSettings.DoesNotExist:
return CustomResponse(response="The user settings doesn't exists").get_failure_response()
if settings.is_userterms_approved:
return CustomResponse(response=response_data).get_success_response()
else:
return CustomResponse(response=response_data).get_failure_response()
1 change: 1 addition & 0 deletions api/dashboard/profile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
path('socials/<str:muid>/', profile_view.GetSocialsAPI.as_view()),
path('qrcode-get/<str:uuid>/', profile_view.QrcodeRetrieveAPI.as_view()),
path('change-password/', profile_view.ResetPasswordAPI.as_view()),
path('userterm-approved/,<str:muid>/',profile_view.UsertermAPI.as_view())
]
2 changes: 1 addition & 1 deletion api/launchpad/launchpad_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
users,
request,
["full_name", "karma", "org", "district_name", "state"]
["muid","full_name","org"]
)

final_users = paginated_queryset.get("queryset")
Expand Down
4 changes: 1 addition & 3 deletions db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class UserSettings(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user_settings_user")
is_public = models.BooleanField(default=False)
is_userterms_approved = models.BooleanField(default=False)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='user_settings_updated_by')
updated_at = models.DateTimeField(auto_now=True)
Expand Down Expand Up @@ -221,6 +222,3 @@ class Meta:
managed = False

db_table = 'user_coupon_link'



3 changes: 2 additions & 1 deletion utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def get_all_values(cls):
class TFPTasksHashtags(Enum):
SCRATCH = '#tfp2.0-scratch'
COMMAND_LINE = '#tfp2.0-command-line'

GIT_GITHUB = '#tfp2.0-git-github'

@classmethod
def get_all_values(cls):
return [member.value for member in cls]
Expand Down

0 comments on commit 927e606

Please sign in to comment.