Skip to main content

============ Aparnik

Aparnik is a simple Django app to help about some common problems. For each question, visitors can choose between a fixed number of answers.

Detailed documentation is in the "docs" directory.

Quick start

  1. Use your custom module.

  2. Add dependency:

    INSTALLED_APPS = [

     'azbankgateways',
     
     's3direct',
    
     'polymorphic',
    
     'fcm_django',
    
     'rest_framework',
    
     'jalali_date',
    
     'dynamic_raw_id',
    
     'django_filters',
    
     'ckeditor',
    
     'ckeditor_uploader',
    
     'tagulous',
    
     'colorfield',
    
     # app
     'aparnik',
    
     'aparnik.contrib.suit',
    
     'aparnik.contrib.users',
     
     'aparnik.contrib.audits',
    
     'aparnik.contrib.addresses',
    
     'aparnik.contrib.bankaccounts',
    
     'aparnik.contrib.managements',
    
     'aparnik.contrib.aboutus',
    
     'aparnik.contrib.contactus',
    
     'aparnik.contrib.province',
    
     'aparnik.contrib.invitations',
    
     'aparnik.contrib.basemodels',
    
     'aparnik.contrib.filefields',
    
     'aparnik.contrib.bookmarks',
    
     'aparnik.contrib.reviews',
    
     'aparnik.contrib.questionanswers',
    
     'aparnik.contrib.socials',
    
     'aparnik.contrib.sliders',
    
     'aparnik.contrib.settings',
    
     'aparnik.contrib.counters',
    
     'aparnik.contrib.notifications',
     
     'aparnik.contrib.messaging',
     
     'aparnik.contrib.chats',
    
     'aparnik.contrib.notifiesme',
    
     'aparnik.contrib.shortblogs',
    
     'aparnik.contrib.supports',
    
     'aparnik.contrib.faq',
    
     'aparnik.contrib.termsandconditions',
    
     'aparnik.contrib.segments',
    
     'aparnik.contrib.buttons',
    
     'aparnik.contrib.categories',
    
     'aparnik.contrib.pages',
    
     'aparnik.packages.shops.products',
    
     'aparnik.packages.shops.productssharing',
    
     'aparnik.packages.bankgateways.zarinpals',
    
     'aparnik.packages.shops.payments',
    
     'aparnik.packages.shops.subscriptions',
    
     'aparnik.packages.shops.orders',
    
     'aparnik.packages.shops.coupons',
    
     'aparnik.packages.shops.cosales',
    
     'aparnik.packages.shops.vouchers',
    
     'aparnik.packages.shops.files',
    
     'aparnik.packages.educations.books',
    
     'aparnik.packages.educations.educations',
    
     'aparnik.packages.educations.teachers',
    
     'aparnik.packages.educations.courses',
    
     'aparnik.packages.educations.progresses',
    
     'aparnik.packages.news',
     ]
    
  3. Add config to settings if you want:

    APARNIK = {

        'API_PRODUCT_MODE': True,
        'AWS_ACTIVE': True,
        'BANK_ACTIVE': True,
    }

    CKEDITOR_CONFIGS = {
        'basic': {
            'toolbar': 'Basic',
        },
    }

    CKEDITOR_UPLOAD_PATH = "/"

    FCM_DJANGO_SETTINGS = {
        'FCM_SERVER_KEY': NOTIFICATION_API_KEY,
         # true if you want to have only one active device per registered user at a time
         # default: False
        'ONE_DEVICE_PER_USER': False,
         # devices to which notifications cannot be sent,
         # are deleted upon receiving error response from FCM
         # default: False
        'DELETE_INACTIVE_DEVICES': False,
    }


    # Amazon
    AWS_HEADERS = {  # see http://developer.yahoo.com/performance/rules.html#expires
            'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
            'Cache-Control': 'max-age=94608000',
    }

    AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
    AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
    AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')

    if not AWS_SECRET_ACCESS_KEY or not AWS_ACCESS_KEY_ID or not AWS_STORAGE_BUCKET_NAME:
            raise ValueError('AWS KEY does not set')

    S3DIRECT_REGION = os.environ.get('S3DIRECT_REGION', 'us-east-1')


    # Tell django-storages that when coming up with the URL for an item in S3 storage, keep
    # it simple - just use this domain plus the path. (If this isn't set, things get complicated).
    # This controls how the `static` template tag from `staticfiles` gets expanded, if you're using it.
    # We also use it in the next setting.
    # AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
    AWS_S3_CUSTOM_DOMAIN = 's3-%s.amazonaws.com/%s' % (S3DIRECT_REGION, AWS_STORAGE_BUCKET_NAME)
    # This is used by the `static` template tag from `static`, if you're using that. Or if anything else
    # refers directly to STATIC_URL. So it's safest to always set it.
    # #
    STATICFILES_LOCATION = 'static'
    STATICFILES_STORAGE = 'custom_storages.StaticStorage'
    STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)
    # #
    # STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
    # STATIC_URL = '/static/'

    # MEDIA
    MEDIAFILES_LOCATION = 'media'
    MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)
    DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'

    def create_filename(filename):
        import uuid
        ext = filename.split('.')[-1]
        filename = '%s.%s' % (uuid.uuid4().hex, ext)
        return os.path.join('files', filename)

    def create_file_filename(filename):
        import uuid
        ext = filename.split('.')[-1]
        filename = '%s.%s' % (uuid.uuid4().hex, ext)
        return os.path.join('file', filename)


    S3DIRECT_DESTINATIONS = {
        # Allow anybody to upload any MIME type
        # 'misc': {
        #     'key': '/'
        # },

        # Allow staff users to upload any MIME type
        # 'pdfs': {
        #     'key': 'uploads/pdfs',
        #     'auth': lambda u: u.is_staff
        # },

        # Allow anybody to upload jpeg's and png's. Limit sizes to 500b - 4mb
        'images': {
            # 'key': 'uploads/images',
            'key': create_filename,
            'auth': lambda u: u.is_authenticated,
            'allowed': [
                'image/jpeg',
                'image/png'
            ],
            'content_length_range': (500, 4000000),
        },

        # Allow authenticated users to upload mp4's
        'videos': {
            # 'key': 'uploads/videos',
            'key': create_filename,
            'auth': lambda u: u.is_authenticated,
            'allowed': ['video/mp4']
        },

        'file': {
            # 'key': 'uploads/videos',
            'key': create_file_filename,
            'auth': lambda u: u.is_authenticated,
            # TODO: add mime type
            # 'allowed': ['application/octet-stream ipa']
        },
        # Allow anybody to upload any MIME type with a custom name function
        # 'custom_filename': {
        #     'key': create_filename
        # },
    }

  1. Add to urls
    url(r'^admin/dynamic_raw_id/', include('dynamic_raw_id.urls')),
    url(r'^api/v1/aparnik/', include('aparnik.urls.api', namespace='aparnik-api')),
    url(r'^aparnik/', include('aparnik.urls.urls', namespace='aparnik')),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
  1. Add clock to procfile

  2. Add line below to wsgi.py:

    from aparnik.clock import *

  3. Add settings key:

    'LOGO_PROJECT_ICON' = 'https://cdn.aparnik.com/static/website/img/logo-persian.png' # لوگو 'SERVER_NAME' = 'educationtest.aparnik.com' # آدرس سایت 'SERVER_PORT' = '80' # پورت سایت 'PRODUCT_WALLET_ID' = 168 # شارژ کیف پول 'COURSE_LEVEL' = 2 # سطح دوره 'INVITER_GIFT_CREDITS_PER_PURCHASE' = 0 # درصد اعتبار هدیه برای دعوت کننده به ازای هر خرید 'INVITER_GIFT_CREDITS' = 20000 # اعتبار هدیه برای دعوت کننده در بدو قبول دعوت تومان 'PRICE_FORMAT' = '%ic=t:%se=,:%cu=t:%gr=3:%tr=True:%abbr=True' # فرمت قیمت ها 'PRICE_PRODUCT_FREE_DESCRIPTION' = 'Free' # عنوان کالاهای رایگان 'PRICE_PRODUCT_SHARING_DESCRIPTION' = 'Shared' # عنوان کالاهایی که دعوت شده اند 'PRICE_PRODUCT_BUY_DESCRIPTION' = 'Bought' # عنوان کالاهای خریداری شده

  4. Add this line to url

    handler404 = 'aparnik.contrib.suit.views.handler404' handler500 = 'aparnik.contrib.suit.views.handler500'

  5. Config azbankgateways

