Repository: CTFd/CTFd
Pull request #2478 (2024-02-22 22:27:07)

Add challenge value in social template
* Show challenge value in social template instead of solve count

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/CTFd/CTFd/pull/2478?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CTFd) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 85.34%. Comparing base [(`47b2814`)](https://app.codecov.io/gh/CTFd/CTFd/commit/47b2814ba6d1bffe4df2b4f5a5b0961da966aaef?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CTFd) to head [(`01f8528`)](https://app.codecov.io/gh/CTFd/CTFd/pull/2478?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CTFd).


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #2478      +/-   ##
==========================================
- Coverage   87.75%   85.34%   -2.42%     
==========================================
  Files         155      153       -2     
  Lines        9601     9550      -51     
==========================================
- Hits         8425     8150     -275     
- Misses       1176     1400     +224     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/CTFd/CTFd/pull/2478?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CTFd).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CTFd).


Patch:
diff --git a/CTFd/utils/social/__init__.py b/CTFd/utils/social/__init__.py
index ae9fe5af..0d8baf6f 100644
--- a/CTFd/utils/social/__init__.py
+++ b/CTFd/utils/social/__init__.py
@@ -20,7 +20,7 @@ BASE_TEMPLATE = """
             <h3 class="text-center">{ctf_name}</h3>
             <h3 class="text-center">{account_name} has solved {challenge_name}</h3>
             <br>
-            <h4 class="text-center">{challenge_name} has {solve_count_word}</h4>
+            <h4 class="text-center">+{challenge_value} points</h4>
         </div>
     </div>
     <div class="row">
@@ -82,6 +82,7 @@ class SolveSocialShare(object):
         # Challenge information
         challenge_id = challenge.id
         challenge_name = challenge.name
+        challenge_value = challenge.value
         solves_count = get_solve_counts_for_challenges(challenge_id=challenge_id)
         solve_count = solves_count.get(challenge_id, 0)
 
@@ -103,6 +104,7 @@ class SolveSocialShare(object):
             ctf_description=ctf_description,
             register_url=register_url,
             challenge_name=challenge_name,
+            challenge_value=challenge_value,
             account_name=account_name,
             user_name=user_name,
             team_name=team_name,


Test patch:
diff --git a/tests/test_share.py b/tests/test_share.py
index e5b30892..db1ee034 100644
--- a/tests/test_share.py
+++ b/tests/test_share.py
@@ -45,7 +45,7 @@ def test_share_endpoints():
             resp = r.get_data(as_text=True)
             assert r.status_code == 200
             assert "user has solved" in resp
-            assert "chal_name has 1 solve" in resp
+            assert "+100 points" in resp
 
             # Test downloading asset image
             m = re.search(r"og:image(.*)", resp)