Skip to content

Commit

Permalink
Merge branch 'develop' into fix/UNT-436-change-donation_recipt.status
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad Bastin authored Nov 8, 2023
2 parents b3adbd3 + 9ff6f5e commit 0d5e0e1
Show file tree
Hide file tree
Showing 78 changed files with 2,926 additions and 6,026 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length=120
extend-ignore = E203
12 changes: 9 additions & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
max-parallel: 1
matrix:
python-version: [3.10.13]
python-version: [3.10.12]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,8 +22,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install requests
run: pip install requests
- name: Install Dependencies
run: pip install -r requirements.txt
- name: Run Tests
Expand All @@ -35,3 +33,11 @@ jobs:
DEBUG: False
SENTRY_DSN: "DEBUG-DSN"
DATABASE_URL: sqlite:///db/db.sqlite3
MEMCACHEDCLOUD_SERVERS: " "
MEMCACHEDCLOUD_USERNAME: " "
MEMCACHEDCLOUD_PASSWORD: " "
LIGHTNING_INVOICE: lnbc100n1pjxtceppp5q65xc3w8tnnmzkhqgg9c7h4a8hzplm0dppr944upwsq4q62sjeesdqu2askcmr9wssx7e3q2dshgmmndp5scqzzsxqyz5vqsp5hj2vzha0x4qvuyzrym6ryvxwnccn4kjwa57037dgcshl5ls4tves9qyyssqj24t4j2dkp2r29ptgxqz2etsk0qp8ggwmt20czfu48h5akgme43zevg6x040scjzx3qgtp8mkcg2gurv0hy8d8xm3hhf8k68uefl9sqqqscuvz
LIGHTNING_RPC_URL: https://api.lnpay.co/v1/
LIGHTNING_WALLET: ${{ secrets.LIGHTNING_WALLET }}
LIGHTNING_FUND_MANAGER: ${{ secrets.LIGHTNING_FUND_MANAGER }}
DEPLOYMENT_ENV: "dev"
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
exclude: .*migrations\/.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=100']
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: no-commit-to-branch
args: ['--branch', main, '--branch', develop ]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
language_version: python3.10
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# syntax=docker/dockerfile:1
FROM --platform=linux/amd64 python:3.10
FROM --platform=linux/amd64 python:3.10.11
WORKDIR /code
COPY requirements.txt /code/
RUN apt update && apt install gcc
COPY ./requirements.txt /code/requirements.txt
RUN pip install pip --upgrade
RUN echo installing requests befor the rest for lnpay compatibility
RUN pip install requests
RUN pip install -r requirements.txt
COPY . .
RUN mkdir db
Expand All @@ -13,4 +12,4 @@ RUN mkdir media
RUN chmod +x start_dev.sh

EXPOSE 5678
CMD ./start_dev.sh
CMD ./start_dev.sh
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: local-setup install-pre-commit install-local-reqs docker-build-dev docker-up-dev


install-local-reqs:
pip install -r requirements/local.txt

install-pre-commit:
pre-commit uninstall; pre-commit install

setup-pre-commit:
$(MAKE) install-local-reqs
$(MAKE) install-pre-commit;

docker-build-dev:
docker-compose -f docker-compose.yml build

docker-up-dev:
docker-compose up -d --force-recreate --build

docker-down-dev:
docker-compose down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@ SENTRY_DSN="DEBUG-DSN"