notifications settings

NOTIFICATIONS_CHANNELS = { 'websocket': 'aparnik.contrib.chats.channels.BroadCastWebSocketChannel' } more read notification/messaging in aparnik.contrib.messaging.readme

run

celery -A chatire worker -l info uwsgi --http :8081 --gevent 2 --module websocket --gevent-monkey-patch --master

Metadata

Release files for django-apar 2.0.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-apar 2.0.15
File Size Uploaded
django-apar-2.0.15.tar.gz 3.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-apar 2.0.15
File Interpreter ABI Platform
django_apar-2.0.15-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 MB

Release files / django-apar-2.0.15.tar.gz

Download URL django-apar-2.0.15.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
53f4095f3bc37d485bb4716cbffb5bc20093f37777230b9d3ff18a1b06adbeca
BLAKE2b-256 checksum
How to use checksums
4681436805d2aa5701b9e86dfc91b40b758680e92b63c15e2c198674c499d0b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.13

Release files / django_apar-2.0.15-py3-none-any.whl

Download URL django_apar-2.0.15-py3-none-any.whl
Size 3.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
80ba0116fb660907c9beec7f8cbf0b1409f18788dc33edd13f32f0a6cecd04c5
BLAKE2b-256 checksum
How to use checksums
dd90a51dffe169be75bc99687990936c3b6f45fd08b875d8f91d5f3d1d837a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.13

Release history Release notifications | RSS feed

This release

2.0.15 This release

2 release files

2.0.13

2 release files

2.0.12

2 release files

2.0.11

2 release files

2.0.10

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

1.1.6.9

1 release file

1.1.6.7

1 release file

1.1.6.6

1 release file

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page