Skip to content

Commit

Permalink
feat: show round / claim status on CLR page (#9544)
Browse files Browse the repository at this point in the history
* add claim date fields

* round / claim status  on CLR page

* add migration

* address review comments

* remove logs

Co-authored-by: Chibuotu Amadi <[email protected]>
  • Loading branch information
thelostone-mc and chibie authored Oct 4, 2021
1 parent 8994c21 commit 22b3c5d
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 299 deletions.
181 changes: 56 additions & 125 deletions app/assets/v2/js/grants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,16 @@ $(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,
limit: 6,
me: false,
sort_option: 'weighted_shuffle',
network: 'mainnet',
// keyword: this.keyword,
state: 'active',
profile: false,
sub_round_slug: false,
Expand All @@ -108,7 +40,6 @@ if (document.getElementById('grants-showcase')) {
grant_tags: [],
tenants: [],
idle: true

};

const grantRegions = [
Expand Down Expand Up @@ -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: [ '[[', ']]' ],
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -341,7 +237,6 @@ if (document.getElementById('grants-showcase')) {

getGrants.grants.forEach(function(item) {
vm.grants.unshift(item);

});


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -619,9 +496,63 @@ 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');
}

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');
Expand Down
28 changes: 28 additions & 0 deletions app/grants/migrations/0126_auto_20211001_0911.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.24 on 2021-10-01 09:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0125_auto_20210928_2029'),
]

operations = [
migrations.AddField(
model_name='grantclr',
name='claim_end_date',
field=models.DateTimeField(blank=True, help_text='CLR Claim End Date', null=True),
),
migrations.AddField(
model_name='grantclr',
name='claim_start_date',
field=models.DateTimeField(blank=True, help_text='CLR Claim Start Date', null=True),
),
migrations.AlterField(
model_name='contribution',
name='checkout_type',
field=models.CharField(blank=True, choices=[('eth_std', 'eth_std'), ('eth_zksync', 'eth_zksync'), ('eth_polygon', 'eth_polygon'), ('zcash_std', 'zcash_std'), ('celo_std', 'celo_std'), ('zil_std', 'zil_std'), ('polkadot_std', 'polkadot_std'), ('harmony_std', 'harmony_std'), ('binance_std', 'binance_std'), ('rsk_std', 'rsk_std'), ('algorand_std', 'algorand_std')], help_text='The checkout method used while making the contribution', max_length=30, null=True),
),
]
2 changes: 2 additions & 0 deletions app/grants/models/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", 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,
Expand Down
Loading

0 comments on commit 22b3c5d

Please sign in to comment.