_read more about `DATABASE_URL` in the [dj-database-url](https://github.com/kennethreitz/dj-database-url#url-schema) docs_

### Setup pre-commit
pre-commit works with python3.10.

create a new virtualenv and activate it:

```shell
python -m virtualenv .venv
source .venv/bin/activate
```

install pre-commit:

```shell
make setup-pre-commit
```

### Using Docker Compose

you might need "sudo" privilege to run the following.

run the following command from projects root directory to build a docker image from this repo and run it:

```shell
docker compose up -d
make docker-up-dev
```

#### create a superuser:
Expand Down Expand Up @@ -62,7 +78,7 @@ you can exit the terminal now. You should now be able to visit the site on `http
create a new virtualenv and activate it:

```shell
python3.8 -m virtualenv .venv
python -m virtualenv .venv
source .venv/bin/activate
```

Expand Down
30 changes: 12 additions & 18 deletions authentication/serializers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from django.db import IntegrityError
from authentication.models import (
UserProfile,
Wallet,
)
from rest_framework.authtoken.models import Token
from rest_framework import serializers
from faucet.faucet_manager.claim_manager import LimitedChainClaimManager
from rest_framework.authtoken.models import Token

from authentication.models import UserProfile, Wallet
from faucet.faucet_manager.claim_manager import LimitedChainClaimManager
from faucet.models import GlobalSettings


Expand Down Expand Up @@ -57,7 +53,7 @@ class Meta:

class ProfileSerializer(serializers.ModelSerializer):
wallets = WalletSerializer(many=True, read_only=True)
total_weekly_claims_remaining = serializers.SerializerMethodField()
# total_round_claims_remaining = serializers.SerializerMethodField()
token = serializers.SerializerMethodField()

class Meta:
Expand All @@ -69,22 +65,20 @@ class Meta:
"initial_context_id",
"is_meet_verified",
"is_aura_verified",
"total_weekly_claims_remaining",
# "total_round_claims_remaining",
"wallets",
]

def get_token(self, instance):
token, bol = Token.objects.get_or_create(user=instance.user)
return token.key

def get_total_weekly_claims_remaining(self, instance):
gs = GlobalSettings.objects.first()
if gs is not None:
return (
gs.weekly_chain_claim_limit
- LimitedChainClaimManager.get_total_weekly_claims(instance)
)

# def get_total_round_claims_remaining(self, instance):
# gs = GlobalSettings.objects.first()
# if gs is not None:
# return gs.gastap_round_claim_limit - LimitedChainClaimManager.get_total_round_claims(instance)


class SimpleProfilerSerializer(serializers.ModelSerializer):
wallets = WalletSerializer(many=True, read_only=True)
username = serializers.SerializerMethodField()
Expand All @@ -102,4 +96,4 @@ class Meta:
def get_username(self, user_profile: UserProfile):
if not user_profile.username:
return f"User{user_profile.pk}"
return user_profile.username
return user_profile.username
31 changes: 9 additions & 22 deletions brightIDfaucet/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,23 @@
},
"update_tokentap_claim_for_verified_lightning_claims": {
"task": "faucet.tasks.update_tokentap_claim_for_verified_lightning_claims",
"schedule": 3,
"schedule": 9,
},
'update-tokens-price': {
"update-tokens-price": {
"task": "faucet.tasks.update_tokens_price",
"schedule": 600,
},
'update-donation-receipt-status': {
"update-donation-receipt-status": {
"task": "faucet.tasks.update_donation_receipt_pending_status",
"schedule": 180,
},
"draw-prizetap-raffles": {
"task": "prizetap.tasks.draw_the_expired_raffles",
"schedule": 300
},
"set-raffle-winner": {
"task": "prizetap.tasks.set_the_winner_of_raffles",
"schedule": 300
},
"request-random-words-for-linea-raffles": {
"task": "prizetap.tasks.request_random_words_for_expired_linea_raffles",
"schedule": 150
},
"draw-linea-raffles": {
"task": "prizetap.tasks.draw_expired_linea_raffles",
"schedule": 60
"request-random-words-for-raffles": {
"task": "prizetap.tasks.request_random_words_for_expired_raffles",
"schedule": 120,
},
"set-linea-raffle-winners": {
"task": "prizetap.tasks.set_the_winner_of_linea_raffles",
"schedule": 60
}
"set-raffle-random-words": {"task": "prizetap.tasks.set_raffle_random_words", "schedule": 120},
"set-raffle-winners": {"task": "prizetap.tasks.set_raffle_winners", "schedule": 300},
"get-raffle-winners": {"task": "prizetap.tasks.get_raffle_winners", "schedule": 300},
}

# Load task modules from all registered Django apps.
Expand Down
67 changes: 35 additions & 32 deletions brightIDfaucet/settings.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import logging
import os
from pathlib import Path
from faucet.faucet_manager.bright_id_interface import BrightIDInterface

import dj_database_url
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from dotenv import load_dotenv
import dj_database_url
import logging
from sentry_sdk.integrations.django import DjangoIntegration

from faucet.faucet_manager.bright_id_interface import BrightIDInterface

load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s"
)
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
'root': {
'handlers': ['console'],
'level': 'WARNING',
"root": {
"handlers": ["console"],
"level": "WARNING",
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'INFO',
"loggers": {
"django": {
"handlers": ["console"],
"level": "INFO",
},
'django.server': {
'handlers': ['console'],
'level': 'INFO',
"django.server": {
"handlers": ["console"],
"level": "INFO",
},
'django.db.backends': {
'handlers': ['console'],
'level': 'INFO',
"django.db.backends": {
"handlers": ["console"],
"level": "INFO",
},
'django.core.cache': {
'handlers': ['console'],
'level': 'ERROR', # Change this to control the log level
}
}
"django.core.cache": {
"handlers": ["console"],
"level": "ERROR", # Change this to control the log level
},
},
}


Expand All @@ -68,6 +68,9 @@ def str2bool(v):
MEMCACHED_URL = os.environ.get("MEMCACHEDCLOUD_SERVERS")
MEMCACHED_USERNAME = os.environ.get("MEMCACHEDCLOUD_USERNAME")
MEMCACHED_PASSWORD = os.environ.get("MEMCACHEDCLOUD_PASSWORD")
DEPLOYMENT_ENV = os.environ.get("DEPLOYMENT_ENV")

assert DEPLOYMENT_ENV in ["dev", "main"]


def before_send(event, hint):
Expand Down Expand Up @@ -110,14 +113,14 @@ def before_send(event, hint):
"faucet.apps.FaucetConfig",
"tokenTap.apps.TokentapConfig",
"prizetap.apps.PrizetapConfig",
"permissions.apps.PermissionsConfig",
# "permissions.apps.PermissionsConfig",
"authentication.apps.AuthenticationConfig",
"rest_framework",
"rest_framework.authtoken",
"encrypted_model_fields",
"drf_yasg",
"corsheaders",
"django_filters"
"django_filters",
]

MIDDLEWARE = [
Expand Down
18 changes: 18 additions & 0 deletions core/migrations/0003_alter_tokenprice_price_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2023-10-27 08:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0002_alter_tokenprice_price_url'),
]

operations = [
migrations.AlterField(
model_name='tokenprice',
name='price_url',
field=models.URLField(blank=True, max_length=255, null=True),
),
]
Loading

0 comments on commit 0d5e0e1

Please sign in to comment.