Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Town Square MVP #5744

Merged
merged 44 commits into from
Jan 15, 2020
Merged

Town Square MVP #5744

merged 44 commits into from
Jan 15, 2020

Conversation

owocki
Copy link
Contributor

@owocki owocki commented Jan 8, 2020

Description

This is the MVP of Town square. I will be demoing on tomorrows sprint meeting. The idea is to be the central nervous system of Gitcoin. A place to view social updates + find out whats new on the network

My hope is that this functionality MASSIVELY increases DAUs on Gitcoin

Includes

  • Newsfeed
  • Commenting
  • Liking
  • Flags
  • Comment Emails
  • Daily Actions

screencapture-localhost-8000-townsquare-2020-01-08-16_13_34

Refers/Fixes

https://app.mural.co/t/consensys3989/m/consensys3989/1576552443637/93b352eccd110e4827ae96f3533fa3de3a5b5571

Testing

Tested a butt ton locally

Release Plan

I plan to release this incrementally to production behind a feature flag. Since its a very social feature, iterative user feedback in production will be important (theres real data in production, so the social experience is more meaningful!).

My Todo list

v0
X likes
X comments displaying + deletion
X hook up activity/tabs

v0.1
x Flag feature 

x view action (web)
X email notifications / send me daily offers email pref on dashboard 
X new bounties => daily offer email

v0.2
x copy-able link to a post or status update on gitcoin
x Comment emails 
x you can enable town square via special cb link

- create action
- town square tabs should have hourly rates of action on them
- Tabs: mentorship, jobs, etc that match status updates

v0.3
- login first modals
- Product updates on right side? 
- Featured users in feed
- Link to chat on landing page. With number online 
- posts should link usernames or search hashtags
- minimize / expand feed button
- feed shows when new items come up 
- auto delete posts with more than one flag

# actions ideas
- anyone can click 
- free kudos
- work on a 15 minute bounty
- use mythx + give technical feedback on it


# Launch notes/checklist

launch with tweet

What to say on Twitter; Killer feature of gitcoin is its community. Unlike other web3 social networks just launching., we’ve already bootstrapped our social graph!
shilly wonka branding

CTA: Got announcement? Post here.  Want to hire? post here?

@codecov
Copy link

codecov bot commented Jan 8, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@748d396). Click here to learn what that means.
The diff coverage is 14.92%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #5744   +/-   ##
========================================
  Coverage          ?   29.2%           
========================================
  Files             ?     264           
  Lines             ?   23543           
  Branches          ?    3631           
========================================
  Hits              ?    6875           
  Misses            ?   16344           
  Partials          ?     324
Impacted Files Coverage Δ
app/app/urls.py 90.38% <ø> (ø)
app/grants/clr.py 0% <0%> (ø)
...arketing/management/commands/export_graph_edges.py 0% <0%> (ø)
app/retail/emails.py 23.32% <0%> (ø)
...grants/management/commands/contribution_checker.py 0% <0%> (ø)
app/marketing/mails.py 13.42% <0%> (ø)
app/grants/views.py 14.41% <0%> (ø)
app/retail/views.py 26.9% <0%> (ø)
app/kudos/views.py 15.02% <0%> (ø)
app/dashboard/admin.py 64.62% <100%> (ø)
... and 5 more

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 748d396...eec30f9. Read the comment docs.

@@ -230,18 +230,19 @@ const alertMessage = function(msg) {
return html;
};

const _alert = function(msg, _class) {
const _alert = function(msg, _class, remove_after_ms) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is quite a nice little feature... removing the msg after some time... clears notifications so users dont have to!



@ratelimit(key='ip', rate='10/m', method=ratelimit.UNSAFE, block=True)
@csrf_exempt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

havent figured out how to feed enough csrf tokens to the frontend to make multi comment experience work well. punting for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I spent some time looking into this and I believe you can use the same CSRF token multiple times - it only gets invalidated on user login. https://stackoverflow.com/questions/25507514/does-django-csrf-token-must-be-unique-on-every-request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixing this now

@@ -1498,6 +1498,16 @@ $(document).ready(function() {
});
});

