Skip to content

Conversation

@octavioamu
Copy link
Contributor

Description

Add tribes and actions

Refers/Fixes

Fix #5516

Testing

@danlipert
Copy link
Contributor

Is this ready for review or still WIP?

@codecov
Copy link

codecov bot commented Nov 27, 2019

Codecov Report

Merging #5555 into master will increase coverage by <.01%.
The diff coverage is 30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5555      +/-   ##
==========================================
+ Coverage   30.25%   30.26%   +<.01%     
==========================================
  Files         247      247              
  Lines       21085    21143      +58     
  Branches     3050     3060      +10     
==========================================
+ Hits         6380     6398      +18     
- Misses      14429    14466      +37     
- Partials      276      279       +3
Impacted Files Coverage Δ
app/app/urls.py 90.19% <ø> (ø) ⬆️
app/dashboard/admin.py 63.83% <100%> (+0.54%) ⬆️
app/dashboard/views.py 12.88% <13.33%> (+0.02%) ⬆️
app/dashboard/models.py 56.27% <72.72%> (+0.07%) ⬆️
...rketing/management/commands/no_applicants_email.py 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40c434e...f42676c. Read the comment docs.


$(elem).on('click', function() {
let user = $(elem).data('openchat');
let url = user ? `https://chat.gitcoin.co/gitcoin/messages/@${user}` : 'https://chat.gitcoin.co/';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

let chatWindow;

$(elem).on('click', function() {
let user = $(elem).data('openchat');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

@@ -0,0 +1,14 @@
const openChat = () => {
$('[data-openchat]').each(function(index, elem) {
let chatWindow;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this variable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really now is actually so we can close the window from js if we need it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also because Im pointing to the same window when user open a new chat.

let user = $(elem).data('openchat');
let url = user ? `https://chat.gitcoin.co/gitcoin/messages/@${user}` : 'https://chat.gitcoin.co/';

chatWindow = window.open(url, 'Loading', 'top=0,left=0,width=400,height=600,status=no,toolbar=no,location=no,menubar=no,titlebar=no');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could do just a window.open ! what do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo without the variable declaration? Is because I want to reuse the window to avoid multiple popups

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

$(elem).attr('disabled', true);

let tribe = $(elem).data('jointribe');
let url = `/join/${tribe}/`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ const

$(elem).on('click', function() {
$(elem).attr('disabled', true);

let tribe = $(elem).data('jointribe');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ const

$(elem).text('Leave Tribe');
} else {
$(elem).text('Join Tribe');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.is_member ? $(elem).text('Leave Tribe') : $(elem).text('Join Tribe') YAY / NAY ?

$(elem).attr('disabled', true);

let memberId = $(elem).data('tribeleader');
let url = 'tribe/tribeleader/';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

$(elem).on('click', function() {
$(elem).attr('disabled', true);

let memberId = $(elem).data('tribeleader');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

const activateQuill = () => {
if (quill) {
return quill.isEnabled() ? destroyQuill() : rebuildQuill();
}
Copy link
Contributor

@thelostone-mc thelostone-mc Nov 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could rewrite this as

return quill && quill.isEnabled() ? destroyQuill() : rebuildQuill(); and drop the if condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quill is undefined in the first run that will block the code to continue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp derp ! you are right

$('[data-savetribe]').on('click', function() {
let tribe = $(this).data('savetribe');
let url = `/savetribe/${tribe}/`;
var sendSave = fetchData (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ const


$('[data-savetribe]').on('click', function() {
let tribe = $(this).data('savetribe');
let url = `/savetribe/${tribe}/`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ const

};

$('[data-savetribe]').on('click', function() {
let tribe = $(this).data('savetribe');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ const

list_display = ['pk', 'profile', 'org', 'leader', 'status']



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove 1 extra line!

@csrf_exempt
@require_POST
def save_tribe(request,handle):
# quill.root.innerHTML
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

app/app/urls.py Outdated
re_path(r'^tribes', retail.views.tribes, name='tribes'),
path('join/<str:handle>/', dashboard.views.join_tribe, name='join_tribe'),
path('savetribe/<str:handle>/', dashboard.views.save_tribe, name='save_tribe'),
path('tribe/tribeleader/', dashboard.views.tribe_leader, name='tribe_leader'),
Copy link
Contributor

@thelostone-mc thelostone-mc Nov 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ would the URL's be

tribe/<str:handle>/join
tribe/<str:handle>/save
tribes/<str:handle>/tribe-leader

^ thoughts on renaming the URI as such ?
Also since there is a join shouldn't there be a /leave?
Or can we group it into a common URI like
tribe/<str:handle>/ and have a body { join: True } / { join: False}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I like your pattern, actually I had plans to look at it, let me change it real quick.
But about having 2 urls to change true/false I think is not needed.
And about the body they are very diff actually pointing to diff models.

@@ -1,3 +1,4 @@
/* stylelint-disable no-descending-specificity */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense to add this throughout the site as opposed to just this file ? (not sure where this goes in though )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because that rule is a pain in the ass using tags instead of class names, and for example every rule with img will complain.

@csrf_exempt
@require_POST
def join_tribe(request, handle):
print(handle, request.user.profile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print

print(handle, request.user.profile)
if request.user.is_authenticated:
profile = request.user.profile if hasattr(request.user, 'profile') else None
print(profile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print

@csrf_exempt
@require_POST
def join_tribe(request, handle):
print(handle, request.user.profile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover print

print(handle, request.user.profile)
if request.user.is_authenticated:
profile = request.user.profile if hasattr(request.user, 'profile') else None
print(profile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover print

if request.user.is_authenticated:
profile = request.user.profile if hasattr(request.user, 'profile') else None
print(profile)
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not use try / except here - if something goes wrong (like a user doesn't have a profile, or the handle doesn't exist) then its going to jump to the exception handling code. Just use an if statement here with exists to see if the user is a tribe member like if profile and handle and TribeMember.objects.get(profile=profile, ...).exists(): TribeMember.objects.get(...).delete()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will get back this to try because is failing in this way
File "/code/app/dashboard/views.py", line 4057, in join_tribe web_1 | if profile and handle and TribeMember.objects.get(profile=profile, org__handle__iexact=handle).exist(): web_1 | dashboard.models.TribeMember.DoesNotExist: TribeMember matching query does not exist.

'success': True,
'is_member': False,
},
status=200)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ do we need to pass success True ? cause status is 200

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes more a rest pattern

@octavioamu octavioamu merged commit 4fcb882 into master Dec 4, 2019
@thelostone-mc thelostone-mc deleted the tribes-profile branch June 27, 2020 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUIDL - Tribes Organization Page

4 participants