Skip to content

Commit 288ad71

Browse files
octavioamuowockithelostone-mcandroolloydsanchaymittal
authored
Stable sep 3 (#7328)
* updates grants round 7 start, to allow for deploly + QA * sentry user_card fixes * hack list * card fixes * profile project url * fix for https://gitcoincore.slack.com/archives/CAXQ7PT60/p1598454051039600 * fix fees data not saving * remove repeated call to user-cards * bump walletconnection version * bump walletconnect to version 1.2.1 * test bot flow * bot trace * justin YOLO request https://gitcoincore.slack.com/archives/CJWQWG6J2/p1598630565055100 * feat: update payoutid when txnid is replaced * User Directory: Elastic Search Edition. (#7204) * WIP, Frank's Super Query added as a view, connected to a ViewSet and returned through the api * WIP: Elastic Search using Haystack - indexes all Profiles, mergeing the to_dict method into the search store itself, - Bounty, and HackathonProject indexers are stubbed out to work on a path for relational models * WIP urls and search view * enable auto complete for lastname, handle, first name, and persona * remove other indexers * WIP: UserDirectory - vue search app hacked into the old user search application - dynamic filters, are all set to checkbox filters presently adjusting by type of metrics is required * wip, user cards rendering * dynamic auto complete based on fields like kibana, still WIP * WIP: dynamic filtering, some style work still needed, dynamic query building is possible * numeric list filter adjusted to account for elastic type * V0 RC1 * restore old user directory * restored docker-compose, addressed review comments * remove email from the elastic search indexer * add crontab entry for elasticsearch update * haystack settings configured to retrieve the proper env variable, removing stale ui components * add missing migration * revert docker-compose change for chat directories * updated path for chat config directory * Bug fixes around the vue app(was loading incorrect js) (#7303) * Bug fixes around the vue app(was loading incorrect js) - added a authenticated proxy route to the elastic search cluster * added a check for settings.DEBUG for http/https * fix / * updates quests, adds a fun little new earnings helper script. * New feature integration of circle to apollo hackathon (#7262) - Integration of circle to apollo hackathon only. - Replaces the old townsquare with gitcoin circle community. * bot notifs * fix user elastic directory * dependencies call * indentation and styles cascade * remove * Update base.txt * fix and create migrations * chains logos visual fix * fix versions giving errors on tests * comment grants test failing * rollback versions * comment out all test Co-authored-by: owocki <ksowocki@gmail.com> Co-authored-by: Aditya Anand M C <aditya.anandmc@gmail.com> Co-authored-by: Andrew Redden <opensource@andrewredden.com> Co-authored-by: Sanchay Mittal <sanchaymittal@gmail.com>
1 parent d1e9207 commit 288ad71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1641
-84
lines changed

app/app/context.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def preprocess(request):
7474
chat_url = get_chat_url(front_end=True)
7575
chat_access_token = ''
7676
chat_id = ''
77-
77+
search_url = '';
7878
user_is_authenticated = request.user.is_authenticated
7979
profile = request.user.profile if user_is_authenticated and hasattr(request.user, 'profile') else None
8080
if user_is_authenticated and profile and profile.pk:
@@ -134,6 +134,7 @@ def preprocess(request):
134134
'MEDIA_URL': settings.MEDIA_URL,
135135
'max_length': max_length,
136136
'max_length_offset': max_length_offset,
137+
'search_url': f'{settings.BASE_URL}user_lookup',
137138
'chat_url': chat_url,
138139
'base_url': settings.BASE_URL,
139140
'chat_id': chat_id,

app/app/settings.py

+11
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
'wiki.plugins.macros.apps.MacrosConfig',
147147
'adminsortable2',
148148
'debug_toolbar',
149+
'haystack',
149150
]
150151

151152
MIDDLEWARE = [
@@ -823,6 +824,16 @@ def callback(request):
823824

824825
ELASTIC_SEARCH_URL = env('ELASTIC_SEARCH_URL', default='')
825826

827+
HAYSTACK_CONNECTIONS = {
828+
'default': {
829+
'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine',
830+
'URL': f"{ELASTIC_SEARCH_URL}:9200",
831+
'INDEX_NAME': 'haystack',
832+
},
833+
}
834+
# Update Search index in realtime (using models.db.signals)
835+
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
836+
826837
account_sid = env('TWILIO_ACCOUNT_SID', default='')
827838
auth_token = env('TWILIO_AUTH_TOKEN', default='')
828839
verify_service = env('TWILIO_VERIFY_SERVICE', default='')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ object.title }}
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ object.title }}
2+
{{ object.description }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ object.object }}

