-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from CodeForAfrica/ft-create-list#179920259
Ft create list#179920259
- Loading branch information
Showing
18 changed files
with
347 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .twitter_client import TwitterClient # noqa |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TwitterclientConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "twoopstracker.twitterclient" |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
|
||
import tweepy | ||
from django.conf import settings | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class TwitterClient: | ||
def __init__(self): | ||
self.auth = tweepy.OAuthHandler( | ||
settings.TWOOPSTRACKER_CONSUMER_KEY, settings.TWOOPSTRACKER_CONSUMER_SECRET | ||
) | ||
self.auth.set_access_token( | ||
settings.TWOOPSTRACKER_ACCESS_TOKEN, | ||
settings.TWOOPSTRACKER_ACCESS_TOKEN_SECRET, | ||
) | ||
self.api = tweepy.API(self.auth) | ||
|
||
try: | ||
username = self.api.verify_credentials().screen_name | ||
logger.info("@" + username + " is authenticated") | ||
except tweepy.errors.TweepyException as e: | ||
logger.error(e) | ||
|
||
def get_user(self, user, key="screen_name"): | ||
try: | ||
if key == "screen_name": | ||
return self.api.get_user(screen_name=user) | ||
elif key == "id": | ||
return self.api.get_user(user_id=user) | ||
except tweepy.errors.TweepyException as e: | ||
logger.error(e) | ||
return None |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
from django.contrib import admin | ||
|
||
from twoopstracker.twoops.models import Tweet, TwitterAccount | ||
from twoopstracker.twoops.models import ( | ||
Tweet, | ||
TwitterAccount, | ||
TwitterAccountsList, | ||
UserProfile, | ||
) | ||
|
||
admin.site.register( | ||
[ | ||
Tweet, | ||
TwitterAccount, | ||
UserProfile, | ||
TwitterAccountsList, | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 3.2.8 on 2021-11-01 10:28 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("authentication", "0001_user_model"), | ||
("twoops", "0002_twitter_account"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="UserProfile", | ||
fields=[ | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"user", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
primary_key=True, | ||
serialize=False, | ||
to="authentication.user", | ||
), | ||
), | ||
], | ||
options={ | ||
"get_latest_by": "updated_at", | ||
"abstract": False, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Generated by Django 3.2.8 on 2021-11-01 10:34 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("twoops", "0003_userprofile"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="TwitterAccountsList", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"name", | ||
models.CharField(help_text="Name of Twitter List", max_length=255), | ||
), | ||
( | ||
"slug", | ||
models.CharField(help_text="Twitter List Slug", max_length=255), | ||
), | ||
( | ||
"accounts", | ||
models.ManyToManyField( | ||
related_name="lists", to="twoops.TwitterAccount" | ||
), | ||
), | ||
( | ||
"owner", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="twoops.userprofile", | ||
), | ||
), | ||
("is_private", models.BooleanField(default=False)), | ||
], | ||
options={ | ||
"get_latest_by": "updated_at", | ||
"abstract": False, | ||
}, | ||
), | ||
] |
33 changes: 33 additions & 0 deletions
33
twoopstracker/twoops/migrations/0005_add_default_values_for_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 3.2.8 on 2021-11-03 16:14 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("twoops", "0004_list"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="twitteraccount", | ||
name="favourites_count", | ||
field=models.IntegerField(default=0), | ||
), | ||
migrations.AlterField( | ||
model_name="twitteraccount", | ||
name="followers_count", | ||
field=models.IntegerField(default=0), | ||
), | ||
migrations.AlterField( | ||
model_name="twitteraccount", | ||
name="friends_count", | ||
field=models.IntegerField(default=0), | ||
), | ||
migrations.AlterField( | ||
model_name="twitteraccount", | ||
name="statuses_count", | ||
field=models.IntegerField(default=0), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from django.urls import path | ||
|
||
from .views import TweetsView | ||
from .views import AccountsList, SingleTwitterList, TweetsView | ||
|
||
urlpatterns = [ | ||
path("tweets/", TweetsView.as_view(), name="tweets"), | ||
path("lists/", AccountsList.as_view(), name="accounts_list"), | ||
path("lists/<pk>", SingleTwitterList.as_view(), name="single_account_list"), | ||
] |
Oops, something went wrong.