-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project complated : fix invite and referrals (#1830)
* fix invite * fix invite * fix invite * fix invite * fix invite * fix invite * fix invite * fix invite
- Loading branch information
Showing
6 changed files
with
144 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
website/migrations/0083_alter_invitefriend_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 5.0.2 on 2024-02-25 15:28 | ||
|
||
import uuid | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("website", "0082_issue_reporter_ip_address"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="invitefriend", | ||
options={}, | ||
), | ||
migrations.RemoveField( | ||
model_name="invitefriend", | ||
name="recipient", | ||
), | ||
migrations.RemoveField( | ||
model_name="invitefriend", | ||
name="sent", | ||
), | ||
migrations.AddField( | ||
model_name="invitefriend", | ||
name="point_by_referral", | ||
field=models.IntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name="invitefriend", | ||
name="recipients", | ||
field=models.ManyToManyField( | ||
blank=True, related_name="received_invites", to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="invitefriend", | ||
name="referral_code", | ||
field=models.CharField(default=uuid.uuid4, editable=False, max_length=100), | ||
), | ||
migrations.AlterField( | ||
model_name="invitefriend", | ||
name="sender", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="sent_invites", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
{% extends "base.html" %} | ||
{% block title %} invite friend {% endblock title %} | ||
{% block content %} | ||
<form action="{% url 'invite_friend' %}" method="post" class="form-inline"> | ||
{% csrf_token %} | ||
<div class="row"> | ||
{% for error in form.non_field_errors %} | ||
<div class="col-lg-6">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="row"> | ||
<div class="col-lg-10"> | ||
{% if form.recipient.errors %} | ||
<div class="alert alert-danger">{{ form.recipient.errors }}</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-lg-10"> | ||
<h3 class="page-header">Invite 2 friends and get 1 point!</h3> | ||
<label>Email:</label> | ||
{{ form.recipient }} | ||
<button type="submit" class="btn btn-danger text-black">Invite</button> | ||
</div> | ||
</div> | ||
</form> | ||
{% endblock %} | ||
{% include "includes/sidenav.html" %} | ||
<div class="mx-auto my-12 p-6 rounded-lg shadow-xl max-w-3xl"> | ||
|
||
<div class="mb-4"> | ||
<label for="recipient" class="block text-gray-700 text-2xl font-bold mb-2">Share & Earn</label> | ||
<input class="form-control" type="text" value="{{ referral_link }}" id="referralLink" readonly> | ||
<button onclick="copyReferralLink()" class="mt-2 bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">Copy</button> <span> or </span> | ||
<a href="mailto:?subject=Join Me on BLT to Discover and Report Bugs!&body=Hi there!%0D%0A%0D%0AI've been using BLT, a platform where we can discover and report bugs across various applications and websites. It's been an exciting journey, and I believe you too can contribute significantly and benefit from it.%0D%0A%0D%0ABLT allows us to:%0D%0A- Explore and report bugs.%0D%0A- Earn rewards and recognition for our contributions.%0D%0A- Join a community of like-minded individuals passionate about improving software quality.%0D%0A%0D%0AI thought it would be something you're interested in exploring. You can sign up using the link below and start your journey with BLT today!%0D%0A%0D%0A{{ referral_link|urlencode }}%0D%0A%0D%0ALooking forward to seeing you on BLT and tackling challenges together.%0D%0A%0D%0ABest,%0D%0A{{ user.username|urlencode }}"><button class="inline-block bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded-lg shadow-lg focus:outline-none focus:shadow-outline transition duration-150 ease-in-out"><i class="fas fa-envelope mr-2"></i>Send Mail</button></a> | ||
</div> | ||
<div class="flex items-center justify-between"> | ||
<p class="inline-block align-baseline font-bold text-base text-red-500 hover:text-red-800"> | ||
Invite a friend to join the site and earn 2 points! | ||
</p> | ||
</div> | ||
</div> | ||
{% endblock content %} | ||
{% block after_js %} | ||
<script> | ||
function copyReferralLink() { | ||
var copyText = document.getElementById("referralLink"); | ||
copyText.select(); | ||
copyText.setSelectionRange(0, 99999); | ||
navigator.clipboard.writeText(copyText.value); | ||
alert("Copied to clipboard: " + copyText.value); | ||
} | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters