# Path: src/librement/profile/links/forms.py
# class LinkForm(forms.ModelForm):
#     class Meta:
#         model = Link
#         fields = (
#             'url',
#             'title',
#         )


from django.contrib import messages
from django.shortcuts import render, get_object_or_404, redirect
from django.views.decorators.http import require_POST
from django.contrib.auth.decorators import login_required
from .forms import LinkForm
# Copyright 2012 The Librement Developers
#
# See the AUTHORS file at the top-level directory of this distribution
# and at http://librement.net/copyright/
#
# This file is part of Librement. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this distribution
# and at http://librement.net/license/. No part of Librement, including
# this file, may be copied, modified, propagated, or distributed except
# according to the terms contained in the LICENSE file.



@login_required
def view(request):
    return render(request, 'profile/links/view.html')

@login_required
def add_edit(request, link_id=None):
    if link_id:
        link = get_object_or_404(request.user.links, pk=link_id)
    else:
        link = None

    if request.method == 'POST':

# Path: src/librement/profile/links/forms.py
# class LinkForm(forms.ModelForm):
#     class Meta:
#         model = Link
#         fields = (
#             'url',
#             'title',
#         )


# Path: src/librement/profile/links/views.py
from django.contrib import messages
from django.shortcuts import render, get_object_or_404, redirect
from django.views.decorators.http import require_POST
from django.contrib.auth.decorators import login_required
from .forms import LinkForm

# Copyright 2012 The Librement Developers
#
# See the AUTHORS file at the top-level directory of this distribution
# and at http://librement.net/copyright/
#
# This file is part of Librement. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this distribution
# and at http://librement.net/license/. No part of Librement, including
# this file, may be copied, modified, propagated, or distributed except
# according to the terms contained in the LICENSE file.



@login_required
def view(request):
    return render(request, 'profile/links/view.html')

@login_required
def add_edit(request, link_id=None):
    if link_id:
        link = get_object_or_404(request.user.links, pk=link_id)
    else:
        link = None

    if request.method == 'POST':

        form = LinkForm(request.POST, instance=link)