Esempio n. 1
0
def register_user(username, password, email, dob):
    # TODO: Check if username or email already exists
    serialize_user(User(username=username,
                        password=password,
                        email=email,
                        dob=dob),
                   username)
Esempio n. 2
0
def remove_ebook_with_infraction(isbn, infraction_reason, timestamp=None):
    book = load_serialized_ebook(isbn)
    user = load_serialized_user(book.uploader.username)
    user.credits -= (book.reward_amount + 100)
    user.infractions[isbn + str(datetime.datetime.now())] = infraction_reason
    check_infractions(user)
    serialize_user(user, user.username)
    delete_ebook_from_users(isbn)
    remove_ebook(isbn)
    if timestamp is not None:
        remove_report(isbn, timestamp)
Esempio n. 3
0
def remove_ebook_with_infraction(isbn, infraction_reason, timestamp=None):
    book = load_serialized_ebook(isbn)
    user = load_serialized_user(book.uploader.username)
    user.credits -= (book.reward_amount + 100)
    user.infractions[isbn + str(datetime.datetime.now())] = infraction_reason
    check_infractions(user)
    serialize_user(user, user.username)
    delete_ebook_from_users(isbn)
    remove_ebook(isbn)
    if timestamp is not None:
        remove_report(isbn, timestamp)
Esempio n. 4
0
def apply_second_pass_attribute(username, isbn, original_price, su_price):
    """
    Sets the second pass attribute which triggers dialogs to confirm if the uploader
    wants to accept the lower price
    :param username: str
    :param isbn: str
    :param original_price: int
    :param su_price: int
    :return:
    """
    user = load_serialized_user(username)
    user.second_pass[isbn] = (original_price,
                              su_price,)
    serialize_user(user, username)
Esempio n. 5
0
def apply_second_pass_attribute(username, isbn, original_price, su_price):
    """
    Sets the second pass attribute which triggers dialogs to confirm if the uploader
    wants to accept the lower price
    :param username: str
    :param isbn: str
    :param original_price: int
    :param su_price: int
    :return:
    """
    user = load_serialized_user(username)
    user.second_pass[isbn] = (
        original_price,
        su_price,
    )
    serialize_user(user, username)
Esempio n. 6
0
import os
from database.database_objects import serialize_user, User

USER_LIST = ["Chris",
             "MD",
             "Porrith",
             "Fioger"]

EMAIL_LIST = ["*****@*****.**",
              "*****@*****.**",
              "*****@*****.**",
              "*****@*****.**"]

DOB_LIST = ["1/26/1995",
            "1/1/1993",
            "7/17/1995",
            "12/26/1995"]

for i in range(4):
    serialize_user(User(username=USER_LIST[i],
                        password="******",
                        email=EMAIL_LIST[i],
                        dob=DOB_LIST[i],
                        group_policy='SU',
                        ), USER_LIST[i])

Esempio n. 7
0
# This script creates a blacklisted user.
from database.database_objects import serialize_user, User
from models.main_model import check_infractions


def populate_infractions(user_instance):
    infractions = user_instance.infractions
    infraction_reasons = [
        'Illegal Copy',
        'Inappropriate Content'
    ]
    for index in range(0, 2):
        infractions[infraction_reasons[index]] = "Reason here"


def create_user():
    user = User('Doe', 'pw', '*****@*****.**', '1/1/1980')
    populate_infractions(user)
    check_infractions(user)
    return user


serialize_user(create_user(), create_user().username)
Esempio n. 8
0
# This script creates a blacklisted user.
from database.database_objects import serialize_user, User
from models.main_model import check_infractions


def populate_infractions(user_instance):
    infractions = user_instance.infractions
    infraction_reasons = ['Illegal Copy', 'Inappropriate Content']
    for index in range(0, 2):
        infractions[infraction_reasons[index]] = "Reason here"


def create_user():
    user = User('Doe', 'pw', '*****@*****.**', '1/1/1980')
    populate_infractions(user)
    check_infractions(user)
    return user


serialize_user(create_user(), create_user().username)
Esempio n. 9
0
def blacklist_book_uploader(isbn):
    book = load_serialized_ebook(isbn)
    user = load_serialized_user(book.uploader.username)
    user.is_blacklisted = True
    serialize_user(user, user.username)
Esempio n. 10
0
def remove_user_credits(username, credit):
    user = load_serialized_user(username)
    user.credits -= credit
    serialize_user(user, username)
Esempio n. 11
0
def populate_rented_books(user):
    """
    Get a random amount of EBook pickle files and loads them into
    rented_book field of a User object
    :param user:
    :return:
    """
    ebook_pickles = get_ebook_pickles()
    for index in range(0, random.randrange(3, 6)):
        user.rented_books[ebook_pickles[index].isbn] = ebook_pickles[index]


def create_user():
    user = User(username='******',
            password='******',
            email='*****@*****.**',
            dob='1/1/1990')

    populate_rented_books(user)
    return user


user = create_user()

for book in get_top_related_books(user):
    print book.title + " :" + book.genre

serialize_user(user, user.username)

# print "Len of similar books: " + str(len(get_top_related_books(create_user())))
Esempio n. 12
0
def register_user(username, password, email, dob):
    # TODO: Check if username or email already exists
    serialize_user(
        User(username=username, password=password, email=email, dob=dob),
        username)
Esempio n. 13
0
def blacklist_book_uploader(isbn):
    book = load_serialized_ebook(isbn)
    user = load_serialized_user(book.uploader.username)
    user.is_blacklisted = True
    serialize_user(user, user.username)
Esempio n. 14
0
def remove_user_credits(username, credit):
    user = load_serialized_user(username)
    user.credits -= credit
    serialize_user(user, username)