Skip to content

Commit

Permalink
conflicts fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
aminatadjer committed Jul 1, 2020
2 parents 23c3e5d + 34aa3cb commit 4a40cac
Show file tree
Hide file tree
Showing 44 changed files with 100 additions and 25 deletions.
8 changes: 5 additions & 3 deletions API/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from datetime import timedelta
from config import LOBELIAS_EMAIL, LOBELIAS_MDP

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Expand All @@ -29,7 +30,8 @@
# SECURITY WARNING: don't run with debug turned on in production!
#DEBUG = os.environ.get('DEBUG', False)
DEBUG = True
ALLOWED_HOSTS = ["192.168.1.9", "127.0.0.1", "localhost"]

ALLOWED_HOSTS = ["192.168.1.9", "127.0.0.1", "localhost", '198.211.99.20']


# Application definition
Expand Down Expand Up @@ -219,8 +221,8 @@
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = 'lobeliasteam@gmail.com'
EMAIL_HOST_PASSWORD = 'gfgcklisma-@*'
EMAIL_HOST_USER = LOBELIAS_EMAIL
EMAIL_HOST_PASSWORD = LOBELIAS_MDP
EMAIL_USE_TLS = True


Expand Down
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ pip install django-cors-headers
pip install djangorestframework-simplejwt

pip install dj_database_url

pip install tweepy

pip install feedparser
Binary file added __pycache__/config.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified article/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified article/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified article/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#for twitter scrapping
CONSUMER_KEY = 'dF8LarLqWcQAlZ3FqomAFGWNZ'
CONSUMER_SECRET = 'eaKxAM5scchwogxYo8oEzC4XkangtrDMsuNqx8ZlqBDuVMpBpZ'
ACCESS_TOKEN = '1046391379360919552-IOEg7xCFH03syq18cGhU3DJxDRVj4D'
ACCESS_TOKEN_SECRET = 'UUjxB6r8yyEQAe0ffcGI7oqPvKI50pxwwmZGSmXkbQbt3'

#email de notifications
LOBELIAS_EMAIL= 'lobeliasteam@gmail.com'
LOBELIAS_MDP= 'gfgcklisma-@*'
CCC_AGENT_EMAIL= 'ga_tadjer@esi.dz'
HEALTH_AGENT_EMAIL= 'ga_tadjer@esi.dz'
Binary file added coronawatch/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added coronawatch/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified customauth/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified map/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified map/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified map/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified report/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file modified report/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions report/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from rest_framework import viewsets, permissions, renderers


from config import CCC_AGENT_EMAIL, HEALTH_AGENT_EMAIL
from .serializers import *


Expand All @@ -29,7 +29,7 @@ def show_list(self, request):
if(serializers.is_valid()):
serializers.save()
send(request.data['commentaire'],
"Nouveau cas Signalé", "media/"+str(request.data['media']), ['ga_tadjer@esi.dz'])
"Nouveau cas Signalé", "media/"+str(request.data['media']), [HEALTH_AGENT_EMAIL])

return Response(serializers.data, status=status.HTTP_201_CREATED)
return Response(serializers.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -58,6 +58,6 @@ def CasSignalerValider(self, request, pk=None):
serializer.save()
x = str(serializer1.data['media']).split("/")
send(serializer1.data['commentaire'],
"Nouveau cas Signalé", "media/" + x[2], ['ga_tadjer@esi.dz'])
"Nouveau cas Signalé validé", "media/" + x[2], [CCC_AGENT_EMAIL])
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ dj-database-url
Scrapy
feedparser
requests
APScheduler
APScheduler
tweepy

31 changes: 20 additions & 11 deletions robot/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.0.4 on 2020-06-22 13:56
# Generated by Django 3.0.4 on 2020-06-25 21:45

from django.db import migrations, models