app/app/templates/search/search.html

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{% comment %}
2+
Copyright (C) 2020 Gitcoin Core
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Affero General Public License as published
6+
by the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Affero General Public License for more details.
13+
14+
You should have received a copy of the GNU Affero General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
{% endcomment %}
18+
{% load i18n static email_obfuscator add_url_schema avatar_tags %}
19+
<!DOCTYPE html>
20+
<html lang="en">
21+
22+
<head>
23+
{% include 'shared/head.html' %}
24+
{% include 'shared/cards.html' %}
25+
<link rel="stylesheet" href={% static "v2/css/users.css" %} />
26+
<link rel="stylesheet" href={% static "v2/css/tag.css" %} />
27+
<link rel="stylesheet" href={% static "v2/css/rating.css" %} />
28+
<link rel="stylesheet" href="https://unpkg.com/vue-innersearch/default-innersearch-theme.min.css">
29+
</head>
30+
31+
<body id="{{ explore }}" class="interior {{active}} g-font-muli">
32+
{% include 'shared/tag_manager_2.html' %}
33+
<div class="container-fluid header dash">
34+
{% include 'shared/top_nav.html' with class='d-md-flex' %}
35+
{% include 'home/nav.html' %}
36+
</div>
37+
{% block content %}
38+
<h2>Search</h2>
39+
40+
<form method="get" action="">
41+
<table>
42+
{{ form.as_table }}
43+
<tr>
44+
<td>&nbsp;</td>
45+
<td>
46+
<input type="submit" value="Search">
47+
</td>
48+
</tr>
49+
</table>
50+
51+
{% if query %}
52+
<h3>Results</h3>
53+
54+
{% for result in page.object_list %}
55+
<p>
56+
<a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
57+
</p>
58+
{% empty %}
59+
<p>No results found.</p>
60+
{% endfor %}
61+
62+
{% if page.has_previous or page.has_next %}
63+
<div>
64+
{% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
65+
|
66+
{% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
67+
</div>
68+
{% endif %}
69+
{% else %}
70+
{# Show some example queries to run, maybe query syntax, something else? #}
71+
{% endif %}
72+
</form>
73+
{% endblock %}
74+
<div id="gc-users-directory" v-cloak>
75+
76+
<section>
77+
<h1 class='is-title'>Hacky User Directory</h1>
78+
79+
<hr class='is-line' />
80+
81+
<div class="filters" style="width : 90%; margin : 0 auto;">
82+
<tag-filter :for="'searchbox'"></tag-filter>
83+
<tag-filter :for="'searchdatalist'">
84+
<template slot-scope="{ data }">
85+
[[ data._source.keywords ]]
86+
</template>
87+
</tag-filter>
88+
<tag-filter :for="'nlf'">
89+
<template slot-scope="{ data }">
90+
Number of Hacks Joined: [[ data._source.keywords ]]
91+
</template>
92+
</tag-filter>
93+
</div>
94+
95+
<div class="is-columns">
96+
<div class="is-column is-one-fifth">
97+
<div>
98+
<numeric-list-filter :id="'nlf'" :field="'num_hacks_joined'">
99+
<template slot="header">
100+
<h3 class="is-nlf-title">Number of Hacks Joined : </h3>
101+
</template>
102+
</numeric-list-filter>
103+
</div>
104+
</div>
105+
<div class="is-column">
106+
<div>
107+
<searchbox :id="'searchbox'" :autofocus="true" :realtime="true" :timeout="200" :field="['keywords', 'handle', 'persona']" :placeholder="'Search by keyword'"></searchbox>
108+
<search-datalist :id="'searchdatalist'" :realtime="true" :field="'keywords'" :suggestion="['keywords']">
109+
<template slot="items" slot-scope="{ item, value }">
110+
[[ value ]] [[ item._source.keywords ]]
111+
</template>
112+
113+
<template slot="nosuggestion" slot-scope="{ value }">
114+
Sorry, "[[ value ]]" doesn't exist... :(
115+
</template>
116+
117+
<template slot="suggestions" slot-scope="{ suggestion }">
118+
<span v-html="suggestion.highlight.first_name ? suggestion.highlight.first_name[0] : suggestion._source.first_name"></span>
119+
<span v-html="suggestion.highlight.last_name ? suggestion.highlight.last_name[0] : suggestion._source.last_name"></span>
120+
<span v-html="suggestion.highlight.handle ? suggestion.highlight.handle[0] : suggestion._source.handle"></span>
121+
<span v-html="suggestion.highlight.persona ? suggestion.highlight.persona[0] : suggestion._source.persona"></span>
122+
</template>
123+
</search-datalist>
124+
125+
<div style="margin: 20px auto;width: 90%">
126+
<search-button></search-button>
127+
<reset-button :emptyHits="false"></reset-button>
128+
</div>
129+
<hits>
130+
<template slot="hits" slot-scope="{ hits }">
131+
<div class="is-score is-hits">
132+
<strong v-if="hits.score === 0">No result found</strong>
133+
<strong v-else-if="hits.score === 1">1 result found</strong>
134+
<strong v-else-if="hits.score > 1">[[ hits.score ]] results found</strong>
135+
</div>
136+
<div v-for="item in hits.items" :item="item">
137+
<div><strong>Identity (firstname, lastname) :</strong> ([[ item._source.first_name ]] [[ item._source.last_name ]] )</div>
138+
</div>
139+
</template>
140+
</hits>
141+
142+
<paginate :previousText="'&#x2B9C; Previous page'" :nextText="'Next page &#x2B9E;'" :size="10"></paginate>
143+
</div>
144+
</div>
145+
</div>
146+
</section>
147+
</div>
148+
149+
<script type="text/x-template" id="select2-template">
150+
<select>
151+
<slot></slot>
152+
</select>
153+
</script>
154+
155+
{% csrf_token %}
156+
{% include 'shared/analytics.html' %}
157+
{% include 'shared/footer_scripts.html' %}
158+
{% include 'shared/footer.html' %}
159+
<script src="https://unpkg.com/vue-innersearch@0.0.12/vue-innersearch.min.js"></script>
160+
161+
162+
<script>
163+
$('body').bootstrapTooltip({
164+
selector: '[data-toggle="tooltip"]'
165+
});
166+
const csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
167+
document.keywords = {{keywords | safe}};
168+
</script>
169+
<script src="{% static "v2/js/users.js" %}"></script>
170+
</body>
171+
</html>

app/app/urls.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@
375375

376376
# User Directory
377377
re_path(r'^users/?', dashboard.views.users_directory, name='users_directory'),
378+
re_path(r'^user_directory/?', dashboard.views.users_directory_elastic, name='users_directory_elastic'),
379+
re_path(r'^user_lookup/?', dashboard.views.user_lookup, name='user_directory_lookup'),
378380
re_path(r'^tribes/explore', dashboard.views.users_directory, name='tribes_directory'),
379381

380382
# Alpha functionality
@@ -506,7 +508,6 @@
506508
bounty_requests.views.update_bounty_request_v1,
507509
name='update_bounty_request_v1'
508510
),
509-
510511
# admin views
511512
re_path(r'^_administration/?', admin.site.urls, name='admin'),
512513
path(
@@ -713,6 +714,7 @@
713714

714715
# users
715716
url(r'^api/v0.1/user_bounties/', dashboard.views.get_user_bounties, name='get_user_bounties'),
717+
url(r'^api/v0.1/users_csv/', dashboard.views.output_users_to_csv, name='users_csv'),
716718
url(r'^api/v0.1/bounty_mentor/', dashboard.views.bounty_mentor, name='bounty_mentor'),
717719
url(r'^api/v0.1/users_fetch/', dashboard.views.users_fetch, name='users_fetch'),
718720

+1-1
Loading

app/assets/v2/js/notifications.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ Vue.mixin({
111111
},
112112
computed: {
113113
sortedItems: function() {
114-
return this.notifications.sort((a, b) => new Date(b.created_on) - new Date(a.created_on));
114+
if (!this.notifications) {
115+
return;
116+
}
117+
return this.notifications.slice().sort((a, b) => new Date(b.created_on) - new Date(a.created_on));
115118
}
116119
}
117120

app/assets/v2/js/pages/new_bounty.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ Vue.mixin({
393393
if (errors) {
394394
_alert({ message: gettext('Unable to pay bounty fee. Please try again.') }, 'error');
395395
} else {
396-
396+
vm.form.feeTxId = txnHash;
397397
saveAttestationData(
398398
txnHash,
399399
vm.totalAmount.totalFee,
@@ -496,8 +496,8 @@ Vue.mixin({
496496
'repo_type': metadata.repo_type,
497497
'is_featured': metadata.is_featured,
498498
'featuring_date': metadata.featuring_date,
499-
'fee_amount': 0,
500-
'fee_tx_id': null,
499+
'fee_amount': vm.totalAmount.totalFee,
500+
'fee_tx_id': vm.form.feeTxId,
501501
'coupon_code': vm.form.couponCode,
502502
'privacy_preferences': JSON.stringify({
503503
show_email_publicly: vm.form.showEmailPublicly
@@ -697,6 +697,7 @@ if (document.getElementById('gc-hackathon-new-bounty')) {
697697
token: {},
698698
terms: false,
699699
termsPrivacy: false,
700+
feeTxId: null,
700701
couponCode: document.coupon_code
701702
}
702703
};

app/assets/v2/js/user_card.js

+3
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ const addFollowAction = () => {
243243
};
244244

245245
function openContributorPopOver(contributor, element) {
246+
if (!contributor) {
247+
return;
248+
}
246249

247250
const contributorURL = `/api/v0.1/user_card/${contributor}`;
248251

0 commit comments

Comments
 (0)