Skip to content

Commit

Permalink
Merge branch 'master' into reserve-bounty-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored Sep 19, 2019
2 parents ba017f5 + 5ee1537 commit cd37a16
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def preprocess(request):
'release': settings.RELEASE,
'env': settings.ENV,
'email_key': email_key,
'orgs': profile.organizations if profile else [],
'profile_id': profile.id if profile else '',
'hotjar': settings.HOTJAR_CONFIG,
'ipfs_config': {
Expand Down
7 changes: 5 additions & 2 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ var show_interest_modal = function() {
}

let actionPlanForm = $('#action_plan');
let discord_username = $('#discord_username');
let issueMessage = $('#issue_message');

issueMessage.attr('placeholder', gettext('What steps will you take to complete this task? (min 30 chars)'));
Expand Down Expand Up @@ -715,7 +716,8 @@ var show_interest_modal = function() {
_alert(response.message, 'info');
add_interest(document.result['pk'], {
issue_message: msg,
signed_nda: response.bounty_doc_id
signed_nda: response.bounty_doc_id,
discord_username: $('#discord_username').length ? $('#discord_username').val() : null
}).then(success => {
if (success) {
$(self).attr('href', '/uninterested');
Expand All @@ -736,7 +738,8 @@ var show_interest_modal = function() {
});
} else {
add_interest(document.result['pk'], {
issue_message: msg
issue_message: msg,
discord_username: $('#discord_username').length ? $('#discord_username').val() : null
}).then(success => {
if (success) {
$(self).attr('href', '/uninterested');
Expand Down
18 changes: 18 additions & 0 deletions app/dashboard/migrations/0051_profile_gitcoin_discord_username.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-09-17 16:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0050_searchhistory_search_type'),
]

operations = [
migrations.AddField(
model_name='profile',
name='gitcoin_discord_username',
field=models.CharField(blank=True, default='', max_length=255),
),
]
1 change: 1 addition & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ class Profile(SuperModel):
slack_token = models.CharField(max_length=255, default='', blank=True)
custom_tagline = models.CharField(max_length=255, default='', blank=True)
slack_channel = models.CharField(max_length=255, default='', blank=True)
gitcoin_discord_username = models.CharField(max_length=255, default='', blank=True)
discord_repos = ArrayField(models.CharField(max_length=200), blank=True, default=list)
discord_webhook_url = models.CharField(max_length=400, default='', blank=True)
suppress_leaderboard = models.BooleanField(
Expand Down
13 changes: 13 additions & 0 deletions app/dashboard/templates/addinterest.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ <h5 class="font-subheader">{% trans "Non-Disclosure Agreement" %}</h5>
<textarea id="issue_message" class="form__input"></textarea>
</div>
<div>
{% if bounty.event %}
<div class="d-flex">
<div class="filter-label ml-0 mb-3">
<label for="checkbox2 mb-0">
{% trans "Discord Username" %}
</label>
<input type="text" id="discord_username" name="discord_username" class="form__input font-body" placeholder="vivek#9746" value="{{gitcoin_discord_username}}" required/>
<span class="font-caption"><a target="_blank" href="https://discord.gg/TxRKTn8">Join Discord</a> to get updates from our sponsors prizes and find help</span>

</div>
</div>
{% endif %}
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox2" class="form__input" value="1" required/>
<span class="checkbox"></span>
Expand All @@ -78,6 +90,7 @@ <h5 class="font-subheader">{% trans "Non-Disclosure Agreement" %}</h5>
</label>
</div>
</div>
<div>
<div class="checkbox_container d-flex">
<input type="checkbox" id="checkbox1" class="form__input" value="1" required/>
<span class="checkbox"></span>
Expand Down
5 changes: 5 additions & 0 deletions app/dashboard/templates/profiles/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ <h1 class="profile-header__handle">
<i class="far fa-envelope"></i>
</a>
{% endif %}
{% if profile.gitcoin_discord_username and user.is_authenticated %}
<a href="https://discord.gg/TxRKTn8#{{profile.gitcoin_discord_username}}" title="{{profile.gitcoin_discord_username}}">
<i class="fab fa-discord"></i>
</a>
{% endif %}
</p>

{% if preferred_payout_address %}
Expand Down
6 changes: 6 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def get_interest_modal(request):

context = {
'bounty': bounty,
'gitcoin_discord_username': request.user.profile.gitcoin_discord_username if request.user.is_authenticated else None,
'active': 'get_interest_modal',
'title': _('Add Interest'),
'user_logged_in': request.user.is_authenticated,
Expand Down Expand Up @@ -307,6 +308,11 @@ def new_interest(request, bounty_id):
'success': False},
status=401)

if request.POST.get('discord_username'):
profile = request.user.profile
profile.gitcoin_discord_username = request.POST.get('discord_username')
profile.save()

msg = _("You have started work.")
approval_required = bounty.permission_type == 'approval'
if approval_required:
Expand Down
3 changes: 3 additions & 0 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,15 @@ def discord_settings(request):
if request.POST:
test = request.POST.get('test')
submit = request.POST.get('submit')
gitcoin_discord_username = request.POST.get('gitcoin_discord_username', '')
webhook_url = request.POST.get('webhook_url', '')
repos = request.POST.get('repos', '')

if test and webhook_url:
response = validate_discord_integration(webhook_url)

if submit or (response and response.get('success')):
profile.gitcoin_discord_username = gitcoin_discord_username
profile.update_discord_integration(webhook_url, repos)
profile = record_form_submission(request, profile, 'discord')
if not response.get('output'):
Expand All @@ -418,6 +420,7 @@ def discord_settings(request):

context = {
'repos': profile.get_discord_repos(join=True) if profile else [],
'gitcoin_discord_username': profile.gitcoin_discord_username,
'is_logged_in': is_logged_in,
'nav': 'home',
'active': '/settings/discord',
Expand Down
4 changes: 4 additions & 0 deletions app/retail/templates/settings/discord.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ <h5>{% trans "Discord Integration" %}</h5>
<label class="form__label" for="repos">{% trans "Github repos to monitor (use full name, like 'gitcoinco/web' for <a href=https://github.com/gitcoinco/web>this repo</a>)" %}</label>
<input type="text" name="repos" class="form__input" placeholder='comma, separated, list (gitcoinco/web)' value="{{ repos }}">
</div>
<div class="form-group">
<label class="form__label" for="gitcoin_discord_username">{% trans "Gitcoin Events Discord Username (<a href=https://discord.gg/TxRKTn8>get a discord invite</a>)" %}</label>
<input type="text" name="gitcoin_discord_username" class="form__input" placeholder='vivek#9746' value="{{ gitcoin_discord_username }}">
</div>
{% csrf_token %}
<input class='button button--primary' type='submit' name='submit' value="{% trans "Go" %}">
<input class='button button--primary' style='margin-left: 0.5em;' type='submit' name='test' value="{% trans "Test" %}">
Expand Down

0 comments on commit cd37a16

Please sign in to comment.