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

Testnet -> Dev #26

Merged
merged 15 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Dev deploy to EC2 on Push

on:
push:
branches: [dev]

env:
AWS_REGION: "us-east-1"

# Permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
DeployToCodeDeploy:
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::471112976510:role/GitHubAction-AssumeRoleWithAction
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}

- name: Generate appspec.yml for dev
run: cp appspec-dev.yml appspec.yml

- name: Set environment variables
id: vars
run: |
echo "DATETIME=$(date +'%Y-%m-%d_%H-%M-%S')" >> $GITHUB_ENV
echo "FILENAME=django-indexer-dev-${DATETIME}.zip" >> $GITHUB_ENV
echo "S3_BUCKET=django-indexer-dev" >> $GITHUB_ENV

- name: Create zip of repository
run: zip -r "${{ env.FILENAME }}" .

- name: Upload repository to S3
run: aws s3 cp "${{ env.FILENAME }}" "s3://${{ env.S3_BUCKET }}/"

- name: Create CodeDeploy Deployment
id: deploy
run: |
aws deploy create-deployment \
--application-name django-indexer \
--deployment-group-name django-indexer-dev-group \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--s3-location bucket=${{ env.S3_BUCKET }},bundleType=zip,key=${{ env.FILENAME }}
66 changes: 66 additions & 0 deletions .github/workflows/deploy-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Testnet deploy to EC2 on Push

on:
push:
branches: [testnet]

env:
AWS_REGION: "us-east-1"

# Permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
DeployToCodeDeploy:
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::471112976510:role/GitHubAction-AssumeRoleWithAction
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}

- name: Generate appspec.yml for testnet
run: cp appspec-testnet.yml appspec.yml

- name: Set environment variables
id: vars
run: |
echo "DATETIME=$(date +'%Y-%m-%d_%H-%M-%S')" >> $GITHUB_ENV
echo "FILENAME=django-indexer-testnet-${DATETIME}.zip" >> $GITHUB_ENV
echo "S3_BUCKET=django-indexer-testnet" >> $GITHUB_ENV

- name: Create zip of repository
run: zip -r "${{ env.FILENAME }}" .

- name: Upload repository to S3
run: aws s3 cp "${{ env.FILENAME }}" "s3://${{ env.S3_BUCKET }}/"

- name: Create CodeDeploy Deployment
id: deploy
run: |
aws deploy create-deployment \
--application-name django-indexer-testnet \
--deployment-group-name django-indexer-testnet-group \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--s3-location bucket=${{ env.S3_BUCKET }},bundleType=zip,key=${{ env.FILENAME }}

# - name: Create zip of repository
# run: zip -r django-indexer-testnet.zip .

# - name: Upload repository to S3
# run: aws s3 cp django-indexer-testnet.zip s3://django-indexer-testnet/

# - name: Create CodeDeploy Deployment
# id: deploy
# run: |
# aws deploy create-deployment \
# --application-name django-indexer-testnet \
# --deployment-group-name django-indexer-testnet-group \
# --deployment-config-name CodeDeployDefault.AllAtOnce \
# --s3-location bucket=django-indexer-testnet,bundleType=zip,key=django-indexer-testnet.zip
106 changes: 0 additions & 106 deletions .github/workflows/deploy.yml

This file was deleted.

47 changes: 37 additions & 10 deletions accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
from django.contrib import admin

from .models import Account


@admin.register(Account)
class AccountAdmin(admin.ModelAdmin):
list_display = ('id', 'total_donations_in_usd', 'total_donations_out_usd', 'total_matching_pool_allocations_usd', 'donors_count')
search_fields = ('id',) # Allow searching by account address
list_filter = ('total_donations_in_usd', 'total_donations_out_usd') # Filter by donation amounts
ordering = ('-total_donations_in_usd',) # Default ordering
list_display = (
"id",
"total_donations_in_usd",
"total_donations_out_usd",
"total_matching_pool_allocations_usd",
"donors_count",
)
search_fields = ("id",) # Allow searching by account address
list_filter = (
"total_donations_in_usd",
"total_donations_out_usd",
) # Filter by donation amounts
ordering = ("-total_donations_in_usd",) # Default ordering

