Skip to content
Permalink
Browse files

minor contract addition and test; UI breadcrumbing; 'About' moved to …

…base template
  • Loading branch information
kdmukai committed Jul 30, 2019
1 parent 0d3e09b commit 73955c96b0a67408f185a67b6ffffa4038bc61a6
@@ -86,6 +86,13 @@ def get_achievement(ecosys_key, cat_key, key):
ecosystem = ecosystems.get('rows', [])[0]
achievement = ecosystem.get('categories')[int(cat_key)].get('achievements')[int(key)]
achievement['key'] = int(key)

if achievement['maxquantity'] == 0:
achievement['num_available'] = 'unlimited'
achievement['maxquantity'] = 'unlimited'
else:
achievement['num_available'] = achievement['maxquantity'] - len(achievement.get('usergrants', []))

users = []
for usergrant in achievement.get('usergrants'):
user = ecosystem.get('users')[usergrant.get('user_id')]
@@ -126,6 +133,10 @@ def get_proofofachievement(ecosys_key, cat_key, ach_key, user_key):
ecosystem = ecosystems.get('rows', [])[0]
achievement = ecosystem.get('categories')[int(cat_key)].get('achievements')[int(ach_key)]
achievement['key'] = int(ach_key)

if achievement['maxquantity'] == 0:
achievement['maxquantity'] = 'unlimited'