const copyToClipboard = str => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm yeah this function is somehwat different (creates a diff message in a diff way, my copyToClipBoard() file, which is more generlizaable...

@octavioamu
Copy link
Contributor

made a quick view looking nice I need to go deeper.
For other side I will say Owocki come to the Vue side, lot of interactions would be so easy to do with vue here.

@owocki
Copy link
Contributor Author

owocki commented Jan 9, 2020

good call; i wish i had thought of the vue stuff before i broke ground on this!

@property
def text(self):
from django.template.loader import render_to_string
from bs4 import BeautifulSoup
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move these imports to module scope

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@danlipert danlipert left a comment

Choose a reason for hiding this comment

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

Fat PR! Looks good though - I think we can deploy Wednesday if you can turn around some of these comments quick

app/dashboard/models.py Show resolved Hide resolved
for to_email in to_emails:
cur_language = translation.get_language()
try:
setup_lang(to_email)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can move the setup_lang and cur_language calls out of the loop for a tiny bit of performance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cur_language and setup_lang are each relative to each to_email so we cant do that..

Copy link
Contributor

Choose a reason for hiding this comment

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

my bad on the setup_lang part - for the get_language part my understanding is that we are storing the current language (english) - then translating the email via the setup_lang function which changes the current language, then going back to english with the finally: section. So its probably good to move out of the loop, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

app/marketing/mails.py Show resolved Hide resolved
@@ -747,7 +787,24 @@ def new_bounty_daily(bounties, old_bounties, to_emails=None):
plural = "s" if len(bounties) != 1 else ""
worth = round(sum([bounty.value_in_usdt for bounty in bounties if bounty.value_in_usdt]), 2)
worth = f" worth ${worth}" if worth else ""
subject = _(f"⚡️ {len(bounties)} New Open Funded Issue{plural}{worth} matching your profile")
offers = f""
if to_emails and len(to_emails):
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the len check here covering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing

subject = _(f"⚡️ {len(bounties)} New Open Funded Issue{plural}{worth} matching your profile")
offers = f""
if to_emails and len(to_emails):
from townsquare.utils import is_email_townsquare_enabled, is_there_an_action_available
Copy link
Contributor

Choose a reason for hiding this comment

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

is this to avoid a circular import? Performance isn't a huge deal here since its outside of a request/response cycle but always good to check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nah; just laziness.. removing

app/townsquare/models.py Show resolved Hide resolved
app/townsquare/tasks.py Show resolved Hide resolved


@ratelimit(key='ip', rate='10/m', method=ratelimit.UNSAFE, block=True)
@csrf_exempt
Copy link
Contributor

Choose a reason for hiding this comment

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

So I spent some time looking into this and I believe you can use the same CSRF token multiple times - it only gets invalidated on user login. https://stackoverflow.com/questions/25507514/does-django-csrf-token-must-be-unique-on-every-request

app/townsquare/views.py Show resolved Hide resolved
return redirect('/login/github?next=' + request.get_full_path())
if request.user.profile.offeractions.filter(what='click', offer=offer) and not is_debugging_offers:
raise Exception('already visited this offer')
OfferAction.objects.create(profile=request.user.profile, offer=offer, what='click')
Copy link
Contributor

Choose a reason for hiding this comment

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

Lots of code in these methods we could DRY up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

id be open to discussions about how to do that... if we were gonna get fancy we could use an inherited class or view or something..

Copy link
Contributor

Choose a reason for hiding this comment

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

I think just a non-view helper function is probably fine, something like offer = get_offer_and_create_offer_action(offer_id, what='click')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@owocki
Copy link
Contributor Author

owocki commented Jan 13, 2020

@danlipert i turned around all the code review here => 3288bbb

lets aim for weds deploy pls!

@owocki
Copy link
Contributor Author

owocki commented Jan 14, 2020

latest code review turnaround => abd3563

app/app/urls.py Outdated
@@ -361,6 +364,16 @@
re_path(r'^results/?(?P<keyword>.*)/?', retail.views.results, name='results_by_keyword'),
re_path(r'^results/?', retail.views.results, name='results'),
re_path(r'^activity/?', retail.views.activity, name='activity'),
re_path(r'^townsquare/?', townsquare.views.index, name='townsquare'),
re_path(r'^$', townsquare.views.index, name='inex'),
Copy link
Contributor

Choose a reason for hiding this comment

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

typo? "inex"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@octavioamu octavioamu merged commit 7953429 into master Jan 15, 2020
@octavioamu
Copy link
Contributor

@owocki There are some stuff I can review but instead since a design for this is coming I can fix css and styles then.

@thelostone-mc thelostone-mc deleted the kevin/townsquare 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.

3 participants