From b02b8d6d654dfb35e9277284e1d2dee2e5ddba1e Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Thu, 30 Sep 2021 06:12:40 +0530 Subject: [PATCH 1/5] add claim date fields --- app/grants/models/grant.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/grants/models/grant.py b/app/grants/models/grant.py index ec8ab8fe42a..647cf0e072e 100644 --- a/app/grants/models/grant.py +++ b/app/grants/models/grant.py @@ -60,6 +60,8 @@ class Meta: is_active = models.BooleanField(default=False, db_index=True, help_text="Is CLR Round currently active") start_date = models.DateTimeField(help_text="CLR Round Start Date") end_date = models.DateTimeField(help_text="CLR Round End Date") + claim_start_date = models.DateTimeField(help_text="CLR Claim Start Date", null=True) + claim_end_date = models.DateTimeField(help_text="CLR Claim Start Date", null=True) grant_filters = JSONField( default=dict, null=True, blank=True, From 2a00fe1e19bde6a967be39ab6798c195ea026d4e Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Fri, 1 Oct 2021 14:47:32 +0530 Subject: [PATCH 2/5] round / claim status on CLR page --- app/assets/v2/js/grants/index.js | 185 +++------ app/grants/models/grant.py | 4 +- app/grants/templates/grants/explorer.html | 361 ++++++++++-------- .../grants/shared/landing_qf_active.html | 9 - app/grants/views.py | 6 + 5 files changed, 265 insertions(+), 300 deletions(-) diff --git a/app/assets/v2/js/grants/index.js b/app/assets/v2/js/grants/index.js index f1e9f9685c4..f6f23e56af0 100644 --- a/app/assets/v2/js/grants/index.js +++ b/app/assets/v2/js/grants/index.js @@ -21,76 +21,9 @@ $(document).ready(() => { }); - // toggleStyle(document.current_style); }); -// Vue.component('grant-sidebar', { -// props: [ -// 'filter_grants', 'grant_types', 'type', 'selected_category', 'keyword', 'following', 'set_type', -// 'idle_grants', 'show_contributions', 'query_params', 'round_num', 'sub_round_slug', 'customer_name', -// 'featured' -// ], -// data: function() { -// return { -// search: this.keyword, -// show_filters: false, -// handle: document.contxt.github_handle -// }; -// }, -// methods: { -// toggleFollowing: function(state, event) { -// event.preventDefault; -// this.filter_grants({following: state}); -// }, -// toggleIdle: function(state, event) { -// event.preventDefault; -// this.filter_grants({idle_grants: state}); -// }, -// toggleContributionView: function(state, event) { -// event.preventDefault; -// this.filter_grants({show_contributions: state}); -// }, -// toggleMyGrants: function(state, event) { -// let me = state ? 'me' : 'all'; - -// event.preventDefault; -// this.filter_grants({type: me, category: '', keyword: ''}); -// }, -// isMobileDevice: function() { -// return window.innerWidth < 576; -// }, -// toggleMyCollections: function(state, event) { -// let me = state ? {type: 'collections', keyword: this.handle} : {type: 'all', keyword: ''}; - -// this.filter_grants(me); - -// this.search = me.keyword; -// }, -// filterLink: function(params) { - -// return this.filter_grants(params); -// }, -// searchKeyword: function() { -// if (this.timeout) { -// clearTimeout(this.timeout); -// } - -// this.timeout = setTimeout(() => { -// this.filter_grants({keyword: this.search}); -// }, 1000); -// }, -// onResize: function() { -// if (!this.isMobileDevice() && this.show_filters !== null) { -// this.show_filters = null; -// } else if (this.isMobileDevice() && this.show_filters === null) { -// this.show_filters = false; -// } -// } -// }, -// mounted() { -// window.addEventListener('resize', this.onResize); -// } -// }); + if (document.getElementById('grants-showcase')) { const baseParams = { page: 1, @@ -98,7 +31,6 @@ if (document.getElementById('grants-showcase')) { me: false, sort_option: 'weighted_shuffle', network: 'mainnet', - // keyword: this.keyword, state: 'active', profile: false, sub_round_slug: false, @@ -108,7 +40,6 @@ if (document.getElementById('grants-showcase')) { grant_tags: [], tenants: [], idle: true - }; const grantRegions = [ @@ -136,25 +67,6 @@ if (document.getElementById('grants-showcase')) { {'name': 'ALGORAND', 'label': 'Algorand'} ]; - // const grant_tags = [ - // {'name': 'ETH', 'label': 'Eth'}, - // {'name': 'ZCASH', 'label': 'Zcash'}, - // {'name': 'ZIL', 'label': 'Zil'}, - // {'name': 'CELO', 'label': 'Celo'}, - // {'name': 'POLKADOT', 'label': 'Polkadot'}, - // {'name': 'HARMONY', 'label': 'Harmony'}, - // {'name': 'KUSAMA', 'label': 'Kusama'}, - // {'name': 'BINANCE', 'label': 'Binance'}, - // {'name': 'RSK', 'label': 'Rsk'}, - // {'name': 'ALGORAND', 'label': 'Algorand'} - // ]; - - - // let sort = getParam('sort'); - - // if (!sort) { - // sort = 'weighted_shuffle'; - // } var appGrants = new Vue({ delimiters: [ '[[', ']]' ], @@ -190,10 +102,6 @@ if (document.getElementById('grants-showcase')) { sub_round_slug: false, cart_lock: false, collection_id: document.collection_id, - // round_num: document.round_num, - // clr_round_pk: document.clr_round_pk, - // sub_round_slug: document.sub_round_slug, - // customer_name: document.customer_name, activeCollection: null, grantsNumPages, grantsHasNext, @@ -218,18 +126,6 @@ if (document.getElementById('grants-showcase')) { return; } - // let banner; - - // if (style.bg) { - // banner = `url("${style.bg }") center top / ${style.size || ''} ${style.color || ''} no-repeat`; - // } else { - // banner = `url("${ style.banner_image }") center no-repeat`; - // } - // $('#grant-hero-img').css('background', banner); - // if (style.background_image) { - // $('#grant-background-image-mount-point').css('background-image', style.background_image); - // } - if (style.inline_css) { $('.page-styles').last().text(style.inline_css); } else { @@ -341,7 +237,6 @@ if (document.getElementById('grants-showcase')) { getGrants.grants.forEach(function(item) { vm.grants.unshift(item); - }); @@ -375,22 +270,7 @@ if (document.getElementById('grants-showcase')) { vm.grants.push(item); }); - // if (page) { - // vm.fetchedPages = [page]; - // } else { - // } vm.fetchedPages = [ ...vm.fetchedPages, Number(vm.params.page) ]; - // if (this.params.collection_id) { - // if (getGrants.collections.length > 0) { - // this.activeCollection = getGrants.collections[0]; - // } - // } else if (this.current_type === 'collections') { - // getGrants.collections.forEach(function(item) { - // vm.collections.push(item); - // }); - // } else { - // vm.collections = getGrants.collections; - // } vm.credentials = getGrants.credentials; vm.contributions = getGrants.contributions; @@ -428,7 +308,6 @@ if (document.getElementById('grants-showcase')) { vm.changeQuery({tab: vm.tabSelected}); vm.unobserveFilter(); vm.params.profile = false; - // vm.updateUrlParams(); if (vm.tabSelected === 'collections') { this.fetchCollections(); @@ -465,8 +344,6 @@ if (document.getElementById('grants-showcase')) { vm.loadingCollections = true; await vm.updateUrlParams(); - // vm.updateUrlParams(); - let url = `/api/v0.1/grants_collections/?${(vm.params.profile ? 'profile=' + vm.params.profile : '')}`; if (vm.collectionsPage) { @@ -619,9 +496,67 @@ if (document.getElementById('grants-showcase')) { if (!vm.clrData.results) return; - return vm.clrData?.results.find(item => { + const currentCLR = vm.clrData?.results.find(item => { return item.sub_round_slug == vm.params?.sub_round_slug; }); + + function getMDT(date) { + if (!date) + return; + return moment(date).tz('America/Denver').format('MMMM D (hA) z'); + } + + function getRoundStatus(start_date, end_date, claim_start_date, claim_end_date) { + now = moment().tz('America/Denver'); + start_date = moment(start_date).tz('America/Denver'); + end_date = moment(end_date).tz('America/Denver'); + + if (claim_start_date && claim_end_date) { + claim_start_date = moment(claim_start_date).tz('America/Denver'); + claim_end_date = moment(claim_end_date).tz('America/Denver'); + } + + console.log(now); + console.log(claim_start_date); + console.log(claim_end_date); + + if (now.isBefore(start_date)) { + // round is yet to start + return 'proposed'; + } else if (now.isBetween(start_date, end_date)) { + // round is currently live + return 'live'; + } else if ( + claim_start_date && claim_end_date && + now.isBetween(claim_start_date, claim_end_date) + ) { + // claim period is live + return 'claim'; + } + // round has ended + return 'ended'; + + } + + if (currentCLR) { + const formatted_dates = { + start_date: getMDT(currentCLR?.start_date), + end_date: getMDT(currentCLR?.end_date), + claim_start_date: getMDT(currentCLR?.claim_start_date), + claim_end_date: getMDT(currentCLR?.claim_end_date), + status: getRoundStatus( + currentCLR?.start_date, + currentCLR?.end_date, + currentCLR?.claim_start_date, + currentCLR?.claim_end_date + ) + }; + + currentCLR.formatted_dates = formatted_dates; + } + + return currentCLR; + }, isGrantExplorer() { return (this.activePage == 'grants_explorer'); diff --git a/app/grants/models/grant.py b/app/grants/models/grant.py index 647cf0e072e..a03c05ac676 100644 --- a/app/grants/models/grant.py +++ b/app/grants/models/grant.py @@ -60,8 +60,8 @@ class Meta: is_active = models.BooleanField(default=False, db_index=True, help_text="Is CLR Round currently active") start_date = models.DateTimeField(help_text="CLR Round Start Date") end_date = models.DateTimeField(help_text="CLR Round End Date") - claim_start_date = models.DateTimeField(help_text="CLR Claim Start Date", null=True) - claim_end_date = models.DateTimeField(help_text="CLR Claim Start Date", null=True) + claim_start_date = models.DateTimeField(help_text="CLR Claim Start Date", blank=True, null=True) + claim_end_date = models.DateTimeField(help_text="CLR Claim End Date", blank=True, null=True) grant_filters = JSONField( default=dict, null=True, blank=True, diff --git a/app/grants/templates/grants/explorer.html b/app/grants/templates/grants/explorer.html index 7f395965a6a..bcf741a2eb6 100644 --- a/app/grants/templates/grants/explorer.html +++ b/app/grants/templates/grants/explorer.html @@ -12,7 +12,7 @@ along with this program. If not, see . {% endcomment %} -{% load humanize static i18n bundle %} +{% load humanize static i18n tz bundle %} @@ -25,10 +25,13 @@ - {% endbundle %}