-
Notifications
You must be signed in to change notification settings - Fork 4
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 #19 from certego/develop
0.2.0
- Loading branch information
Showing
32 changed files
with
224 additions
and
40 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
File renamed without changes.
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CertegoUserConfig(AppConfig): | ||
name = "certego_saas.apps.user" | ||
label = "certego_saas_user" |
File renamed without changes.
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,63 @@ | ||
from django.db import OperationalError, migrations | ||
from django.db.migrations.operations.base import Operation | ||
|
||
|
||
class AlterCertegoSaasUser(Operation): | ||
reversible = True | ||
|
||
def state_forwards(self, app_label, state): | ||
pass | ||
|
||
def database_forwards(self, app_label, schema_editor, from_state, to_state): | ||
vendor = schema_editor.connection.vendor | ||
|
||
for old, new in zip( | ||
[ | ||
"certego_saas_user", | ||
"certego_saas_user_groups", | ||
"certego_saas_user_user_permissions", | ||
], | ||
[ | ||
"certego_saas_user_user", | ||
"certego_saas_user_user_groups", | ||
"certego_saas_user_user_user_permissions", | ||
], | ||
): | ||
try: | ||
schema_editor.execute( | ||
f"ALTER TABLE {'IF EXISTS' if vendor == 'postgresql' else ''} {old} RENAME TO {new};" | ||
) | ||
except OperationalError: | ||
pass | ||
|
||
def database_backwards(self, app_label, schema_editor, from_state, to_state): | ||
vendor = schema_editor.connection.vendor | ||
for old, new in zip( | ||
[ | ||
"certego_saas_user", | ||
"certego_saas_user_groups", | ||
"certego_saas_user_user_permissions", | ||
], | ||
[ | ||
"certego_saas_user_user", | ||
"certego_saas_user_user_groups", | ||
"certego_saas_user_user_user_permissions", | ||
], | ||
): | ||
try: | ||
schema_editor.execute( | ||
f"ALTER TABLE {'IF EXISTS' if vendor == 'postgresql' else ''} {new} RENAME TO {old};" | ||
) | ||
except OperationalError: | ||
pass | ||
|
||
def describe(self): | ||
return "Alter Certego_saas_user table if necessary" | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("certego_saas_user", "0001_initial"), | ||
] | ||
|
||
operations = [AlterCertegoSaasUser()] |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,36 @@ | ||
"""This command allow us to list all tasks from the queue (selected automatically)""" | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "List available messages in the queue used by this instance" | ||
|
||
def handle(self, *args, **options): | ||
try: | ||
import boto3 | ||
except ImportError: | ||
self.stdout.write( | ||
self.style.ERROR( | ||
"boto3 is not installed. Please install boto3 to use this command." | ||
) | ||
) | ||
return | ||
|
||
client = boto3.client("sqs", settings.AWS_REGION) | ||
queues = client.list_queues().get("QueueUrls", []) | ||
for queue in queues: | ||
if input(f"Are you sure you want to select {queue}? (y/n) ") == "y": | ||
queue_data = client.get_queue_attributes( | ||
QueueUrl=queue, | ||
AttributeNames=["ApproximateNumberOfMessages"], | ||
) | ||
message_in_the_queue = queue_data["Attributes"][ | ||
"ApproximateNumberOfMessages" | ||
] | ||
self.stdout.write( | ||
f"the number of the messages in the queue {queue} is {message_in_the_queue}" | ||
) | ||
else: | ||
self.stdout.write(self.style.ERROR(f"Skipping {queue}")) |
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,31 @@ | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Purge selected queues" | ||
|
||
def handle(self, *args, **options): | ||
# we should import it here so that projects that don't use boto3 can still use this library | ||
# since we are not adding this in the requirements.txt file | ||
try: | ||
import boto3 | ||
except ImportError: | ||
self.stdout.write( | ||
self.style.ERROR( | ||
"boto3 is not installed. Please install boto3 to use this command." | ||
) | ||
) | ||
return | ||
client = boto3.client("sqs", settings.AWS_REGION) | ||
queues = client.list_queues().get("QueueUrls", []) | ||
for queue in queues: | ||
if input(f"Are you sure you want to purge {queue}? (y/n) ") == "y": | ||
client.purge_queue(QueueUrl=queue) | ||
self.stdout.write( | ||
self.style.SUCCESS( | ||
f"Successfully purged queue {queue} with url {queue}" | ||
) | ||
) | ||
else: | ||
self.stdout.write(self.style.ERROR(f"Skipping {queue}")) |
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,11 @@ | ||
# Patterns | ||
from django.apps import apps | ||
from django.urls import include, path | ||
|
||
# Patterns | ||
urlpatterns = [ | ||
urlpatterns = [] | ||
|
||
if apps.is_installed("certego_saas.apps.user"): | ||
# certego_saas: user sub-app | ||
path("", include("certego_saas.user.urls")), | ||
] | ||
urlpatterns.append( | ||
path("", include("certego_saas.apps.user.urls")), | ||
) |
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 +1 @@ | ||
VERSION = "0.1.3" | ||
VERSION = "0.2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ Apps (``certego_saas.apps``) | |
:maxdepth: 2 | ||
|
||
auth | ||
user | ||
feedback | ||
notifications | ||
organization | ||
|
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
Oops, something went wrong.