Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Hjelp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Hjelp
Commits
46bf88b3
Commit
46bf88b3
authored
5 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
add dynamic icons
parent
c01ba426
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
Resolve "Rewrite REBUS with django-select2"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/hjelp/templates/hjelp/rebus.html
+47
-6
47 additions, 6 deletions
aleksis/apps/hjelp/templates/hjelp/rebus.html
aleksis/apps/hjelp/urls.py
+3
-2
3 additions, 2 deletions
aleksis/apps/hjelp/urls.py
aleksis/apps/hjelp/views.py
+94
-56
94 additions, 56 deletions
aleksis/apps/hjelp/views.py
with
144 additions
and
64 deletions
aleksis/apps/hjelp/templates/hjelp/rebus.html
+
47
−
6
View file @
46bf88b3
...
...
@@ -17,16 +17,35 @@
<div
class=
"row"
>
<div
id=
"{{ form.bug_category_1.auto_id }}"
class=
"input col s12 m4 support-input-mobile browser-default"
>
{{ form.bug_category_1.label_tag }}
{{ form.bug_category_1 }}
<div
class=
"row"
>
<div
id=
"bug_category_1_icon"
class=
"col s2"
>
<i
class=
"material-icons prefix small"
>
bug_report
</i>
</div>
<div
class=
"col s10"
>
{{ form.bug_category_1.label_tag }}
{{ form.bug_category_1 }}
</div>
</div>
</div>
<div
id=
"{{ form.bug_category_2.auto_id }}"
class=
"input col s12 m4 support-input-mobile browser-default"
style=
"display: none"
>
{{ form.bug_category_2.label_tag }}
{{ form.bug_category_2 }}
<div
class=
"row"
>
<div
id=
"bug_category_2_icon"
class=
"col s2"
>
</div>
<div
class=
"col s10"
>
{{ form.bug_category_2.label_tag }}
{{ form.bug_category_2 }}
</div>
</div>
</div>
<div
id=
"{{ form.bug_category_3.auto_id }}"
class=
"input col s12 m4 support-input-mobile browser-default"
style=
"display: none"
>
{{ form.bug_category_3.label_tag }}
{{ form.bug_category_3 }}
<div
class=
"row"
>
<div
id=
"bug_category_3_icon"
class=
"col s2"
>
</div>
<div
class=
"col s10"
>
{{ form.bug_category_3.label_tag }}
{{ form.bug_category_3 }}
</div>
</div>
</div>
</div>
...
...
@@ -66,9 +85,31 @@
}
});
$
(
"
#{{ form.bug_category_1.auto_id }}
"
).
on
(
'
input
'
,
function
()
{
var
category
=
$
(
'
#{{ form.bug_category_1.auto_id }} :selected
'
).
text
();
$
.
ajax
({
url
:
'
/app/hjelp/ajax/rebus_get_icon/
'
,
data
:
{
'
category
'
:
category
},
dataType
:
'
json
'
,
success
:
function
(
data
)
{
$
(
"
#bug_category_2_icon
"
).
html
(
"
<i class=
\"
material-icons prefix small
\"
>
"
+
data
.
icon
+
"
</i>
"
);
}
});
$
(
"
#{{ form.bug_category_2.auto_id }}
"
).
show
();
});
$
(
"
#{{ form.bug_category_2.auto_id }}
"
).
on
(
'
input
'
,
function
()
{
var
category
=
$
(
'
#{{ form.bug_category_2.auto_id }} :selected
'
).
text
();
$
.
ajax
({
url
:
'
/app/hjelp/ajax/rebus_get_icon/
'
,
data
:
{
'
category
'
:
category
},
dataType
:
'
json
'
,
success
:
function
(
data
)
{
$
(
"
#bug_category_3_icon
"
).
html
(
"
<i class=
\"
material-icons prefix
\"
>
"
+
data
.
icon
+
"
</i>
"
);
}
});
$
(
"
#{{ form.bug_category_3.auto_id }}
"
).
show
();
});
</script>
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/hjelp/urls.py
+
3
−
2
View file @
46bf88b3
...
...
@@ -5,6 +5,7 @@ from . import views
urlpatterns
=
[
path
(
"
rebus/
"
,
views
.
rebus
,
name
=
"
rebus
"
),
path
(
"
feedback/
"
,
views
.
feedback
,
name
=
"
feedback
"
),
path
(
'
faq/
'
,
views
.
faq
,
name
=
'
faq
'
),
path
(
'
faq/ask/
'
,
views
.
ask
,
name
=
'
ask-faq
'
)
path
(
"
faq/
"
,
views
.
faq
,
name
=
"
faq
"
),
path
(
"
faq/ask/
"
,
views
.
ask
,
name
=
"
ask-faq
"
),
path
(
"
ajax/rebus_get_icon/
"
,
views
.
rebus_get_icon
,
name
=
"
rebus-get-icon
"
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/hjelp/views.py
+
94
−
56
View file @
46bf88b3
from
django.http
import
JsonResponse
from
django.shortcuts
import
render
from
django.contrib.auth.decorators
import
login_required
from
django.utils.translation
import
ugettext_lazy
as
_
from
.models
import
FAQSection
,
FAQQuestion
from
.models
import
FAQSection
,
FAQQuestion
,
REBUSCategory
from
.forms
import
FAQForm
,
REBUSForm
,
FeedbackForm
from
datetime
import
datetime
...
...
@@ -15,7 +16,11 @@ from aleksis.core.models import Activity
def
create_info
(
text
):
return
'
<div class=
"
alert success
"
> <p> <i class=
"
material-icons left
"
>info</i>
'
+
text
+
'
</p> </div>
'
return
(
'
<div class=
"
alert success
"
> <p> <i class=
"
material-icons left
"
>info</i>
'
+
text
+
"
</p> </div>
"
)
def
faq
(
request
):
...
...
@@ -24,31 +29,36 @@ def faq(request):
"
questions
"
:
FAQQuestion
.
objects
.
filter
(
show
=
True
),
"
sections
"
:
FAQSection
.
objects
.
all
(),
}
return
render
(
request
,
'
hjelp/faq.html
'
,
context
)
return
render
(
request
,
"
hjelp/faq.html
"
,
context
)
@login_required
def
ask
(
request
):
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
"
POST
"
:
form
=
FAQForm
(
request
.
POST
)
if
form
.
is_valid
():
# Read out form data
question
=
form
.
cleaned_data
[
'
question
'
]
act
=
Activity
(
title
=
_
(
"
You have submitted a question.
"
),
description
=
question
,
app
=
"
Hjelp
"
,
user
=
request
.
user
)
question
=
form
.
cleaned_data
[
"
question
"
]
act
=
Activity
(
title
=
_
(
"
You have submitted a question.
"
),
description
=
question
,
app
=
"
Hjelp
"
,
user
=
request
.
user
,
)
act
.
save
()
context
=
{
"
question
"
:
question
,
"
user
"
:
request
.
user
}
send_mail_with_template
(
"
[FAQ QUESTION] {}
"
.
format
(
question
),
[
config
.
MAIL_QUESTIONS
],
"
hjelp/mail/question.txt
"
,
"
hjelp/mail/question.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
))
return
render
(
request
,
'
hjelp/question_submitted.html
'
)
context
=
{
"
question
"
:
question
,
"
user
"
:
request
.
user
}
send_mail_with_template
(
"
[FAQ QUESTION] {}
"
.
format
(
question
),
[
config
.
MAIL_QUESTIONS
],
"
hjelp/mail/question.txt
"
,
"
hjelp/mail/question.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
),
)
return
render
(
request
,
"
hjelp/question_submitted.html
"
)
else
:
form
=
FAQForm
()
...
...
@@ -59,64 +69,89 @@ def add_arrows(array: list):
return
"
→
"
.
join
([
item
for
item
in
array
if
item
!=
""
])
def
rebus_get_icon
(
request
):
category
=
request
.
GET
.
get
(
"
category
"
,
None
)
icon
=
{
"
icon
"
:
REBUSCategory
.
objects
.
get
(
name
=
category
).
icon
}
return
JsonResponse
(
icon
)
@login_required
def
rebus
(
request
):
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
"
POST
"
:
form
=
REBUSForm
(
request
.
POST
)
if
form
.
is_valid
():
# Read out form data
bug_category_1
=
str
(
form
.
cleaned_data
[
'
bug_category_1
'
])
bug_category_2
=
str
(
form
.
cleaned_data
[
'
bug_category_2
'
])
bug_category_3
=
str
(
form
.
cleaned_data
[
'
bug_category_3
'
])
short_description
=
form
.
cleaned_data
[
'
short_description
'
]
long_description
=
form
.
cleaned_data
[
'
long_description
'
]
bug_category_1
=
str
(
form
.
cleaned_data
[
"
bug_category_1
"
])
bug_category_2
=
str
(
form
.
cleaned_data
[
"
bug_category_2
"
])
bug_category_3
=
str
(
form
.
cleaned_data
[
"
bug_category_3
"
])
short_description
=
form
.
cleaned_data
[
"
short_description
"
]
long_description
=
form
.
cleaned_data
[
"
long_description
"
]
# Register activity
desc_act
=
"
{} | {}
"
.
format
(
add_arrows
([
bug_category_1
,
bug_category_2
,
bug_category_3
]),
short_description
)
act
=
Activity
(
title
=
_
(
"
You reported a problem.
"
),
description
=
desc_act
,
app
=
"
Hjelp
"
,
user
=
request
.
user
)
desc_act
=
"
{} | {}
"
.
format
(
add_arrows
([
bug_category_1
,
bug_category_2
,
bug_category_3
]),
short_description
,
)
act
=
Activity
(
title
=
_
(
"
You reported a problem.
"
),
description
=
desc_act
,
app
=
"
Hjelp
"
,
user
=
request
.
user
,
)
act
.
save
()
# Send mail
context
=
{
"
arrow_list
"
:
add_arrows
([
bug_category_1
,
bug_category_2
,
bug_category_3
]),
"
arrow_list
"
:
add_arrows
(
[
bug_category_1
,
bug_category_2
,
bug_category_3
]
),
"
short_desc
"
:
short_description
,
"
long_desc
"
:
long_description
,
"
user
"
:
request
.
user
"
user
"
:
request
.
user
,
}
send_mail_with_template
(
"
[REBUS] {}
"
.
format
(
short_description
),
[
config
.
MAIL_REBUS
],
"
hjelp/mail/rebus.txt
"
,
"
hjelp/mail/rebus.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
))
return
render
(
request
,
'
hjelp/rebus_submitted.html
'
)
send_mail_with_template
(
"
[REBUS] {}
"
.
format
(
short_description
),
[
config
.
MAIL_REBUS
],
"
hjelp/mail/rebus.txt
"
,
"
hjelp/mail/rebus.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
),
)
return
render
(
request
,
"
hjelp/rebus_submitted.html
"
)
else
:
form
=
REBUSForm
()
rooms
=
[
room
.
name
for
room
in
Room
.
objects
.
all
()]
return
render
(
request
,
'
hjelp/rebus.html
'
,
{
'
form
'
:
form
,
"
props
"
:
{
"
rooms
"
:
"
rooms
"
}})
return
render
(
request
,
"
hjelp/rebus.html
"
,
{
"
form
"
:
form
,
"
props
"
:
{
"
rooms
"
:
"
rooms
"
}}
)
@login_required
def
feedback
(
request
):
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
"
POST
"
:
form
=
FeedbackForm
(
request
.
POST
)
if
form
.
is_valid
():
# Read out form data
design_rating
=
form
.
cleaned_data
[
'
design_rating
'
]
performance_rating
=
form
.
cleaned_data
[
'
performance_rating
'
]
usability_rating
=
form
.
cleaned_data
[
'
usability_rating
'
]
overall_rating
=
form
.
cleaned_data
[
'
overall_rating
'
]
more
=
form
.
cleaned_data
[
'
more
'
]
ideas
=
form
.
cleaned_data
[
'
ideas
'
]
design_rating
=
form
.
cleaned_data
[
"
design_rating
"
]
performance_rating
=
form
.
cleaned_data
[
"
performance_rating
"
]
usability_rating
=
form
.
cleaned_data
[
"
usability_rating
"
]
overall_rating
=
form
.
cleaned_data
[
"
overall_rating
"
]
more
=
form
.
cleaned_data
[
"
more
"
]
ideas
=
form
.
cleaned_data
[
"
ideas
"
]
apps
=
form
.
cleaned_data
[
"
apps
"
]
# Register activity
act
=
Activity
(
title
=
_
(
"
You submitted feedback.
"
),
description
=
_
(
"
You rated AlekSIS with {} from 5 stars.
"
).
format
(
overall_rating
),
app
=
"
Feedback
"
,
user
=
request
.
user
)
act
=
Activity
(
title
=
_
(
"
You submitted feedback.
"
),
description
=
_
(
"
You rated AlekSIS with {} from 5 stars.
"
).
format
(
overall_rating
),
app
=
"
Feedback
"
,
user
=
request
.
user
,
)
act
.
save
()
# Send mail
...
...
@@ -128,16 +163,19 @@ def feedback(request):
"
more
"
:
more
,
"
apps
"
:
apps
,
"
ideas
"
:
ideas
,
"
user
"
:
request
.
user
"
user
"
:
request
.
user
,
}
send_mail_with_template
(
_
(
"
Feedback from {}
"
).
format
(
request
.
user
.
username
),
[
config
.
MAIL_FEEDBACK
],
"
hjelp/mail/feedback.txt
"
,
"
hjelp/mail/feedback.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
))
return
render
(
request
,
'
hjelp/feedback_submitted.html
'
)
send_mail_with_template
(
_
(
"
Feedback from {}
"
).
format
(
request
.
user
.
username
),
[
config
.
MAIL_FEEDBACK
],
"
hjelp/mail/feedback.txt
"
,
"
hjelp/mail/feedback.html
"
,
context
,
"
{} <{}>
"
.
format
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
),
)
return
render
(
request
,
"
hjelp/feedback_submitted.html
"
)
else
:
form
=
FeedbackForm
()
return
render
(
request
,
'
hjelp/feedback.html
'
,
{
'
form
'
:
form
})
return
render
(
request
,
"
hjelp/feedback.html
"
,
{
"
form
"
:
form
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment