Commit 7d392d04 authored by EL HASSANE GARGEM's avatar EL HASSANE GARGEM
Browse files

Merge branch 'develop' into onboarding

parents 0aaf854a 57724b73
......@@ -26,7 +26,7 @@ class BootstrapFormMixin():
class_ += ' form-control'
if issubclass(field.widget.__class__, forms.Select):
class_ += ' custom-select'
if field.widget.input_type == 'select':
if hasattr(field.widget,'input_type') and field.widget.input_type == 'select':
field.widget.need_label = True
field.widget.attrs['class'] = class_
......
......@@ -146,8 +146,7 @@ def segtrain(task, model_pk, document_pk, part_pks, user_pk=None):
load = model.file.path
upload_to = model.file.field.upload_to(model, model.name + '.mlmodel')
except ValueError: # model is empty
# load = settings.KRAKEN_DEFAULT_SEGMENTATION_MODEL
load = None
load = settings.KRAKEN_DEFAULT_SEGMENTATION_MODEL
upload_to = model.file.field.upload_to(model, model.name + '.mlmodel')
model.file = upload_to
......@@ -185,6 +184,7 @@ def segtrain(task, model_pk, document_pk, part_pks, user_pk=None):
evaluation_data=evaluation_data,
threads=LOAD_THREADS,
augment=True,
resize='both',
load_hyper_parameters=True)
if not os.path.exists(os.path.split(modelpath)[0]):
......
......@@ -6,7 +6,7 @@ from django.contrib import messages
from django.utils.translation import ngettext
from users.models import User, ResearchField, Invitation
from users.models import User, ResearchField, Invitation, ContactUs
class MyUserChangeForm(UserChangeForm):
......@@ -62,3 +62,5 @@ class InvitationAdmin(admin.ModelAdmin):
admin.site.register(User, MyUserAdmin)
admin.site.register(ResearchField)
admin.site.register(Invitation, InvitationAdmin)
admin.site.register(ContactUs)
from django import forms
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from django.utils.translation import gettext as _
from captcha.fields import CaptchaField
from bootstrap.forms import BootstrapFormMixin
from users.models import Invitation, User
from users.models import Invitation, User, ContactUs
class InvitationForm(BootstrapFormMixin, forms.ModelForm):
......@@ -52,3 +53,14 @@ class ProfileForm(BootstrapFormMixin, forms.ModelForm):
class Meta:
model = User
fields = ('email', 'first_name', 'last_name')
class ContactUsForm(BootstrapFormMixin, forms.ModelForm):
message = forms.CharField(label="Message : Please precise your institution or research center if applicable", widget=forms.Textarea(attrs={'placeholder':'Message : Please precise your institution or research center if applicable' }))
captcha = CaptchaField()
class Meta:
model = ContactUs
fields = ('name','email','message','captcha')
# Generated by Django 2.1.4 on 2020-08-20 16:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0008_auto_20200520_1007'),
]
operations = [
migrations.CreateModel(
name='ContactUs',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('subject', models.CharField(max_length=255)),
('email', models.EmailField(max_length=255, verbose_name='email address')),
('message', models.TextField()),
],
),
]
# Generated by Django 2.1.4 on 2020-08-28 08:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0009_contactus'),
]
operations = [
migrations.AlterModelOptions(
name='contactus',
options={'verbose_name': 'message', 'verbose_name_plural': 'messages'},
),
migrations.RemoveField(
model_name='contactus',
name='subject',
),
]
......@@ -133,3 +133,41 @@ class Invitation(models.Model):
_('{username} accepted your invitation!').format(
username=self.recipient.username),
level='success')
class ContactUs(models.Model):
"""
Represents Contact Us form
"""
name = models.CharField(max_length=255)
email = models.EmailField(
verbose_name=_('email address'),
max_length=255,
)
message = models.TextField()
class Meta:
verbose_name ="message"
verbose_name_plural = "messages"
def __str__(self):
return "from {}({})".format(self.name,self.email)
def save(self, *args, **kwargs):
context = {
"sender_name": self.name,
"sender_email": self.email,
"message": self.message,
}
send_email(
'users/email/contactus_subject.txt',
'users/email/contactus_message.txt',
'users/email/contactus_html.html',
settings.ADMINS,
context=context,
result_interface=None
)
super().save(*args, **kwargs)
from django.urls import path, include
from users.views import SendInvitation, AcceptInvitation, Profile
from users.views import SendInvitation, AcceptInvitation, Profile, ContactUsView
from django.contrib.auth.decorators import permission_required
urlpatterns = [
path('', include('django.contrib.auth.urls')),
path('profile/', Profile.as_view(), name='user_profile'),
path('contact/', ContactUsView.as_view(), name='contactus'),
path('invite/',
permission_required('users.can_invite', raise_exception=True)(SendInvitation.as_view()),
name='send-invitation'),
......
from os import listdir, stat
from os.path import isfile, join, relpath
from django.shortcuts import reverse
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
......@@ -12,8 +12,8 @@ from django.views.generic.edit import CreateView, UpdateView
from rest_framework.authtoken.models import Token
from users.models import User, Invitation
from users.forms import InvitationForm, InvitationAcceptForm, ProfileForm
from users.models import User, Invitation, ContactUs
from users.forms import InvitationForm, InvitationAcceptForm, ProfileForm, ContactUsForm
class SendInvitation(LoginRequiredMixin, SuccessMessageMixin, CreateView):
......@@ -103,3 +103,14 @@ class Profile(SuccessMessageMixin, UpdateView):
context['is_paginated'] = paginator.count != 0
context['page_obj'] = paginator.get_page(page_number)
return context
class ContactUsView(SuccessMessageMixin, CreateView):
model = ContactUs
form_class = ContactUsForm
success_message = _('Your message successfully sent.')
template_name = 'users/contactus.html'
success_url = '/contact/'
......@@ -62,6 +62,7 @@ INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken',
'compressor',
'captcha',
'bootstrap',
'versioning',
......
......@@ -616,3 +616,7 @@ i.panel-icon {
.cmp-del {
color: red;
}
#contact-form{
width: 100%;
}
\ No newline at end of file
......@@ -1182,8 +1182,10 @@ class Segmenter {
for (let i=0; i<this.regions.length; i++) {
if (this.selecting.selected && this.regions[i] != this.selecting) {
let hit = this.regions[i].polygonPath.hitTest(event.point);
if (hit) this.selecting = this.regions[i];
break;
if (hit) {
this.selecting = this.regions[i];
break;
}
}
}
}
......
......@@ -48,7 +48,7 @@
<a class="nav-link" href="#">{% trans 'About' %}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">{% trans 'Contact' %}</a>
<a class="nav-link" href="{% url 'contactus' %}">{% trans 'Contact' %}</a>
</li>
{% comment %}
......
{% extends "base.html" %}
{% load i18n bootstrap static %}
{% block body %}
<div class="container">
<div class="row">
<form id="contact-form" method="post">
{% csrf_token %}
<fieldset>
<div class="form-group">
{% for error in form.non_field_errors %}
<p class="error">{{ error }}</p>
{% endfor %}
</div>
{% render_field form.name %}
{% render_field form.email %}
{% render_field form.message %}
{{ form.captcha }}
<input type="submit" value="{% trans 'Send' %}" class="btn btn-success btn-block my-3" {% if object %}autofocus{% endif %}>
</fieldset>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
<p>Hello escriptorium Admin</p>
<p>{{sender_name}} wants to send you a message, you will find it bellow.</br>
{{message}}
<p>You can contact him on this email : {{ sender_email }}</p>
<p>Sincerely, the eScriptorium team.</p>
Dear escriptorium Admin,
{{sender_name}} wants to send you a message, you will find it bellow.
{{message}}
You can contact him on this email : {{ sender_email }}
Sincerely, the eScriptorium team.
message from : {{ sender_name }}({{sender_email }})
\ No newline at end of file
......@@ -26,7 +26,8 @@ urlpatterns = [
path('api/', include('api.urls', namespace='api')),
# sandbox
path('baseline-editor/', TemplateView.as_view(template_name='baseline_editor.html'))
path('baseline-editor/', TemplateView.as_view(template_name='baseline_editor.html')),
path(r'captcha/', include('captcha.urls')),
]
if settings.DEBUG:
......
......@@ -22,3 +22,4 @@ requests==2.21.0
numpy>=1.17
django-compressor==2.4
albumentations
django-simple-captcha==0.5.12
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment