Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
arcbtc committed Jun 7, 2024
1 parent aa2f21f commit ddaacbb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
11 changes: 4 additions & 7 deletions crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ async def create_participant(


async def get_participant(
raisenow_id: str, req: Optional[Request] = None
participant_id: str, req: Optional[Request] = None
) -> Optional[Participant]:
row = await db.fetchone(
"SELECT * FROM raisenow.participants WHERE id = ?", (raisenow_id,)
"SELECT * FROM raisenow.participants WHERE id = ?", (participant_id,)
)
if not row:
return None
Expand All @@ -136,14 +136,11 @@ async def get_participant(


async def get_participants(
wallet_ids: Union[str, List[str]], req: Optional[Request] = None
raisenow_id: str, req: Optional[Request] = None
) -> List[Participant]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]

q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM raisenow.participants WHERE wallet IN ({q})", (*wallet_ids,)
"SELECT * FROM raisenow.participants WHERE raisenow = ?", (raisenow_id,)
)
tempRows = [Participant(**row) for row in rows]
if req:
Expand Down
2 changes: 1 addition & 1 deletion migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def m002_initial(db):
"""
CREATE TABLE raisenow.participants (
id TEXT PRIMARY KEY,
raise TEXT NOT NULL,
raisenow TEXT NOT NULL,
name TEXT NOT NULL,
description TEXT,
profile_image TEXT,
Expand Down
40 changes: 21 additions & 19 deletions templates/raisenow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h5 class="text-subtitle1 q-my-none">raisenow</h5>
color="accent"
round
dense
@click="props.expand = !props.expand"
@click="handleClick(props.key, props)"
:icon="props.expand ? 'expand_less' : 'expand_more'"
><q-tooltip>Participants</q-tooltip></q-btn>
</q-td>
Expand Down Expand Up @@ -85,14 +85,6 @@ <h5 class="text-subtitle1 q-my-none">raisenow</h5>
class="float-left q-my-sm"
>Add Participant</q-btn
>
<q-btn
color="grey"
outline
unelevated
@click="deleteAllParticipants(props.row.id)"
class="float-left q-my-sm q-ml-sm"
>Delete All</q-btn
>
</div>
</div>

Expand Down Expand Up @@ -215,10 +207,8 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} raisenow extension</h6>
placeholder="Name for your raise"></q-input>
<q-input filled dense v-model.trim="RaiseFormDialog.data.description" label="Description (optional)"
placeholder="optional description for your raise "></q-input>
<q-select filled dense emit-value v-model="RaiseFormDialog.data.raise" :options="ranow"
label="Raise *"></q-select>
<q-input filled dense v-model.trim="RaiseFormDialog.data.profile_image" label="Profile image for the participant (optional)"
placeholder="Optional profile image"></q-input>
placeholder="Optional profile image URL 400/400px"></q-input>
<div class="row q-mt-lg">
<q-btn v-if="RaiseFormDialog.data.id" unelevated color="primary" type="submit" color="primary">Update raisenow</q-btn>
<q-btn v-else unelevated color="primary"
Expand Down Expand Up @@ -377,11 +367,18 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} raisenow extension</h6>
console.log(this.RaiseFormDialog.data.live_dates)
const data = {
name: this.RaiseFormDialog.data.name,
description: this.RaiseFormDialog.data.description,
background_image: this.RaiseFormDialog.data.background_image,
header_image: this.RaiseFormDialog.data.header_image,
live_dates: String(this.RaiseFormDialog.data.live_dates.from + ',' + this.RaiseFormDialog.data.live_dates.to)
description: this.RaiseFormDialog.data.description
}
if(this.RaiseFormDialog.data.live_dates){
data.live_dates = String(this.RaiseFormDialog.data.live_dates.from + ',' + this.RaiseFormDialog.data.live_dates.to)
}
if(this.RaiseFormDialog.data.background_image){
data.background_image = this.RaiseFormDialog.data.background_image
}
if(this.RaiseFormDialog.data.header_image){
data.header_image = this.RaiseFormDialog.data.header_image
}

const wallet = _.findWhere(this.g.user.wallets, {
id: this.RaiseFormDialog.data.wallet
})
Expand Down Expand Up @@ -493,7 +490,7 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} raisenow extension</h6>
LNbits.api
.request(
'GET',
'/participants/api/v1/' + raID,
'/raisenow/api/v1/participants/' + raID,
this.g.user.wallets[0].inkey
)
.then(function (response) {
Expand All @@ -503,9 +500,9 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} raisenow extension</h6>
})
})
},
openParticipantDialog: function (id) {
openParticipantDialog: function (raId) {
this.ParticpantsFormDialog.data = {
raisenow: id
raisenow: raId
}
this.ParticpantsFormDialog.show = true
},
Expand Down Expand Up @@ -564,6 +561,11 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} raisenow extension</h6>
return obj.raisenow == partId
})
},
handleClick(id, props) {
console.log(id)
this.getparticipants(id)
props.expand = !props.expand
},
makeItRain: function () {
document.getElementById("vue").disabled = true
var end = Date.now() + (2 * 1000)
Expand Down
5 changes: 5 additions & 0 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
delete_raisenow,
get_raisenow,
get_raisenows,
create_participant,
update_participant,
delete_participant,
get_participant,
get_participants,
)
from .models import CreateRaiseNowData, CreateParticipantData, Participant, RaiseNow

Expand Down

0 comments on commit ddaacbb

Please sign in to comment.