def reset(self):
        Post.objects(
            slug__in=[item['slug'] for item in self.json_data.get('posts')]
        ).delete()

        SubContentPurpose.objects(
            identifier__in=[
                item['identifier'] for item in self.json_data.get('purposes')
            ]
        ).delete()

        for channel in Channel.objects(
                slug__in=[
                    item['slug'] for item in self.json_data.get('channels')]):
            for subchannel in channel.get_children():
                for subsubchannel in subchannel.get_children():
                    subsubchannel.delete()
                subchannel.delete()
            channel.delete()

        User.objects(
            email__in=[item['email'] for item in self.json_data.get('users')]
        ).delete()

        if self.kwargs.get('first_install'):
            Quokka.objects.delete()
Ejemplo n.º 2
0
    def create_users(self):
        self.users_data = [
            {
                "name": "admin",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('admin')]
            },
            {
                "name": "moderator",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('moderator')]
            },
            {
                "name": "editor",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('editor')]
            },
            {
                "name": "user",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('user'), self.role('viewer')]
            },
        ]

        for data in self.users_data:
            name = data.get('name')
            pwd = data.get("password")
            if not name in self.users:
                user = User.createuser(**data)
                self.users[name] = user
                print("User: mail:{o.email} pwd:{pwd}".format(o=user, pwd=pwd))
 def test_get_authors_without_created_by_should_raise_exception(self):
     user = User.createuser(
         u'Lechuck',
         '*****@*****.**',
         'guybrushsucks',
     )
     self.channel.authors = [user]
     with self.assertRaises(db.ValidationError):
         self.channel.get_authors()
Ejemplo n.º 4
0
 def test_get_authors_without_created_by_should_raise_exception(self):
     user = User.createuser(
         u'Lechuck',
         '*****@*****.**',
         'guybrushsucks',
     )
     self.channel.authors = [user]
     with self.assertRaises(db.ValidationError):
         self.channel.get_authors()
Ejemplo n.º 5
0
 def create_user(self, data):
     name = data.get('name')
     if name not in self.users:
         pwd = data.get("password")
         data['roles'] = [self.role(role) for role in data.get('roles')]
         user = User.createuser(**data)
         self.users[name] = user
         logger.info("Created: User: mail:%s pwd:%s", user.email, pwd)
         return user
     else:
         logger.info("Exist: User: mail: %s", data.get('email'))
 def create_user(self, data):
     name = data.get('name')
     if name not in self.users:
         pwd = data.get("password")
         data['roles'] = [self.role(role) for role in data.get('roles')]
         user = User.createuser(**data)
         self.users[name] = user
         logger.info("Created: User: mail:%s pwd:%s", user.email, pwd)
         return user
     else:
         logger.info("Exist: User: mail: %s", data.get('email'))
Ejemplo n.º 7
0
    def create_users(self):

        self.users_data = self.json_data.get('users')

        for data in self.users_data:
            name = data.get('name')
            if name not in self.users:
                pwd = data.get("password")
                data['roles'] = [self.role(role) for role in data.get('roles')]
                user = User.createuser(**data)
                self.users[name] = user
                logger.info("Created: User: mail:{o.email} pwd:{pwd}".format(
                    o=user, pwd=pwd))
            else:
                logger.info("Exist: User: mail:{o[email]}".format(o=data))
Ejemplo n.º 8
0
    def create_users(self):

        self.users_data = self.json_data.get('users')

        for data in self.users_data:
            name = data.get('name')
            if name not in self.users:
                pwd = data.get("password")
                data['roles'] = [self.role(role) for role in data.get('roles')]
                user = User.createuser(**data)
                self.users[name] = user
                logger.info(
                    "Created: User: mail:{o.email} pwd:{pwd}".format(o=user,
                                                                     pwd=pwd)
                )
            else:
                logger.info("Exist: User: mail:{o[email]}".format(o=data))
Ejemplo n.º 9
0
    def create_users(self):
        self.users_data = [
            {
                "name": "admin",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('admin')]
            },
            {
                "name": "moderator",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('moderator')]
            },
            {
                "name": "editor",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('editor')]
            },
            {
                "name": "user",
                "email": "*****@*****.**",
                "password": "******",
                "roles": [self.role('user'), self.role('viewer')]
            },
        ]

        for data in self.users_data:
            name = data.get('name')
            pwd = data.get("password")
            if name not in self.users:
                user = User.createuser(**data)
                self.users[name] = user
                logger.info(
                    "Created: User: mail:{o.email} pwd:{pwd}".format(o=user,
                                                                     pwd=pwd)
                )
            else:
                logger.info("Exist: User: mail:{o[email]}".format(o=data))
Ejemplo n.º 10
0
#!/usr/bin/python
"""
THIS SCRIPT CLEANS ALL DATA IN YOUR QUOKKA DB
RUN ONLY IN OPENSHIFT DEMO DEPLOY
OR AT YOUR OWN RISK!!!!
"""
from quokka import create_app
from quokka.core.models.content import Content
from quokka.core.models.config import Config
from quokka.core.models.channel import Channel
from quokka.modules.accounts.models import User

app = create_app()

Content.drop_collection()
User.drop_collection()
Config.drop_collection()
Channel.drop_collection()