user = ecosystem.get('users')[int(user_key)]
user['key'] = int(user_key)
if not user.get('avatarurl').startswith('http'):
@@ -26,10 +26,36 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<style>
.tweet_button {
position: absolute;
top: 0.5em;
right: 1em;
.breadcrumbing {
font-size: 0.7em;
margin-left: 0.5em;
margin-bottom: 1.5em;
}
.info {
margin-top: 6em;
margin-left: -1em;
margin-right: -1em;
margin-bottom: -1em;
padding-top: 2em;
padding-left: 0.25em;
padding-right: 0.25em;
border-top: 4px solid #6cc7cc;
background-color: #2c878c;
background-image: linear-gradient(#4ca7ac 30%, #7cd7dc);
background-repeat: no-repeat;
background-attachment: fixed;
padding-bottom: 3em;
color: #333;
}
.tagline {
font-style: italic;
text-align: center;
margin-bottom: 1em;
}
.info_text {
max-width: 700px;
margin: auto;
font-size: 0.8em;
}
</style>
{% block header_content %}
@@ -55,14 +81,32 @@

</header>
<body>
{% block social_media_shares %}{% endblock %}
<a href="/"><img width="175" height="36" src="{{ url_for('static', filename='img/waxbadges_logo_350x72.png') }}" /></a>
<div class="breadcrumbing">
{% block breadcrumbing %}
{% endblock %}
</div>

<div class="main_content">
{% block main_content %}
{% endblock %}
</div>

<div class="info">
<div class="page_title">About WAXBadges</div>

<div class="tagline">Achievements logged on the blockchain for eternity! Keep what you earn!</div>

<div class="info_text">
WAXBadges is an open Achievements platform that safely preserves your achievements forever on the WAX blockchain. Even if the game or company disappears, your achievements will always live on!

<p>Any game studio or app developer can easily integrate their achievements into WAXBadges at almost zero cost.

<p>Learn more at <a href="https://github.com/kdmukai/waxbadges" target="_new">https://github.com/kdmukai/waxbadges</a>
</div>

</div>

{% block js_content %}
{% endblock %}
</body>
@@ -105,22 +105,13 @@




{% block social_media_shares %}
<div class="tweet_button">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-size="large"
data-text="The &quot;{{ achievement.name }}&quot; achievement from {{ ecosystem.name }}"
data-url="https://explorer.waxbadges.com/ach/{{ ecosystem.key }}/{{ category_id }}/{{ achievement.key }}"
data-related="WAXBadges">
Tweet
</a>
</div>
{% block breadcrumbing %}
<a href="/">home</a> > <a href="/ecosys/{{ ecosystem.key }}">{{ ecosystem.name }}</a> > {{ achievement.name }}
{% endblock %}




{% block main_content %}
<div id="ecosystem_name" class="page_title">{{ ecosystem.name }}</div>
<div id="ecosystem_website"><a href="{{ ecosystem.website }}" target="_new">{{ ecosystem.website }}</a></div>
@@ -129,12 +120,22 @@
<div class="achievement">
<img class="ach_asset" src="//{{ ecosystem.assetbaseurl }}/{{ achievement.assetname }}"/>
<div class="ach_name">{{ achievement.name }}</div>
<div class="ach_quantity">max: {{ achievement.maxquantity }}</div>
<div class="ach_quantity">max: {{ achievement.maxquantity }} / remaining: {{ achievement.num_available }}</div>
<div class="ach_description">{{ achievement.description }}</div>
<div class="tweet_button">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-size="large"
data-text="The &quot;{{ achievement.name }}&quot; achievement from {{ ecosystem.name }}"
data-url="https://explorer.waxbadges.com/ach/{{ ecosystem.key }}/{{ category_id }}/{{ achievement.key }}"
data-related="WAXBadges">
Tweet
</a>
</div>
</div>

<div class="usergrants">
<div class="section_title">User Grants</div>
<div class="section_title">Awarded to</div>
{% for usergrant in usergrants %}
<div class="usergrant" id="usergrant_{{ usergrant.user.user_id }}">
<img src="{{ usergrant.user.avatarurl }}"/>
@@ -76,6 +76,11 @@



{% block breadcrumbing %}
<a href="/">home</a> > {{ ecosystem.name }}
{% endblock %}



{% block main_content %}
<div id="ecosystem_name" class="page_title">{{ ecosystem.name }}</div>
@@ -121,66 +121,31 @@
font-size: 0.7em;
color: #555;
}
.vmiddle {
vertical-align: middle;
}
.tweet_button {
margin-bottom: -0.5em;
}
.raw_blockchain_container {
margin-top: 0.5em;
text-align: center;
font-size: 0.75em;
}
.info {
margin-top: 6em;
margin-left: -1em;
margin-right: -1em;
margin-bottom: -1em;
padding-top: 2em;
padding-left: 0.25em;
padding-right: 0.25em;
border-top: 4px solid #6cc7cc;
background-color: #2c878c;
background-image: linear-gradient(#2c878c 30%, #6cc7cc);
background-repeat: no-repeat;
background-attachment: fixed;
padding-bottom: 3em;
color: #333;
}
.tagline {
font-style: italic;
text-align: center;
margin-bottom: 1em;
}
.info_text {
max-width: 700px;
margin: auto;
font-size: 0.8em;
}
.info a {
color: #d8d8d8;
}
.info a:hover {
color: white;
}
</style>
{% endblock %}




{% block social_media_shares %}
<div class="tweet_button">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-size="large"
data-text="Proof-of-Achievement: I earned the &quot;{{ achievement.name }}&quot; achievement from {{ ecosystem.name }}!"
data-url="https://explorer.waxbadges.com/poa/{{ ecosystem.key }}/{{ category_id }}/{{ achievement.key }}/{{ user.key }}"
data-related="WAXBadges">
Tweet
</a>
</div>
{% block breadcrumbing %}
<a href="/">home</a> > <a href="/ecosys/{{ ecosystem.key }}">{{ ecosystem.name }}</a> > <a href="/ach/{{ ecosystem.key }}/{{ category_id }}/{{ achievement.key }}">{{ achievement.name }}</a> > Proof-of-Achievement
{% endblock %}




{% block main_content %}
<div id="ecosystem_name" class="page_title">{{ ecosystem.name }}</div>
<div id="ecosystem_website"><a href="{{ ecosystem.website }}" target="_new">{{ ecosystem.website }}</a></div>
@@ -213,8 +178,22 @@
</tr>
<tr>
<td class="label">max&nbsp;avail:</td>
<td class="value">{% if achievement.maxquantity == 0 %}unlimited{% else %}{{ achievement.maxquantity }}{% endif %}</td>
<td class="value">{{ achievement.maxquantity }}</td>
</tr>
<tr>
<td class="label vmiddle">share:</td>
<td class="value">
<div class="tweet_button">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-size="large"
data-text="Proof-of-Achievement: I earned the &quot;{{ achievement.name }}&quot; achievement from {{ ecosystem.name }}!"
data-url="https://explorer.waxbadges.com/poa/{{ ecosystem.key }}/{{ category_id }}/{{ achievement.key }}/{{ user.key }}"
data-related="WAXBadges">
Tweet
</a>
</div>
</td>
</table>
</div>
<div class="clearfix"></div>
@@ -223,20 +202,6 @@
<div class="raw_blockchain_container">
raw blockchain data: <a href="https://wax.bloks.io/contract?tab=Tables&table=ecosystems&account=waxbadgesftw&scope=waxbadgesftw" target="_new">wax.blocks.io</a>
</div>

<div class="info">
<div class="page_title">About WAXBadges</div>

<div class="tagline">Achievements logged on the blockchain for eternity! Keep what you earn!</div>

<div class="info_text">
WAXBadges is an open Achievements platform that safely preserves user achievements forever on the WAX blockchain. Even if the game or company behind it disappears, your achievements will always live on!

<p>Learn more at <a href="https://github.com/kdmukai/waxbadges" target="_new">https://github.com/kdmukai/waxbadges</a>
</div>

</div>

{% endblock %}


@@ -534,6 +534,31 @@ def test_0710_edit_granted_achievement_fails(self):
self.assertTrue(table.json["rows"][0]["categories"][0]["achievements"][achievement_id]["name"] != new_achievement_name)


def test_0711_edit_assetname_granted_achievement(self):
COMMENT("Should allow a WAX account to update the assetname for an Achievement that has been granted at least once")
achievement_id = 0
new_assetname = "newname.png"

table = CONTRACT.table("ecosystems", CONTRACT)
self.assertTrue(len(table.json["rows"][0]["categories"][0]["achievements"][achievement_id]["usergrants"]) > 0)

CONTRACT.push_action(
"editachasset",
{
"ecosystem_owner": STUDIOA,
"ecosystem_id": 0,
"category_id": 0,
"achievement_id": achievement_id,
"assetname": new_assetname
},
permission=(STUDIOA, Permission.ACTIVE)
)

table = CONTRACT.table("ecosystems", CONTRACT)
self.assertTrue(table.json["rows"][0]["categories"][0]["achievements"][achievement_id]["assetname"] == new_assetname, table.json["rows"][0]["categories"][0]["achievements"][achievement_id]["assetname"])



def test_0750_rmecosys_with_granted_achievement_fails(self):
COMMENT("Should prevent an WAX account from deleting an Ecosystem that has an Achievement that has been granted at least once")
ecosystem_id = 0
@@ -272,9 +272,9 @@ class [[eosio::contract("waxbadges")]] waxbadges : public contract {


/**
Editing an achievement risks upsetting our expectation of permanence. For
now we only allow editing an Achievement that hasn't been granted to any
Users.
Editing an achievement risks upsetting our expectation of permanence. The
full Achievement details can only be updated if it hasn't already been
granted to a User (see editachasset to just update the assetname).
**/
[[eosio::action]]
void editach( name ecosystem_owner,
@@ -317,6 +317,36 @@ class [[eosio::contract("waxbadges")]] waxbadges : public contract {
}


[[eosio::action]]
void editachasset(name ecosystem_owner,
uint32_t ecosystem_id,
uint32_t category_id,
uint32_t achievement_id,
string assetname) {
check_is_contract_or_owner(ecosystem_owner);

validateAssetname(assetname);

auto ecosystems_table = get_ecosystems_table_for(get_self());
auto ecosystems_iter = ecosystems_table.find(ecosystem_id);
check(ecosystems_iter != ecosystems_table.end(), "Ecosystem not found");

// The ecosystem_owner must match the Ecosystem.account to make changes
check(ecosystems_iter->account == ecosystem_owner, "Not authorized");

check(category_id < ecosystems_iter->categories.size(), "Category not found");

auto achievements = ecosystems_iter->categories[category_id].achievements;
check(achievement_id < achievements.size(), "Achievement not found");

// Can update assetname regardless of whether or not the Achievement has
// already been granted at least once.
ecosystems_table.modify(ecosystems_iter, maybe_charge_to(ecosystem_owner), [&](auto& ecosystem) {
ecosystem.categories[category_id].achievements[achievement_id].assetname = assetname;
});
}


/**
Deletes the last Achievement in the Category. We only allow deleting from
the end because we rely on vector index position as the Achievement key;
@@ -740,5 +770,5 @@ class [[eosio::contract("waxbadges")]] waxbadges : public contract {
};


EOSIO_DISPATCH( waxbadges, (addecosys)(editecosys)(ecosysowner)(rmecosys)(addcat)(editcat)(rmlastcat)(addach)(editach)(rmlastach)(retireach)(adduser)(edituser)(wipeusername)(approveclaim)(claimuser)(grantach)(wipetables) )
EOSIO_DISPATCH( waxbadges, (addecosys)(editecosys)(ecosysowner)(rmecosys)(addcat)(editcat)(rmlastcat)(addach)(editach)(editachasset)(rmlastach)(retireach)(adduser)(edituser)(wipeusername)(approveclaim)(claimuser)(grantach)(wipetables) )

0 comments on commit 73955c9

Please sign in to comment.
You can’t perform that action at this time.