Example #1
0
def create_user(request):
    if request.method == 'GET':
        return secure_render_response(request, 'cadastro.html', locals())
    elif request.method == 'POST':
        user_form = UsuarioForm(request.POST)
        if user_form.is_valid():
            user_new = user_form.save(commit=False)
            user_new.type = 1
            portfolio = Portfolio()
            portfolio.save()
            user_new.portfolio = portfolio
            djuser = User.objects.create_user(username=request.POST['mail'],email=request.POST['mail'], password=request.POST['pwd'])
            user_new.djuser = djuser 
            user_new.save()
        return render_to_response('user_view.html',  locals())
Example #2
0
def get_portfolio_carousels():
    portfolios = cache.get("portfolio_carousels")
    if not portfolios:
        portfolios = Portfolio.get_latest(max_size=3)
        # if len(testimonials) > 3:
        #     testimonials = testimonials[0:3]
        # cache.set("portfolio_carousels", testimonials)

    return portfolios
Example #3
0
def home(request):
    if request.user:
        most_rated_products = Rate.get_most_rated_products(max_size=4)
        most_hot_products = Product.get_hot(max_size=4)
        recent_portfolios = Portfolio.get_latest(max_size=4)
        recent_articles = Article.get_recommended()
        activities = Activity.get_banner_activity()
        types = ProductType.objects.all()

        return render(request, "welcome.html", {"most_rated_products": most_rated_products,
                        "recent_articles": recent_articles, "types": types, 'activities': activities,  "recent_portfolios": recent_portfolios, "most_hot_products": most_hot_products})
    else:
        return render(request, "home.html")
Example #4
0
data = set_values(get_data(Simfonia.URL), Simfonia.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Simfonia.INVESTED
max_gain = max(data) - Simfonia.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Simfonia.URL)

# To correctly plot any range of values we use a pixel delimiter defined in Graph constants.
# In short, we set the maximum height for the highest value and 50 pixels for lowest value.
# Each plot has a gradient so we define a start and end color.
plot = Plot(Graph.PLOT_MAX_PIXELS, Simfonia.START_COLOR, Simfonia.END_COLOR)

# Instantiate portfolio.
simfonia = Portfolio(name, data, gain, max_gain, Simfonia.INVESTED,
                     latest_date, plot)

# ----- Diverso -----

# Name will be used to print the plot name.
name = Diverso.NAME

# Data is a list of integers calculated by multiplying VUAN and UNITS.
data = set_values(get_data(Diverso.URL), Diverso.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Diverso.INVESTED
max_gain = max(data) - Diverso.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Diverso.URL)
data = set_values(get_data(Simfonia.URL), Simfonia.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Simfonia.INVESTED
max_gain = max(data) - Simfonia.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Simfonia.URL)

# To correctly plot any range of values we use a pixel delimiter defined in Graph constants.
# In short, we set the maximum height for the highest value and 50 pixels for lowest value.
# Each plot has a gradient so we define a start and end color.
plot = Plot(Graph.PLOT_MAX_PIXELS, Simfonia.START_COLOR, Simfonia.END_COLOR)

# Instantiate portfolio.
simfonia = Portfolio(name, data, gain, max_gain, latest_date, plot)

# ----- Diverso -----

# Name will be used to print the plot name.
name = Diverso.NAME

# Data is a list of integers calculated by multiplying VUAN and UNITS.
data = set_values(get_data(Diverso.URL), Diverso.UNITS)

# Gain refers to actual gain over the invested amount.
gain = data[0] - Diverso.INVESTED
max_gain = max(data) - Diverso.INVESTED

# We plot the latest date.
latest_date = get_latest_date(Diverso.URL)