Bladeren bron

Added a custom management command and reconfigure cron-job

Mohidul Islam 5 jaren geleden
bovenliggende
commit
95a17d8813

+ 1 - 1
dashboard/static/main.css

@@ -90,7 +90,7 @@ a.article-title:hover {
 
 .scrollable-section {
    position: fixed;
-   max-height: 90%;
+   max-height: 80%;
    overflow: auto;
    width: 18%;
 }

+ 4 - 4
gauth/views.py

@@ -1,16 +1,17 @@
+import os
 from django.http import HttpResponse
 from django.shortcuts import redirect
-from django.urls import reverse
 import google_auth_oauthlib.flow
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.models import User
-
+from django.conf import settings
 from .auth_utils import get_access_token, get_google_account_id
 
 from .models import UserModel
 
+base_dir = settings.BASE_DIR
 
-CLIENT_SECRETS_FILE = "client_secrets.json"
+CLIENT_SECRETS_FILE = os.path.join(base_dir, "client_secrets.json")
 SCOPES = ['https://www.googleapis.com/auth/business.manage']
 flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
         CLIENT_SECRETS_FILE,
@@ -54,7 +55,6 @@ def oauth2callback(request):
     user_model.refresh_token = credentials.refresh_token
     user_model.gmb_account_id = account_id
     user_model.save()
-    print(credentials.refresh_token)
     request.session['credentials'] = credentials_to_dict(credentials)
     return redirect('token')
 

+ 0 - 0
review/management/__init__.py


+ 0 - 0
review/management/commands/__init__.py


+ 11 - 0
review/management/commands/collect_reviews.py

@@ -0,0 +1,11 @@
+from django.core.management.base import BaseCommand
+from review.review_utils import populate_reviews
+
+
+class Command(BaseCommand):
+
+    help = 'Collect all new un-recorded reviews .'
+
+    def handle(self, *args, **options):
+        populate_reviews()
+        self.stdout.write(self.style.SUCCESS('All new reviews has been stored in the database.'))

+ 2 - 1
review_automation/settings.py

@@ -126,7 +126,8 @@ TOKEN_URI = "https://oauth2.googleapis.com/token"
 HOST_URI = "http://127.0.0.1:8000"
 NLU_SERVER_URI = 'http://localhost:5005'
 
+
 # Cron-Jobs of the project
 CRONJOBS = [
-    ('0 3 * * *', 'review.review_utils.populate_reviews')
+    ('*/10 * * * *', 'review.review_utils.populate_reviews'),
 ]