# Optionally, format decimal fields for better readability in the admin
def total_donations_in_usd_display(self, obj):
return "${:,.2f}".format(obj.total_donations_in_usd)
total_donations_in_usd_display.admin_order_field = 'total_donations_in_usd'
total_donations_in_usd_display.short_description = 'Total Donations Received (USD)'

total_donations_in_usd_display.admin_order_field = "total_donations_in_usd"
total_donations_in_usd_display.short_description = "Total Donations Received (USD)"

def total_donations_out_usd_display(self, obj):
return "${:,.2f}".format(obj.total_donations_out_usd)
total_donations_out_usd_display.admin_order_field = 'total_donations_out_usd'
total_donations_out_usd_display.short_description = 'Total Donations Sent (USD)'

total_donations_out_usd_display.admin_order_field = "total_donations_out_usd"
total_donations_out_usd_display.short_description = "Total Donations Sent (USD)"

def total_matching_pool_allocations_usd_display(self, obj):
return "${:,.2f}".format(obj.total_matching_pool_allocations_usd)
total_matching_pool_allocations_usd_display.admin_order_field = 'total_matching_pool_allocations_usd'
total_matching_pool_allocations_usd_display.short_description = 'Total Matching Pool Allocations (USD)'

total_matching_pool_allocations_usd_display.admin_order_field = (
"total_matching_pool_allocations_usd"
)
total_matching_pool_allocations_usd_display.short_description = (
"Total Matching Pool Allocations (USD)"
)

def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False
44 changes: 33 additions & 11 deletions activities/admin.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
from django.contrib import admin
from django.utils.html import format_html
from .models import Activity, Account

from .models import Account, Activity


@admin.register(Activity)
class ActivityAdmin(admin.ModelAdmin):
list_display = ('id', 'signer_address', 'receiver_address', 'timestamp', 'type', 'transaction_link', 'action_result')
list_filter = ('timestamp', 'type', 'signer', 'receiver')
search_fields = ('signer__id', 'receiver__id', 'tx_hash')
date_hierarchy = 'timestamp'
ordering = ('-timestamp',)
list_display = (
"id",
"signer_address",
"receiver_address",
"timestamp",
"type",
"transaction_link",
"action_result",
)
list_filter = ("timestamp", "type", "signer", "receiver")
search_fields = ("signer__id", "receiver__id", "tx_hash")
date_hierarchy = "timestamp"
ordering = ("-timestamp",)

def signer_address(self, obj):
return obj.signer.id
signer_address.admin_order_field = 'signer'
signer_address.short_description = 'Signer Address'

signer_address.admin_order_field = "signer"
signer_address.short_description = "Signer Address"

def receiver_address(self, obj):
return obj.receiver.id
receiver_address.admin_order_field = 'receiver'
receiver_address.short_description = 'Receiver Address'

receiver_address.admin_order_field = "receiver"
receiver_address.short_description = "Receiver Address"

def transaction_link(self, obj):
url = f"https://nearblocks.io?query={obj.tx_hash}"
return format_html('<a href="{}" target="_blank">{}</a>', url, obj.tx_hash)
transaction_link.short_description = 'Transaction Hash' # Sets the column header

transaction_link.short_description = "Transaction Hash" # Sets the column header

# def action_result_summary(self, obj):
# return "Has Result" if obj.action_result else "No Result"
# action_result_summary.short_description = 'Action Result'

def has_add_permission(self, request):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False
16 changes: 16 additions & 0 deletions appspec-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/django-indexer
hooks:
# # Install:
AfterInstall:
- location: scripts/after_install_dev.sh
timeout: 300
runas: ec2-user
# ApplicationStart:
# - location: scripts/application_start.sh
# timeout: 300
# runas: root
# # ValidateService:
16 changes: 16 additions & 0 deletions appspec-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/django-indexer-testnet
hooks:
# # Install:
AfterInstall:
- location: scripts/after_install_testnet.sh
timeout: 300
runas: ec2-user
# ApplicationStart:
# - location: scripts/application_start.sh
# timeout: 300
# runas: root
# # ValidateService:
Loading
Loading