Expand All @@ -12,35 +12,44 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='GoogleSearchResult',
name='Tweets',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('proprio', models.CharField(max_length=50)),
('content', models.CharField(max_length=500)),
('date', models.DateTimeField()),
('valide', models.BooleanField(default=False)),
('supprime', models.BooleanField(default=False)),
('titre', models.CharField(max_length=20)),
('description', models.TextField()),
('url', models.URLField()),
('date', models.DateTimeField()),
],
),
migrations.CreateModel(
name='Tweets',
name='VideoYoutube',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('valide', models.BooleanField(default=False)),
('supprime', models.BooleanField(default=False)),
('titre', models.CharField(max_length=200)),
('description', models.TextField()),
('url', models.URLField()),
],
),
migrations.CreateModel(
name='VideoYoutube',
name='GoogleSearchResult',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('valide', models.BooleanField(default=False)),
('supprime', models.BooleanField(default=False)),
('titre', models.CharField(max_length=20)),
('titre', models.CharField(max_length=200)),
('description', models.TextField()),
('url', models.URLField()),
('date', models.CharField(max_length=50)),
],
options={
'unique_together': {('url',)},
},
),
]
17 changes: 17 additions & 0 deletions robot/migrations/0002_remove_tweets_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0.4 on 2020-06-25 21:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('robot', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='tweets',
name='url',
),
]
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Generated by Django 3.0.4 on 2020-06-22 14:32
# Generated by Django 3.0.4 on 2020-06-25 21:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('robot', '0001_initial'),
('robot', '0002_remove_tweets_url'),
]

operations = [
migrations.AlterField(
model_name='googlesearchresult',
model_name='tweets',
name='date',
field=models.CharField(max_length=50),
),
Expand Down
11 changes: 9 additions & 2 deletions robot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
class VideoYoutube(models.Model):
valide = models.BooleanField(default=False)
supprime = models.BooleanField(default=False)
<<<<<<< HEAD
titre = models.CharField(max_length=1000)
=======
titre = models.CharField(max_length=200)
>>>>>>> 34aa3cbd447a64e7f0f3e9a36467953e1d884df5
description = models.TextField()
url = models.URLField(primary_key=True)


class Tweets(models.Model):
proprio=models.CharField(max_length=50)
content= models.CharField(max_length=500)
date= models.CharField(max_length=50)
valide = models.BooleanField(default=False)
supprime = models.BooleanField(default=False)
url = models.URLField()



class GoogleSearchResult(models.Model):
valide = models.BooleanField(default=False)
supprime = models.BooleanField(default=False)
titre = models.CharField(max_length=20)
titre = models.CharField(max_length=200)
description = models.TextField()
url = models.URLField()
date = models.CharField(max_length=50)
Expand Down
22 changes: 22 additions & 0 deletions robot/twitterScrapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import tweepy
import sys
from .models import Tweets
from config import ACCESS_TOKEN, ACCESS_TOKEN_SECRET,CONSUMER_KEY,CONSUMER_SECRET

def getTweets(counts):

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

api = tweepy.API(auth)
try:
api.verify_credentials()
print('Authentication Successful')
except:
print('Error while authenticating API')
sys.exit(1)

covid_tweets = tweepy.Cursor(api.search, q='فيروس كورونا').items(counts)
for tweet in covid_tweets:
tweetObj= Tweets.objects.create(content=tweet.text, date=tweet.created_at, proprio=tweet.user.name)
tweetObj.save()
5 changes: 3 additions & 2 deletions robot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


from rest_framework import viewsets, permissions

from .twitterScrapping import getTweets
from .googleSearchScrapping import ParseFeed
from .serializers import *
from .models import *
Expand Down Expand Up @@ -119,8 +119,9 @@ class TweetsViewSet(viewsets.ModelViewSet):
serializer_class = TweetSerializer

@action(methods=['post', 'get'], detail=False)
def show_list(self, request):
def getData(self, request):
if(request.method == "GET"):
getTweets(50)
data = Tweets.objects.all()
serializers = TweetSerializer(data, many=True)
return Response(serializers.data)
Expand Down
Binary file modified sendMail/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified sendMail/__pycache__/views.cpython-38.pyc
Binary file not shown.

0 comments on commit 4a40cac

Please sign in to comment.